include/SDL_pixels.h
branchSDL-1.3
changeset 1683 396a35389351
parent 1682 7ae8018b2e5d
child 1684 c4aa1a2f48f1
     1.1 --- a/include/SDL_pixels.h	Fri Jun 16 06:00:31 2006 +0000
     1.2 +++ b/include/SDL_pixels.h	Sat Jun 17 06:45:14 2006 +0000
     1.3 @@ -195,11 +195,24 @@
     1.4  } SDL_Color;
     1.5  #define SDL_Colour SDL_Color
     1.6  
     1.7 -typedef struct SDL_Palette
     1.8 +typedef struct SDL_Palette SDL_Palette;
     1.9 +typedef int (*SDL_PaletteChangedFunc) (void *userdata, SDL_Palette * palette);
    1.10 +
    1.11 +typedef struct SDL_PaletteWatch
    1.12 +{
    1.13 +    SDL_PaletteChangedFunc callback;
    1.14 +    void *userdata;
    1.15 +    struct SDL_PaletteWatch *next;
    1.16 +} SDL_PaletteWatch;
    1.17 +
    1.18 +struct SDL_Palette
    1.19  {
    1.20      int ncolors;
    1.21      SDL_Color *colors;
    1.22 -} SDL_Palette;
    1.23 +
    1.24 +    int refcount;
    1.25 +    SDL_PaletteWatch *watch;
    1.26 +};
    1.27  
    1.28  /* Everything in the pixel format structure is read-only */
    1.29  typedef struct SDL_PixelFormat
    1.30 @@ -226,23 +239,96 @@
    1.31      Uint8 alpha;
    1.32  } SDL_PixelFormat;
    1.33  
    1.34 -/*
    1.35 - * Convert one of the enumerated formats above to a bpp and RGBA masks.
    1.36 - * Returns SDL_TRUE, or SDL_FALSE if the conversion wasn't possible.
    1.37 +/**
    1.38 + * \fn SDL_bool SDL_PixelFormatEnumToMasks(Uint32 format, int *bpp, Uint32 * Rmask, Uint32 * Gmask, Uint32 * Bmask, Uint32 * Amask)
    1.39 + *
    1.40 + * \brief Convert one of the enumerated pixel formats to a bpp and RGBA masks.
    1.41 + *
    1.42 + * \return SDL_TRUE, or SDL_FALSE if the conversion wasn't possible.
    1.43 + *
    1.44 + * \sa SDL_MasksToPixelFormatEnum()
    1.45   */
    1.46 -extern DECLSPEC SDL_bool SDL_PixelFormatEnumToMasks(Uint32 format, int *bpp,
    1.47 -                                                    Uint32 * Rmask,
    1.48 -                                                    Uint32 * Gmask,
    1.49 -                                                    Uint32 * Bmask,
    1.50 -                                                    Uint32 * Amask);
    1.51 +extern DECLSPEC SDL_bool SDLCALL SDL_PixelFormatEnumToMasks(Uint32 format,
    1.52 +                                                            int *bpp,
    1.53 +                                                            Uint32 * Rmask,
    1.54 +                                                            Uint32 * Gmask,
    1.55 +                                                            Uint32 * Bmask,
    1.56 +                                                            Uint32 * Amask);
    1.57  
    1.58 -/*
    1.59 - * Convert a bpp and RGBA masks to one of the enumerated formats above.
    1.60 - * Returns SDL_PixelFormat_Unknown if the conversion wasn't possible.
    1.61 +/**
    1.62 + * \fn Uint32 SDL_MasksToPixelFormatEnum(int bpp, Uint32 Rmask, Uint32 Gmask, Uint32 Bmask, Uint32 Amask)
    1.63 + *
    1.64 + * \brief Convert a bpp and RGBA masks to an enumerated pixel format.
    1.65 + *
    1.66 + * \return The pixel format, or SDL_PixelFormat_Unknown if the conversion wasn't possible.
    1.67 + *
    1.68 + * \sa SDL_PixelFormatEnumToMasks()
    1.69   */
    1.70 -extern DECLSPEC Uint32 SDL_MasksToPixelFormatEnum(int bpp, Uint32 Rmask,
    1.71 -                                                  Uint32 Gmask, Uint32 Bmask,
    1.72 -                                                  Uint32 Amask);
    1.73 +extern DECLSPEC Uint32 SDLCALL SDL_MasksToPixelFormatEnum(int bpp,
    1.74 +                                                          Uint32 Rmask,
    1.75 +                                                          Uint32 Gmask,
    1.76 +                                                          Uint32 Bmask,
    1.77 +                                                          Uint32 Amask);
    1.78 +
    1.79 +/**
    1.80 + * \fn SDL_Palette *SDL_AllocPalette(int ncolors)
    1.81 + *
    1.82 + * \brief Create a palette structure with the specified number of color entries.
    1.83 + *
    1.84 + * \return A new palette, or NULL if there wasn't enough memory
    1.85 + *
    1.86 + * \note The palette entries are initialized to white.
    1.87 + *
    1.88 + * \sa SDL_FreePalette()
    1.89 + */
    1.90 +extern DECLSPEC SDL_Palette *SDLCALL SDL_AllocPalette(int ncolors);
    1.91 +
    1.92 +/**
    1.93 + * \fn int SDL_AddPaletteWatch(SDL_Palette *palette, SDL_PaletteChangedFunc callback, void *userdata)
    1.94 + *
    1.95 + * \brief Add a callback function which is called when the palette changes.
    1.96 + *
    1.97 + * \sa SDL_DelPaletteWatch()
    1.98 + */
    1.99 +extern DECLSPEC int SDLCALL SDL_AddPaletteWatch(SDL_Palette * palette,
   1.100 +                                                SDL_PaletteChangedFunc
   1.101 +                                                callback, void *userdata);
   1.102 +
   1.103 +/**
   1.104 + * \fn void SDL_DelPaletteWatch(SDL_Palette *palette, SDL_PaletteChangedFunc callback, void *userdata)
   1.105 + *
   1.106 + * \brief Remove a callback function previously added with SDL_AddPaletteWatch()
   1.107 + *
   1.108 + * \sa SDL_AddPaletteWatch()
   1.109 + */
   1.110 +extern DECLSPEC void SDLCALL SDL_DelPaletteWatch(SDL_Palette * palette,
   1.111 +                                                 SDL_PaletteChangedFunc
   1.112 +                                                 callback, void *userdata);
   1.113 +
   1.114 +/**
   1.115 + * \fn int SDL_SetPaletteColors(SDL_Palette *palette, const SDL_Colors *colors, int firstcolor, int numcolors)
   1.116 + *
   1.117 + * \brief Set a range of colors in a palette.
   1.118 + *
   1.119 + * \param palette The palette to modify
   1.120 + * \param colors An array of colors to copy into the palette
   1.121 + * \param firstcolor The index of the first palette entry to modify
   1.122 + * \param ncolors The number of entries to modify
   1.123 + *
   1.124 + * \return 0 on success, or -1 if not all of the colors could be set
   1.125 + */
   1.126 +extern DECLSPEC int SDLCALL SDL_SetPaletteColors(SDL_Palette * palette,
   1.127 +                                                 const SDL_Color * colors,
   1.128 +                                                 int firstcolor, int ncolors);
   1.129 +
   1.130 +/**
   1.131 + * \fn void SDL_FreePalette(SDL_Palette *palette)
   1.132 + *
   1.133 + * \brief Free a palette created with SDL_AllocPalette()
   1.134 + *
   1.135 + * \sa SDL_AllocPalette()
   1.136 + */
   1.137 +extern DECLSPEC void SDLCALL SDL_FreePalette(SDL_Palette * palette);
   1.138  
   1.139  /* Ends C function definitions when using C++ */
   1.140  #ifdef __cplusplus