Re: Gtk::Image and HiDPI



On Mon, Feb 11, 2019 at 09:48:05AM +0000, Kasper Peeters wrote:
Try using a Cairo surface (or cairo_surface_t) with the appropriate
scaling factor (see cairo_surface_set_device_scale).

A GdkPixbuf doesn't have a scaling factor attached to it, but a Cairo
surface does. Generally speaking, these days there's a trend to move
towards the latter wherever possible and makes sense.

I tried using a Gtk::DrawingArea instead of my Gtk::Image, and then used
the following override of 'DrawingArea::on_draw' to draw my pixbuf onto
the Cairo surface provided by the DrawingArea:

This should also work. There must be something wrong in your code.

So this is probably not what you meant... Can you give me a pointer?

I meant gtk_image_set_from_surface and gtk_image_new_from_surface. You
can convert the GdkPixbuf to a Cairo surface using things like
gdk_cairo_surface_create_from_pixbuf.


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