Jonathan Dearborn <grimfang4 gmail.com> writes:
Has your Googling led you here?
http://pubpages.unh.edu/~jmb97/tutorials/blending.htmlIf you’re looking to
copy the alpha channel, you have to disable alpha-blending using SDL_SetAlpha
(surface, 0, surface->format->alpha), blit it, then re-enable it SDL_SetAlpha
(newSurface, SDL_SRCALPHA, newSurface->format->alpha).Jonny D
I’ve done a number of google searches and read the documentation about
SDL_BlitSurface(), SDL_SetAlpha(), SDL_CreateRGBSurface(), SDL_GetRGBA() and
SDL_MapRGBA. So far I haven’t come up with any clear answers and have gone
through dozens of pages of text, some not even C/C++ code.
Here’s the problem I’m having.
I have one surface that I load up using IMG_Load() – no problems there. Per-
Pixel alpha turns up normally as expected. Whoopdeedoo – never had a problem
Now, I want to break up that image into smaller pieces so I can arrange them
however I want. So, I use SDL_Surface *surface = SDL_CreateRGBSurface(…) to
create a surface of the correct size. I then blit the area from the larger
image that I need into the smaller image. No problems with that either.
But, it’s clear that the surface I’m creating gets initialized to all black
with no per-pixel alpha values.
How can I copy the per-pixel alpha values from the source image to the
My first thought was to use SDL_SetAlpha – but naturally that doesn’t work
properly. That’s when I looked around and found that this is apparently a
common question but there seem to be no clear answers.
Is there a simple way to do this or will I have to come up with a function to
read per-pixel alpha values from the source and write them to the
Am I just making this far more difficult than it really needs to be?
Thanks for taking the time to read over this message.
Thank you very much for pointing me in the right direction! Actually, that
site never did come up in my google searches – Must not have used a good
search string… -_-
Thanks again! I really do appreciate it!