[cairo] Confused by render to image buffer

Ned Konz ned at squeakland.org
Fri Dec 24 12:45:33 PST 2004


On Friday 24 December 2004 11:30 am, Chris wrote:
> I'm rendering to an image buffer by way of the svg-cairo stuff:
> cairo_set_target_image(rend, buffer, CAIRO_FORMAT_ARGB32, width, height,
> width);
> svg_cairo_render(ctx, rend);
>
> This seems to mostly work if I set the target to a PNG image but when
> the target is just a memory buffer then the results don't appear to be
> anything like the image.

The last argument to cairo_set_target_image() should be the stride, not the 
width. In the case of a 90 pixel wide square, the stride should be 90*4 (for 
RGBA), not 90.

> For example, I tried rendering a plain black square with alpha 254 that
> fills the entire image area.  Image size comes out at 90x90 pixels.  The
> result in the image buffer is something like:
>
> 00 00 00 FE 00 00 00 FE 00 00 00 FE 00 00 00 FE 00 00 00 FE
>
> Which appears to be correct but it stops after about 16 RGBA values.
> Then I get some 00 00 00 FF values for about 2000 more pixels. Finally,
> then from there to the end (some 6000 pixels) are all null values.
>
> What happened to the rest of the image?

-- 
Ned Konz
http://bike-nomad.com/squeak/



More information about the cairo mailing list