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

Re: SDL question



The "pitch" is the number of bytes between pixels. It is usually safe to use
the original surface for this (I don't have SDL docs handy, but I think
Martin Donlon is on this list, so he'd know, seeing as he wrote the SDL
documentation), which I think is SDL_Surface->pitch or something similar.

The RGB masks specifiy where in each pixel the different color information
is stored.

In a 16 bit pixel, the mask would be something like this:
R=0xFFFFFFFF >> 11
G=(0xFFFFFFFF >> 6) ^ R
B=(0xFFFFFFFF) ^ (R | G)
(with ^ being XOR, not to the power of, swap R and B depending on your
endian)

Or something like that. It's not usually that complicated (you have bit
masks and shifts for each color, so the renderer does all the conversions
for you), but you have very little *real* control over the actual masks. You
will have to use the ones returned by SDL_CreateSurface() or whatever the
function is called. They're all kept somewhere in the SDL_Surface structure.

The Infamous Mark 'Nurgle' Collins
Project Manager/Chief code monkey - 'Obligatory Flame'
Maintainer - 'OpenLobby'


----- Original Message -----
From: MAO <maos@gbl.com.br>
To: <linuxgames@sunsite.auc.dk>
Sent: Monday, January 29, 2001 10:41 AM
Subject: SDL question


> Hey there,
>
>
>
>
>     Anyone familiar with SDL, could you give me a help here? I've been
> working with GGI for some time, but now I want to port some of my
> applications to  SDL. How do I calculate the "pitch" to use with the
> SDL_CreateRGBSurfaceFrom, once I have an image loaded into a buffer, with
> it's width and height? And what are the R, G and B masks for, and how do I
> find out what are they?
>
>
>
>
> Thanks in advance,
> M.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: linuxgames-unsubscribe@sunsite.dk
> For additional commands, e-mail: linuxgames-help@sunsite.dk
>
>


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