include/SDL_pixels.h
changeset 5288 d4381f3b0d1e
parent 5264 7ace5f8f432f
child 5434 fb5e9db92a77
equal deleted inserted replaced
5287:d1823573d005 5288:d4381f3b0d1e
   251     Uint8 b;
   251     Uint8 b;
   252     Uint8 unused;
   252     Uint8 unused;
   253 } SDL_Color;
   253 } SDL_Color;
   254 #define SDL_Colour SDL_Color
   254 #define SDL_Colour SDL_Color
   255 
   255 
   256 typedef struct SDL_Palette SDL_Palette;
   256 typedef struct SDL_Palette
   257 typedef int (*SDL_PaletteChangedFunc) (void *userdata, SDL_Palette * palette);
       
   258 typedef struct SDL_PaletteWatch SDL_PaletteWatch;
       
   259 
       
   260 struct SDL_Palette
       
   261 {
   257 {
   262     int ncolors;
   258     int ncolors;
   263     SDL_Color *colors;
   259     SDL_Color *colors;
   264 
   260     Uint32 version;
   265     int refcount;
   261     int refcount;
   266     SDL_PaletteWatch *watch;
   262 } SDL_Palette;
   267 };
       
   268 
   263 
   269 /**
   264 /**
   270  *  \note Everything in the pixel format structure is read-only.
   265  *  \note Everything in the pixel format structure is read-only.
   271  */
   266  */
   272 typedef struct SDL_PixelFormat
   267 typedef struct SDL_PixelFormat
   273 {
   268 {
       
   269     Uint32 format;
   274     SDL_Palette *palette;
   270     SDL_Palette *palette;
   275     Uint8 BitsPerPixel;
   271     Uint8 BitsPerPixel;
   276     Uint8 BytesPerPixel;
   272     Uint8 BytesPerPixel;
   277     Uint8 Rloss;
   273     Uint8 Rloss;
   278     Uint8 Gloss;
   274     Uint8 Gloss;
   284     Uint8 Ashift;
   280     Uint8 Ashift;
   285     Uint32 Rmask;
   281     Uint32 Rmask;
   286     Uint32 Gmask;
   282     Uint32 Gmask;
   287     Uint32 Bmask;
   283     Uint32 Bmask;
   288     Uint32 Amask;
   284     Uint32 Amask;
       
   285     int refcount;
       
   286     struct SDL_PixelFormat *next;
   289 } SDL_PixelFormat;
   287 } SDL_PixelFormat;
   290 
   288 
   291 /**
   289 /**
   292  * \brief Get the human readable name of a pixel format
   290  * \brief Get the human readable name of a pixel format
   293  */
   291  */
   320                                                           Uint32 Gmask,
   318                                                           Uint32 Gmask,
   321                                                           Uint32 Bmask,
   319                                                           Uint32 Bmask,
   322                                                           Uint32 Amask);
   320                                                           Uint32 Amask);
   323 
   321 
   324 /**
   322 /**
       
   323  *  \brief Create an SDL_PixelFormat structure from a pixel format enum.
       
   324  */
       
   325 extern DECLSPEC SDL_PixelFormat * SDLCALL SDL_AllocFormat(Uint32 pixel_format);
       
   326 
       
   327 /**
       
   328  *  \brief Free an SDL_PixelFormat structure.
       
   329  */
       
   330 extern DECLSPEC void SDLCALL SDL_FreeFormat(SDL_PixelFormat *format);
       
   331 
       
   332 /**
   325  *  \brief Create a palette structure with the specified number of color 
   333  *  \brief Create a palette structure with the specified number of color 
   326  *         entries.
   334  *         entries.
   327  *  
   335  *  
   328  *  \return A new palette, or NULL if there wasn't enough memory.
   336  *  \return A new palette, or NULL if there wasn't enough memory.
   329  *  
   337  *  
   332  *  \sa SDL_FreePalette()
   340  *  \sa SDL_FreePalette()
   333  */
   341  */
   334 extern DECLSPEC SDL_Palette *SDLCALL SDL_AllocPalette(int ncolors);
   342 extern DECLSPEC SDL_Palette *SDLCALL SDL_AllocPalette(int ncolors);
   335 
   343 
   336 /**
   344 /**
   337  *  \brief Add a callback function which is called when the palette changes.
   345  *  \brief Set the palette for a pixel format structure.
   338  *  
   346  */
   339  *  \sa SDL_DelPaletteWatch()
   347 extern DECLSPEC int SDLCALL SDL_SetPixelFormatPalette(SDL_PixelFormat * format,
   340  */
   348                                                       SDL_Palette *palette);
   341 extern DECLSPEC int SDLCALL SDL_AddPaletteWatch(SDL_Palette * palette,
       
   342                                                 SDL_PaletteChangedFunc
       
   343                                                 callback, void *userdata);
       
   344 
       
   345 /**
       
   346  *  \brief Remove a callback function previously added with 
       
   347  *         SDL_AddPaletteWatch().
       
   348  *  
       
   349  *  \sa SDL_AddPaletteWatch()
       
   350  */
       
   351 extern DECLSPEC void SDLCALL SDL_DelPaletteWatch(SDL_Palette * palette,
       
   352                                                  SDL_PaletteChangedFunc
       
   353                                                  callback, void *userdata);
       
   354 
   349 
   355 /**
   350 /**
   356  *  \brief Set a range of colors in a palette.
   351  *  \brief Set a range of colors in a palette.
   357  *  
   352  *  
   358  *  \param palette    The palette to modify.
   353  *  \param palette    The palette to modify.