Added SDL_GetColorKey()
authorSam Lantinga <slouken@libsdl.org>
Fri, 03 Apr 2009 13:27:33 +0000
changeset 31037be21a78777e
parent 3102 73fe1f73a56f
child 3104 86ea6c073d87
Added SDL_GetColorKey()
include/SDL_surface.h
src/video/SDL_surface.c
     1.1 --- a/include/SDL_surface.h	Sat Mar 28 06:00:42 2009 +0000
     1.2 +++ b/include/SDL_surface.h	Fri Apr 03 13:27:33 2009 +0000
     1.3 @@ -199,6 +199,19 @@
     1.4  extern DECLSPEC int SDLCALL SDL_SetColorKey(SDL_Surface * surface,
     1.5                                              Uint32 flag, Uint32 key);
     1.6  
     1.7 +/*
     1.8 + * \fn int SDL_GetColorKey(SDL_Surface *surface, Uint32 *key)
     1.9 + *
    1.10 + * \brief Sets the color key (transparent pixel) in a blittable surface.
    1.11 + *
    1.12 + * \param surface The surface to update
    1.13 + * \param key A pointer filled in with the transparent pixel in the native surface format
    1.14 + *
    1.15 + * \return 0 on success, or -1 if the surface is not valid or colorkey is not enabled.
    1.16 + */
    1.17 +extern DECLSPEC int SDLCALL SDL_GetColorKey(SDL_Surface * surface,
    1.18 +                                            Uint32 * key);
    1.19 +
    1.20  /**
    1.21   * \fn int SDL_SetSurfaceColorMod(SDL_Surface *surface, Uint8 r, Uint8 g, Uint8 b)
    1.22   *
     2.1 --- a/src/video/SDL_surface.c	Sat Mar 28 06:00:42 2009 +0000
     2.2 +++ b/src/video/SDL_surface.c	Fri Apr 03 13:27:33 2009 +0000
     2.3 @@ -272,6 +272,23 @@
     2.4      return 0;
     2.5  }
     2.6  
     2.7 +int
     2.8 +SDL_GetColorKey(SDL_Surface * surface, Uint32 * key)
     2.9 +{
    2.10 +    if (!surface) {
    2.11 +        return -1;
    2.12 +    }
    2.13 +
    2.14 +    if (!(surface->map->info.flags & SDL_COPY_COLORKEY)) {
    2.15 +        return -1;
    2.16 +    }
    2.17 +
    2.18 +    if (key) {
    2.19 +        *key = surface->map->info.colorkey;
    2.20 +    }
    2.21 +    return 0;
    2.22 +}
    2.23 +
    2.24  /* This is a fairly slow function to switch from colorkey to alpha */
    2.25  static void
    2.26  SDL_ConvertColorkeyToAlpha(SDL_Surface * surface)