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…


On 02/08/11 19:05, Thomas Harty wrote:
Thank you for the reply.

I tried following the example here: 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 ( 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?


From: gtkmm-list-bounces gnome org [gtkmm-list-bounces gnome org] on behalf of Yann LEYDIER [yann leydier info]
Sent: 02 August 2011 16:29
To: gtkmm-list gnome org
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! ;)

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?


gtkmm-list mailing list
gtkmm-list gnome org

gtkmm-list mailing list
gtkmm-list gnome org

[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]