[cairo] CAIRO_FORMAT_A8 / stride

Nikolaj Thygesen nikolaj.thygesen at hotmail.com
Sun Jul 2 13:07:09 PDT 2006


    The thing is that I'm using an existing buffer for the data part, so I 
don't always know whether stride is divisible by four, and the size of the 
buffers may be substantial, so I'd hate to create temporary copies.
    Suppose I created my own "local_image_surface" by cloning the official  
"cairo_image_surface.c", and implemented what I need. Would other parts of 
Cairo still readjust my "odd" stride, or could I get away with it?? I have 
looked around at the Cairo sources but find very few references to stride.

    br - Nikolaj Thygesen

>From: Owen Taylor <otaylor at redhat.com>
>To: Nikolaj Thygesen <nikolaj.thygesen at hotmail.com>
>CC: cairo at cairographics.org
>Subject: Re: [cairo] CAIRO_FORMAT_A8 / stride
>Date: Sun, 02 Jul 2006 11:30:36 -0400
>
>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
>
>

_________________________________________________________________
Log på MSN Messenger direkte på nettet:  http://webmessenger.msn.com



More information about the cairo mailing list