[cairo] Problem with drawing pixbuf

Tobias Hoffmann lcairo-list at thax.hardliners.org
Sun Sep 26 09:35:28 PDT 2010


Hi,

I use cairo(mm) with a Gtk::DrawingArea. There I display a simple image 
(e.g. just white), loaded into a Gdk::Pixbuf, using essentially the 
following code:

... Cairo::RefPtr<Cairo::Context>  cr   ... scaled to window size ... 
paint background gray ...
cr->save();
cr->translate(5,5); // just to show the borders are there also on the 
left and top.
Gdk::Cairo::set_source_pixbuf(cr,data[imgid],0,0);
// cr->push_group();
cr->paint();
// cr->pop_group_to_source();
// cr->paint();
cr->restore();

This leads to a black border around the image, as can be seen in 
http://thax.hardliners.org/test/pic1.png
The expected behavior would be http://thax.hardliners.org/test/pic2.png 
, as can be obtained by adding the commented-out sections above.
But this workaround becomes really slow for bigger window-sizes.

I've tried different antialias-modes and operator-modes with no success. 
It also seems to not be possible to set the background color of the 
source. Even using a clipping path does not really work without cutting 
away "too much". Setting EXTEND_PAD is problematic for images that have 
some content that touches the border.

So what is the correct way for doing this?

FYI, I've used debian's libcairo2 1.8.8-2 and now 1.8.10-6; the problem 
does not exist in a windows-version under wine with cairo 1.9.14, though.

Regards
  Tobias



More information about the cairo mailing list