Re: Gtk::Image and HiDPI



On Fri, Feb 08, 2019 at 07:40:06PM +0000, Kasper Peeters wrote:
When I set the content of a Gtk::Image from a pixbuf, gtk seems to be
scaling up the visible size by the HiDPI scale factor. That is, if I
feed it a pixbuf of 100x100 pixels, on a screen with scale factor 2, it
will be upscaled to cover 200x200 device pixels, making it blocky.

Is there any way in which I can tell gtk not to do that, so that when I
feed it a 200x200 image, it will actually draw it at 200x200 device
pixels, not 400x400 device pixels?

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.


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