# HG changeset patch # User Sam Lantinga # Date 1238765253 0 # Node ID 7be21a78777e78aab90ea2eaeae4f4a3e5983b21 # Parent 73fe1f73a56fb38e7d0e3b1cecdb2e254ba4572a Added SDL_GetColorKey() diff -r 73fe1f73a56f -r 7be21a78777e include/SDL_surface.h --- a/include/SDL_surface.h Sat Mar 28 06:00:42 2009 +0000 +++ b/include/SDL_surface.h Fri Apr 03 13:27:33 2009 +0000 @@ -199,6 +199,19 @@ extern DECLSPEC int SDLCALL SDL_SetColorKey(SDL_Surface * surface, Uint32 flag, Uint32 key); +/* + * \fn int SDL_GetColorKey(SDL_Surface *surface, Uint32 *key) + * + * \brief Sets the color key (transparent pixel) in a blittable surface. + * + * \param surface The surface to update + * \param key A pointer filled in with the transparent pixel in the native surface format + * + * \return 0 on success, or -1 if the surface is not valid or colorkey is not enabled. + */ +extern DECLSPEC int SDLCALL SDL_GetColorKey(SDL_Surface * surface, + Uint32 * key); + /** * \fn int SDL_SetSurfaceColorMod(SDL_Surface *surface, Uint8 r, Uint8 g, Uint8 b) * diff -r 73fe1f73a56f -r 7be21a78777e src/video/SDL_surface.c --- a/src/video/SDL_surface.c Sat Mar 28 06:00:42 2009 +0000 +++ b/src/video/SDL_surface.c Fri Apr 03 13:27:33 2009 +0000 @@ -272,6 +272,23 @@ return 0; } +int +SDL_GetColorKey(SDL_Surface * surface, Uint32 * key) +{ + if (!surface) { + return -1; + } + + if (!(surface->map->info.flags & SDL_COPY_COLORKEY)) { + return -1; + } + + if (key) { + *key = surface->map->info.colorkey; + } + return 0; +} + /* This is a fairly slow function to switch from colorkey to alpha */ static void SDL_ConvertColorkeyToAlpha(SDL_Surface * surface)