[cairo] problem with scaling images

Kristian Høgsberg krh at bitplanet.net
Thu Jul 14 11:30:18 PDT 2005

Benjamin Berg wrote:
> Hello,
> I am currently trying to port my gtk engine to cairo.

Good news!

> Everything worked
> pretty smoothly, but I ran into a problem.
> I am trying to draw scaled images, but somehow they fade out at one
> side, and are placed at the wrong position. For an example see:
> http://benjamin.sipsolutions.net/screenshots/zenity-wrong.png
> as a reference, an old version not rendered with cairo:
> http://benjamin.sipsolutions.net/screenshots/zenity-correct.png
> For example look at the top of the buttons. The line should have full
> opacity everywhere, but at the left it transparent.
> I have attached image.c, which is, where I think the problem is in. The
> draw_image_part function in image.c:313 should draw an image at a
> certain position and scale. But as soon as the the image needs to be
> scaled it does not work correctly. The corners, which are not scaled,
> are drawn correctly.
> To demonstrate this, here a screenshot where only the corners are drawn:
> http://benjamin.sipsolutions.net/screenshots/zenity-corners-only.png


I wasn't able to view any of your sipsolutions.net screenshots or get 
the theme source code, I got "Document contains no data".  From your 
description of the problem, it sounds like a workaround could be setting 
the pattern filtering to be CAIRO_FILTER_NEAREST:

   cairo_pattern_set_filter (pattern, CAIRO_FILTER_NEAREST);

but I think the real problem could be an off-by-one error in the width 
calculation in your code, or in possibly in cairo.  If you can put the 
code and the screenshots up somewhere where I can get them, I'll take a 


More information about the cairo mailing list