Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

barazor

loading raw pixel data into an SDL_Surface?

This topic is 5778 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

i have been trying to figure out how to load my own custom image format into an SDL_Surface, with no luck. i''ve tried looking at the SDL_Image code, but i haven''t been able to get anywhere. can anyone show me the basic steps in loading raw pixel data from a file into a a surface?

Share this post


Link to post
Share on other sites
Advertisement
Read the guidevideo.htm file in the SDL docs. You learn about writing directly to the surface memory, locking and unlocking the surface, with code examples.

Share this post


Link to post
Share on other sites
If you use SDL_CreateRGBSurfaceFrom, remember you have to free the pixel data, and remember that SDL_FreeSurface won''t do this for you:

quote:

From SDL_CreateRGBSurfaceFrom

The pixel data is not copied into the SDL_Surface structure so it should not be freed until the surface has been freed with a called to SDL_FreeSurface.




quote:

From SDL_FreeSurface

If the surface was created using SDL_CreateRGBSurfaceFrom then the pixel data is not freed.




aut viam inveniam aut faciam

MoonStar Projects

Share this post


Link to post
Share on other sites
alright, i solved my own problem. turned out that i confused the amask and rmask parameters, and set the red channel mask to 0

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!