Skip to main content
GameDev.net gamedev.net
🔒 Locked

SDL_Image loading/format question

Started by Atash Mar 29, 2006 at 9:33 PM 4 replies 1k views
Original Post
Atash
Atash
In SDL_Image, when an image is loaded, is it loaded as an RGB or an RGBA surface? Thank you in advance :-) [Edited by - Atash on March 29, 2006 9:55:03 PM]
After ArgumentP1: What was it about?P2: Something involving a chair, a cat, and a rubber ducky...
caseyd
caseyd
I'm not sure. I just spent a few minutes looking through some material but couldn't find anything. What I would do is load an image using it and than look at the Pixelformat structure through the format member. Maybe compare the differences to a non RGBA surface. I'm sure that certain values, such as Amask would be different for non-RGBA surfaces.
Atash
Atash
Okay, that brings me to a different issue (because of OGL tex loading functions and... yeah)... When you have an SDL_Surface that has pixel data, is all of that data stored with slots for every single value (RGBA), and when using it in RGB mode you simply skip over the Alpha, or is it that it is ACTUALLY stored in an RGB format?

Thanks in advance!!!
After ArgumentP1: What was it about?P2: Something involving a chair, a cat, and a rubber ducky...
Lazy Foo
Lazy Foo
Quote:
Original post by Atash
Okay, that brings me to a different issue (because of OGL tex loading functions and... yeah)... When you have an SDL_Surface that has pixel data, is all of that data stored with slots for every single value (RGBA), and when using it in RGB mode you simply skip over the Alpha, or is it that it is ACTUALLY stored in an RGB format?

Thanks in advance!!!


If all you want is a consistent format when loading the image just convert the loaded surface to RGBA:

        //The format    SDL_PixelFormat format;            //Set format    format.palette = NULL;    format.BitsPerPixel = 32;    format.BytesPerPixel = 4;            //Set mask    #if SDL_BYTEORDER == SDL_BIG_ENDIAN    format.Rmask = 0xFF000000;    format.Gmask = 0x00FF0000;    format.Bmask = 0x0000FF00;    format.Amask = 0x000000FF;    #else    format.Rmask = 0x000000FF;    format.Gmask = 0x0000FF00;    format.Bmask = 0x00FF0000;    format.Amask = 0xFF000000;    #endif            //Set shift    format.Rshift = 8; format.Gshift = 8; format.Bshift = 8; format.Ashift = 8;            //Set loss    format.Rloss = 0; format.Gloss = 0; format.Bloss = 0; format.Aloss = 0;


then convert the surface with that pixel format.
Learn to make games with my SDL 2 Tutorials

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.