[cairo] problem with scaling images

Bill Spitzak spitzak at d2.com
Thu Jul 14 11:54:10 PDT 2005

Though I can't get them now, I did see his sample images before when 
this was first posted.

It looks like the alpha for each image he draws is replaced with a 
gradient with 1,1 in the upper-left corner and 0,0 in the lower-right. 
His buttons are drawn by cutting the image into 9 pieces in a 
tic-tac-toe pattern and scaling each piece differently, with the corners 
unscaled, the edges scaled in one direction, and the center scaled in both.

Though I did not look at the code, I would suspect a bug in Cairo 
itself, as the color part of the image appears to be correct.

Kristian Høgsberg wrote:
> 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
> Hi,
> 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 
> look.
> cheers,
> Kristian
> _______________________________________________
> cairo mailing list
> cairo at cairographics.org
> http://lists.freedesktop.org/mailman/listinfo/cairo

More information about the cairo mailing list