Transparent Bitmaps (SDL)
To make the bitmap ''swat1up'' have transparency on its white pixels, I put:
int SDL_SetColorKey(SDL_Surface *swat1up, SDL_SRCCOLORKEY, 0, 0, 0);
I get error C2059: syntax error : ''constant''
You have to map the RGB color to the pixel format of the surface.
BTW, (255,255,255) is white, (0,0,0) is black.
http://roninmagus.hopto.org
acronymfinder.com - Find any acronym you need!
SDL_Surface * swat1up;SDL_SetColorKey(swat1up, SDL_SRCCOLORKEY, SDL_MapRGB(swat1up->format, 255, 255, 255));
BTW, (255,255,255) is white, (0,0,0) is black.
http://roninmagus.hopto.org
acronymfinder.com - Find any acronym you need!
error C2501: ''SDL_SetColorKey'' : missing storage-class or type specifiers
error C2373: ''SDL_SetColorKey'' : redefinition; different type modifiers
c:\unzipped\sdl-devel-1.2.3-vc6[1]\sdl-1.2.3\include\sdl_video.h(567) : see declaration of ''SDL_SetColorKey''
error C2078: too many initializers
error C2373: ''SDL_SetColorKey'' : redefinition; different type modifiers
c:\unzipped\sdl-devel-1.2.3-vc6[1]\sdl-1.2.3\include\sdl_video.h(567) : see declaration of ''SDL_SetColorKey''
error C2078: too many initializers
quote:Original post by BioSquirrel
int SDL_SetColorKey(SDL_Surface *swat1up, SDL_SRCCOLORKEY, 0, 0, 0);
You're declaring a function prototype here: almost certainly not what you want. The format should be:
SDL_SetColorKey(swat1up, SDL_SRCCOLORKEY, 0, 0, 0);
It's just a function call, after all. But also see what Ronin posted above. Or use my little function here:
inline int SDL_SetNativeColorKey(SDL_Surface* const in, int flags, Uint8 r, Uint8 g, Uint8 b){ return SDL_SetColorKey(in, flags|SDL_SRCCOLORKEY, SDL_MapRGB(in->format, r, g, b));}
[ MSVC Fixes | STL | SDL | Game AI | Sockets | C++ Faq Lite | Boost | Asking Questions | Organising code files | My stuff ]
[edited by - Kylotan on December 4, 2002 8:31:35 PM]
Are you sure that all the pixels you want transparent are absolutely RGB(255,255,255)? Transparency will not work if any of the color values of the pixel are off by even 1 unit.
After the transparency is set, simply calling SDL_BlitSurface with the transparent surface as before should work fine.
http://roninmagus.hopto.org
acronymfinder.com - Find any acronym you need!
After the transparency is set, simply calling SDL_BlitSurface with the transparent surface as before should work fine.
http://roninmagus.hopto.org
acronymfinder.com - Find any acronym you need!
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement