[cairo] CAIRO_FORMAT_A8 / stride

Owen Taylor otaylor at redhat.com
Sun Jul 2 08:30:36 PDT 2006


On Sat, 2006-07-01 at 20:38 +0000, Nikolaj Thygesen wrote:
> Howdy list,
> 
>     I'm new to Cairo and this list, and I'm currently doing a graphics gtk+ 
> application in which I want to render text to a Cairo 
> CAIRO_FORMAT_A8/image_surface using Pango. Now I'm wondering whether it's a 
> feature or a bug, when stride insists on being a multiple of four even when 
> using CAIRO_FORMAT_A8 == one byte / pixel??? It looks like the rendering 
> chops off the two least significant bits of the stride, but I've found no 
> documents documenting this "feature", which seems odd to me.

Generally, using multiple-of-word-size row strides allows for better
optimization that wouldn't be possible, because every line starts off
word-aligned. So if you let Cairo create an image surface, it will
pad the lines out to a multiple of word length.

I'd be very surprised if it the last bits get "chopped off" - the usual
equation for is something like:

 stride = (width + 3) & ~3

Which rounds up, rather than down.

					- Owen




More information about the cairo mailing list