Harry,

I tried that originally, but I got complier errors:

‘class Gdk::Pixbuf’ has no member named ‘render_to_drawable’
‘get_style’ was not declared in this scope
‘RGB_DITHER_NONE’ is not a member of ‘Gdk’

(I'm including <gtkmm.h> and <gdkmm.h> and compiling with: g++ `pkg-config 
gtkmm-3.0 --cflags --libs`)

I had a look in Pixbuf reference 
(http://developer.gnome.org/gtkmm/unstable/classGdk_1_1Pixbuf.html) and 
couldn't see any reference to render_to_drawable. I also couldn't find this in 
the headers or any of the widgets it's derived from. The gdkmm/gdk/pixbf.h had 
the comment:

//Use Gdk::Drawable::draw_pixbuf() instead of gdk_pixbuf_render_to_drawable(), 
gdk_pixbuf_render_to_drawable_alpha().

Any ideas?
________________________________
From: Harry van Haaren [[email protected]]
Sent: 02 August 2011 21:02
To: Thomas Harty
Cc: Yann LEYDIER; [email protected]
Subject: Re: Images in GTKmm

Hi Thomas,

Gtk 3 uses Cairo for its drawing backend, so one option would be to subclass 
Gtk::DrawingArea, and then load a .png or so with Cairo, and copy that to the 
cairo surface (& hence the Gtk::DrawingArea), after which you can display the 
DrawingArea as a normal widget.

Another option is to use Gdk::Pixbuf and friends. This might be the easier 
option, but provides less flexibility.

This link provides up to date (ie: Gtk3) info on both:
See this link: 
http://developer.gnome.org/gtkmm-tutorial/3.0/sec-draw-images.html.en

Good luck! -Harry



On Tue, Aug 2, 2011 at 6:49 PM, Thomas Harty 
<[email protected]<mailto:[email protected]>> wrote:
Thanks. It looks like these won't work in gtkmm3. E.g. the "Changes in gtkmm 3" 
notes:

9. Gdk::Pixmap and Gdk::Bitmap were removed in favour of Gdk::Pixbuf.

I had a look in the Gdk::window api 
(http://developer.gnome.org/gtkmm/stable/classGdk_1_1Window.html), but couldn't 
see a draw_drawable method.

Any idea how to do this in gtkmm3?

Tom
________________________________________
From: [email protected]<mailto:[email protected]> 
[[email protected]<mailto:[email protected]>] on behalf 
of Yann LEYDIER [[email protected]<mailto:[email protected]>]
Sent: 02 August 2011 18:19
To: [email protected]<mailto:[email protected]>
Subject: Re: Images in GTKmm

I'm not using Gtkmm 3, but you might have to use cairomm to do that.

In Gtkmm 2, I render the Pixbuf to a Pixmap and then use
Gdk::Window::draw_drawable on the DrawingArea's Gdk window. Perhaps it
still works in API 3…


yann

On 02/08/11 19:05, Thomas Harty wrote:
> Thank you for the reply.
>
> I tried following the example here: 
> http://developer.gnome.org/gtkmm-tutorial/3.0/sec-draw-images.html.en to test 
> out using a Pixbuf in a Drawing area, but got a few compile-time errors (n.b. 
> I'm using gtkmm 3.0):
>
> error: ‘class Gdk::Pixbuf’ has no member named ‘render_to_drawable’
> error: ‘get_style’ was not declared in this scope
> error: ‘RGB_DITHER_NONE’ is not a member of ‘Gdk’
>
> I had a look in the class reference 
> (http://developer.gnome.org/gtkmm/3.1/classGdk_1_1Pixbuf.html) and couldn't 
> see render_to_drawable. Has this been depreciated in gtkmm 3? If so, what's 
> the appropriate way to do this now?
>
> Tom
>
>
>
> ________________________________________
> From: [email protected]<mailto:[email protected]> 
> [[email protected]<mailto:[email protected]>] on behalf 
> of Yann LEYDIER [[email protected]<mailto:[email protected]>]
> Sent: 02 August 2011 16:29
> To: [email protected]<mailto:[email protected]>
> Subject: Re: Images in GTKmm
>
> I would do this with a DrawingArea. It is possible to resize a Pixbuf to
> the size of the DrawingArea and render it in a callback plugged to the
> expose_event signal.
>
> But I don't known if it is the best way! ;)
> yann
>
> On 02/08/11 12:51, Thomas Harty wrote:
>> I want to put an image into a box in such a way that the image will
>> shrink to fit into empty space in the box, whilst preserving its aspect
>> ratio. Thus, the dimensions of the image should be determined by the
>> dimensions of the objects around it. The image needs to shrink and
>> expand with the box (e.g. if the user re-sizes the main window).
>>
>> For example, I want to put a few items in a VBox and have these items
>> determine the width of the VBox. I then want to be able to add the image
>> to the VBox in such a way that it doesn't resize the box, but rather
>> fits into the space. If there is space left above/below the widget (due
>> to the constraint of preserving it's aspect ratio), this should be
>> filled with padding, rather than the image expanding to fill the space.
>>
>> What's the best way of accomplishing this in Gtkmm?
>>
>> Tom
>>
>>
>>
>> _______________________________________________
>> gtkmm-list mailing list
>> [email protected]<mailto:[email protected]>
>> http://mail.gnome.org/mailman/listinfo/gtkmm-list
>
> _______________________________________________
> gtkmm-list mailing list
> [email protected]<mailto:[email protected]>
> http://mail.gnome.org/mailman/listinfo/gtkmm-list

_______________________________________________
gtkmm-list mailing list
[email protected]<mailto:[email protected]>
http://mail.gnome.org/mailman/listinfo/gtkmm-list
_______________________________________________
gtkmm-list mailing list
[email protected]<mailto:[email protected]>
http://mail.gnome.org/mailman/listinfo/gtkmm-list

_______________________________________________
gtkmm-list mailing list
[email protected]
http://mail.gnome.org/mailman/listinfo/gtkmm-list

Reply via email to