[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: SDL question

Martin Donlon wrote:
> The 'pitch' is the length of each scanline of the image in bytes. So for an
> 8bpp image the pitch would usually be equal to the width, for a 16bpp image
> the pitch would usually be width*2.

	Aye, I eventually discovered that about 5 min after I sent this
message, but, of course, thanks anyway. I found somthing curious though:
SDL uses a 4 byte padding scheme for the "pitch" attribute, for speed
optimization. What I found out was that this actually did not work with
"odd" sized images (not divisible by 4, maybe?) because when I looked at
SDL's source code, I discovered this SDL_CalculatePitch function, used
internally only, and the calculations start indeed with a line somewhat

	pitch = image->width*image->pixelformat->bytesperpixel;

and go on with the mentioned 4 byte padding. So, what I did was copy
these lines to my main() function and tested the routine to calculate
the pitch. The image displayed was corrupted, and when I commented the
padding calculation, it worked fine - that is, exactly what you said
about width*2, in the case of a 16bpp image. Thing is, the padding seems
to work fine with widths that are multiples of 4.

> The [RGBA] masks specify how the colour components are packed. These are
> ignored in 8-bit modes. A standard 32-bit surface would have masks like:
> (Little Endian)
> R: 0x000000ff
> G: 0x0000ff00
> B: 0x00ff0000
> A: 0xff000000
> (Big Endian)
> R: 0xff000000
> G: 0x00ff0000
> B: 0x0000ff00
> A: 0x000000ff

	Hum, my 16bpp images displayed correctly using a R:0, G:0, B:0, A:0
mask - how come?


To unsubscribe, e-mail: linuxgames-unsubscribe@sunsite.dk
For additional commands, e-mail: linuxgames-help@sunsite.dk