Creating a RGB surface

Hi there, I just wanted to get some explanation and help for creating an
empty (or not) surface.

The image should just be created and then wrote to disk…

SDL_Surface *mySurface =
SDL_CreateRGBSurfaceFrom(myPixels, w, h, 32,
?, ?, ?, ?, ?);

Now, you see I don’t quite understand the use of Mask… I would like
to create a simple RGBA image with no mask at all… Also, I was
wondering for a 8 bit-per-color RGBA (would mean 4 bytes for each
pixels), the pitch should be 4*w ??

Thanks for your help!
Xilo–
Dedicated to audio/visual and interactive artwork.
http://www.geocities.com/simonlemieux/

Xilo Musimene: “[SDL] Creating a RGB surface” (2003-07-17 01:18)

#Hi there, I just wanted to get some explanation and help for creating an
#empty (or not) surface.#
#The image should just be created and then wrote to disk…

#SDL_Surface *mySurface =
#SDL_CreateRGBSurfaceFrom(myPixels, w, h, 32,
#?, ?, ?, ?, ?);

pitch = wbytes_per_pixel in this case, may be something else if the
surface is in hardware etc. So w
4 seems correct! The exact meaning of
pitch is therefore “the number of bytes one ‘scanline’ of the surface
occupies”.

‘Uint32 Rmask’ is used like this:

RMask == 0xFF000000 means the red color component is stored using the
most significant byte of the 32 bit integer (Uint32).

The usual setting for a RGBA surface would therefore be
CreateRGBSurfaceFrom(…, w*4, 0xFF << 24, 0xFF << 16, 0xFF << 8,
0xFF);

Anyway, see this code in the doc to get a more thorough (?) picture:

http://sdldoc.csn.ul.ie/sdlcreatergbsurface.php

regards,

/Olof

Olof Bjarnason wrote:

Xilo Musimene: “[SDL] Creating a RGB surface” (2003-07-17 01:18)

#Hi there, I just wanted to get some explanation and help for creating an
#empty (or not) surface.

#The image should just be created and then wrote to disk…

#SDL_Surface *mySurface =
#SDL_CreateRGBSurfaceFrom(myPixels, w, h, 32,
#?, ?, ?, ?, ?);

pitch = wbytes_per_pixel in this case, may be something else if the
surface is in hardware etc. So w
4 seems correct! The exact meaning of
pitch is therefore “the number of bytes one ‘scanline’ of the surface
occupies”.

Ok, this is pretty simple, thanks for the confirmation!

‘Uint32 Rmask’ is used like this:

RMask == 0xFF000000 means the red color component is stored using the
most significant byte of the 32 bit integer (Uint32).

The usual setting for a RGBA surface would therefore be
CreateRGBSurfaceFrom(…, w*4, 0xFF << 24, 0xFF << 16, 0xFF << 8,
0xFF);

Anyway, see this code in the doc to get a more thorough (?) picture:

Yes, the code is a very ‘visual’ explanation… I wonder what would
happen if something else than 0xFF had been used? Such as 0x80 ??

Thanks a lot, now I really understand surfaces, well, enough for my needs!

Thanks,
Xilo–
Dedicated to audio/visual and interactive artwork.

Xilo Musimene: “[SDL] Re: Creating a RGB surface” (2003-07-17 09:28)

#Olof Bjarnason wrote:
#> ### Xilo Musimene: “[SDL] Creating a RGB surface” (2003-07-17 01:18) ###
#> #Hi there, I just wanted to get some explanation and help for creating an
#> #empty (or not) surface.
#> #
#> #The image should just be created and then wrote to disk…
#> #
#> #SDL_Surface mySurface =
#> #SDL_CreateRGBSurfaceFrom(myPixels, w, h, 32,
#> #?, ?, ?, ?, ?);
#>
#> pitch = w
bytes_per_pixel in this case, may be something else if the
#> surface is in hardware etc. So w*4 seems correct! The exact meaning of
#> pitch is therefore “the number of bytes one ‘scanline’ of the surface
#> occupies”.#
#Ok, this is pretty simple, thanks for the confirmation!

#> ‘Uint32 Rmask’ is used like this:
#>
#> RMask == 0xFF000000 means the red color component is stored using the
#> most significant byte of the 32 bit integer (Uint32).
#>
#> The usual setting for a RGBA surface would therefore be
#> CreateRGBSurfaceFrom(…, w*4, 0xFF << 24, 0xFF << 16, 0xFF << 8,
#> 0xFF);
#>
#> Anyway, see this code in the doc to get a more thorough (?) picture:

#Yes, the code is a very ‘visual’ explanation… I wonder what would
#happen if something else than 0xFF had been used? Such as 0x80 ??

Yep, “visual” is a good word for the documentation in some places :slight_smile:

At least I think the doc’s could be more detailed here and there, much
is assumed as “folk lore” = things people already now. I had to
"guess" many things when starting with SDL, and still have to guess
or mail this list to get the details…

see ya,

/Olof