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

Easy alpha + pixel manipulation w/ SDL.

Started by Ruzhyo2000 Feb 6, 2010 at 5:30 PM 1 replies 2.2k views
Original Post
Ruzhyo2000
Ruzhyo2000
First of all, thanks for anyone who can help me out. I tried looking through SDL documentation and doing google searches but nothing helped me out with this. I have two main questions: 1. If an SDL_Surface uses 32bit pixel data, I know how to pull a single pixel's information and store it in a Uint32, but how would I modify the single pixel data once it is in the Uint32 format? Specifically, I want to be able to modify the pixel's alpha value, and place it into a new SDL_Surface. 2. This is why the first question is relevant. Basically what I want to do is use, in the source image for my SDL_surface that will hold my sprites, an alpha mask for every sprite. Basically, for every sprite on my sprite sheet, I want a corresponding alpha mask that is black and white, where the percentage that a pixel is black corresponds with the percentage I want that pixel on the sprite to be alpha'd. My question is: is there a super simple way to do this (that SDL provides specifically for this purpose, perhaps), or would I have to use the pixel-by-pixel manipulation method I plan on using with the knowledge gained by question one?
rip-off
rip-off
These links might help:
Pixel Access
SDL_GetRGB()
SDL_MapRGBA()

I don't believe there is a *super* simple way to do this, but it isn't all that difficult. I assume you have a reason for storing the alpha data separately from the image data?
Ruzhyo2000
Ruzhyo2000
Quote:
Original post by rip-off
These links might help:
Pixel Access
SDL_GetRGB()
SDL_MapRGBA()

I don't believe there is a *super* simple way to do this, but it isn't all that difficult. I assume you have a reason for storing the alpha data separately from the image data?


Thanks for the links! I literally passed right over those (SDL_GetRGB and SDL_MapRGBA) when reading the wiki, confusing them with a different set of functions I was passively aware of. Those functions certainly appear to be simple enough..

And honestly, now that I think about it, no I don't have a very good reason... I have been using microsoft paint to make all of my images and, to my knowledge it doesn't have anything that allows me to edit the alpha channel of an image. I suppose I don't HAVE to use paint... I just wanted to see how easily all this could be done. Thanks again.

Topic Locked

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

Sign in to reply to this topic.