Mercurial > sdl-ios-xcode
comparison include/SDL_pixels.h @ 1683:396a35389351 SDL-1.3
Finished palettized display handling.
Added support for surface palette sharing.
author | Sam Lantinga <slouken@libsdl.org> |
---|---|
date | Sat, 17 Jun 2006 06:45:14 +0000 |
parents | 7ae8018b2e5d |
children | c4aa1a2f48f1 |
comparison
equal
deleted
inserted
replaced
1682:7ae8018b2e5d | 1683:396a35389351 |
---|---|
193 Uint8 b; | 193 Uint8 b; |
194 Uint8 unused; | 194 Uint8 unused; |
195 } SDL_Color; | 195 } SDL_Color; |
196 #define SDL_Colour SDL_Color | 196 #define SDL_Colour SDL_Color |
197 | 197 |
198 typedef struct SDL_Palette | 198 typedef struct SDL_Palette SDL_Palette; |
199 typedef int (*SDL_PaletteChangedFunc) (void *userdata, SDL_Palette * palette); | |
200 | |
201 typedef struct SDL_PaletteWatch | |
202 { | |
203 SDL_PaletteChangedFunc callback; | |
204 void *userdata; | |
205 struct SDL_PaletteWatch *next; | |
206 } SDL_PaletteWatch; | |
207 | |
208 struct SDL_Palette | |
199 { | 209 { |
200 int ncolors; | 210 int ncolors; |
201 SDL_Color *colors; | 211 SDL_Color *colors; |
202 } SDL_Palette; | 212 |
213 int refcount; | |
214 SDL_PaletteWatch *watch; | |
215 }; | |
203 | 216 |
204 /* Everything in the pixel format structure is read-only */ | 217 /* Everything in the pixel format structure is read-only */ |
205 typedef struct SDL_PixelFormat | 218 typedef struct SDL_PixelFormat |
206 { | 219 { |
207 SDL_Palette *palette; | 220 SDL_Palette *palette; |
224 Uint32 colorkey; | 237 Uint32 colorkey; |
225 /* Alpha value information (per-surface alpha) */ | 238 /* Alpha value information (per-surface alpha) */ |
226 Uint8 alpha; | 239 Uint8 alpha; |
227 } SDL_PixelFormat; | 240 } SDL_PixelFormat; |
228 | 241 |
229 /* | 242 /** |
230 * Convert one of the enumerated formats above to a bpp and RGBA masks. | 243 * \fn SDL_bool SDL_PixelFormatEnumToMasks(Uint32 format, int *bpp, Uint32 * Rmask, Uint32 * Gmask, Uint32 * Bmask, Uint32 * Amask) |
231 * Returns SDL_TRUE, or SDL_FALSE if the conversion wasn't possible. | 244 * |
232 */ | 245 * \brief Convert one of the enumerated pixel formats to a bpp and RGBA masks. |
233 extern DECLSPEC SDL_bool SDL_PixelFormatEnumToMasks(Uint32 format, int *bpp, | 246 * |
234 Uint32 * Rmask, | 247 * \return SDL_TRUE, or SDL_FALSE if the conversion wasn't possible. |
235 Uint32 * Gmask, | 248 * |
236 Uint32 * Bmask, | 249 * \sa SDL_MasksToPixelFormatEnum() |
237 Uint32 * Amask); | 250 */ |
238 | 251 extern DECLSPEC SDL_bool SDLCALL SDL_PixelFormatEnumToMasks(Uint32 format, |
239 /* | 252 int *bpp, |
240 * Convert a bpp and RGBA masks to one of the enumerated formats above. | 253 Uint32 * Rmask, |
241 * Returns SDL_PixelFormat_Unknown if the conversion wasn't possible. | 254 Uint32 * Gmask, |
242 */ | 255 Uint32 * Bmask, |
243 extern DECLSPEC Uint32 SDL_MasksToPixelFormatEnum(int bpp, Uint32 Rmask, | 256 Uint32 * Amask); |
244 Uint32 Gmask, Uint32 Bmask, | 257 |
245 Uint32 Amask); | 258 /** |
259 * \fn Uint32 SDL_MasksToPixelFormatEnum(int bpp, Uint32 Rmask, Uint32 Gmask, Uint32 Bmask, Uint32 Amask) | |
260 * | |
261 * \brief Convert a bpp and RGBA masks to an enumerated pixel format. | |
262 * | |
263 * \return The pixel format, or SDL_PixelFormat_Unknown if the conversion wasn't possible. | |
264 * | |
265 * \sa SDL_PixelFormatEnumToMasks() | |
266 */ | |
267 extern DECLSPEC Uint32 SDLCALL SDL_MasksToPixelFormatEnum(int bpp, | |
268 Uint32 Rmask, | |
269 Uint32 Gmask, | |
270 Uint32 Bmask, | |
271 Uint32 Amask); | |
272 | |
273 /** | |
274 * \fn SDL_Palette *SDL_AllocPalette(int ncolors) | |
275 * | |
276 * \brief Create a palette structure with the specified number of color entries. | |
277 * | |
278 * \return A new palette, or NULL if there wasn't enough memory | |
279 * | |
280 * \note The palette entries are initialized to white. | |
281 * | |
282 * \sa SDL_FreePalette() | |
283 */ | |
284 extern DECLSPEC SDL_Palette *SDLCALL SDL_AllocPalette(int ncolors); | |
285 | |
286 /** | |
287 * \fn int SDL_AddPaletteWatch(SDL_Palette *palette, SDL_PaletteChangedFunc callback, void *userdata) | |
288 * | |
289 * \brief Add a callback function which is called when the palette changes. | |
290 * | |
291 * \sa SDL_DelPaletteWatch() | |
292 */ | |
293 extern DECLSPEC int SDLCALL SDL_AddPaletteWatch(SDL_Palette * palette, | |
294 SDL_PaletteChangedFunc | |
295 callback, void *userdata); | |
296 | |
297 /** | |
298 * \fn void SDL_DelPaletteWatch(SDL_Palette *palette, SDL_PaletteChangedFunc callback, void *userdata) | |
299 * | |
300 * \brief Remove a callback function previously added with SDL_AddPaletteWatch() | |
301 * | |
302 * \sa SDL_AddPaletteWatch() | |
303 */ | |
304 extern DECLSPEC void SDLCALL SDL_DelPaletteWatch(SDL_Palette * palette, | |
305 SDL_PaletteChangedFunc | |
306 callback, void *userdata); | |
307 | |
308 /** | |
309 * \fn int SDL_SetPaletteColors(SDL_Palette *palette, const SDL_Colors *colors, int firstcolor, int numcolors) | |
310 * | |
311 * \brief Set a range of colors in a palette. | |
312 * | |
313 * \param palette The palette to modify | |
314 * \param colors An array of colors to copy into the palette | |
315 * \param firstcolor The index of the first palette entry to modify | |
316 * \param ncolors The number of entries to modify | |
317 * | |
318 * \return 0 on success, or -1 if not all of the colors could be set | |
319 */ | |
320 extern DECLSPEC int SDLCALL SDL_SetPaletteColors(SDL_Palette * palette, | |
321 const SDL_Color * colors, | |
322 int firstcolor, int ncolors); | |
323 | |
324 /** | |
325 * \fn void SDL_FreePalette(SDL_Palette *palette) | |
326 * | |
327 * \brief Free a palette created with SDL_AllocPalette() | |
328 * | |
329 * \sa SDL_AllocPalette() | |
330 */ | |
331 extern DECLSPEC void SDLCALL SDL_FreePalette(SDL_Palette * palette); | |
246 | 332 |
247 /* Ends C function definitions when using C++ */ | 333 /* Ends C function definitions when using C++ */ |
248 #ifdef __cplusplus | 334 #ifdef __cplusplus |
249 /* *INDENT-OFF* */ | 335 /* *INDENT-OFF* */ |
250 } | 336 } |