Re: Gtk::Image and HiDPI
- From: Kasper Peeters <kasper peeters phi-sci com>
- To: Debarshi Ray <rishi is lostca se>
- Cc: gtkmm-list <gtkmm-list gnome org>
- Subject: Re: Gtk::Image and HiDPI
- Date: Mon, 11 Feb 2019 09:48:05 +0000
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:
-----
bool MyArea::on_draw(const Cairo::RefPtr<Cairo::Context>& cr)
{
if(!pixbuf) return false;
auto surface = cr->get_target();
auto csurface = surface->cobj();
cairo_surface_set_device_scale(csurface, 1.0, 1.0);
Gdk::Cairo::set_source_pixbuf(cr, pixbuf, 0, 0);
cr->paint();
}
-----
Unfortunately, the inclusion of that 'cairo_surface_set_device_scale'
makes the widget go black completely, unless the scale factor already
was 1.0.
So this is probably not what you meant... Can you give me a pointer?
Thanks,
Kasper
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]