[SDL] Loading alpha-channeled PNGs?
DARKGuy .
dark.guy.2008 at gmail.com
Tue Sep 12 21:04:14 PDT 2006
Hi! ^^
I just subscribed to this mailing list in hopes someone here would be able
to help me (as I haven't found a SDL forum yet). I've been trying to learn
SDL and so far so good, I've learnt how to put an image, animate a sprite,
change resolution... well, just basic stuff. Now, however, my sprites are in
PNG. Since there are black areas on it I choosed not to use SDL_SetColorKey.
Testing, I used it this way:
SDL_SetColorKey(temp, SDL_SRCCOLORKEY, SDL_MapRGB(temp->format, 0, 0, 0));
It works, there's no black border around it, but the black areas on the
sprite are transparent too! (well, that's logical) I'm loading the PNG
using...
if((temp = IMG_Load("sprites/ship0001.png")) == NULL){ printf("Error
loading sprite"); return 1; }
SDL_SetColorKey(temp, SDL_SRCCOLORKEY, SDL_MapRGB(temp->format, 0, 0,
0));
mAnim[0].image = SDL_DisplayFormat(temp); SDL_FreeSurface(temp);
Somehow I'm missing something here. My question is: Anybody knows how to
load the PNG file, and use the Alpha channel as the transparency one, and
not a RGB 0,0,0 color key as if it was a plain 8-bit image?
Thanks in advance :)
- DARKGuy
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.libsdl.org/pipermail/sdl-libsdl.org/attachments/20060913/344bf81c/attachment.htm
More information about the SDL
mailing list