comparison src/video/SDL_pixels.c @ 2967:e4a469d6ddab

Implemented SDL_SetWindowIcon(), with translucent icon support under X11.
author Sam Lantinga <slouken@libsdl.org>
date Fri, 02 Jan 2009 17:39:48 +0000
parents 99210400e8b9
children 502adab079a4
comparison
equal deleted inserted replaced
2966:c1e3621ba959 2967:e4a469d6ddab
345 SDL_PixelFormat * 345 SDL_PixelFormat *
346 SDL_AllocFormat(int bpp, 346 SDL_AllocFormat(int bpp,
347 Uint32 Rmask, Uint32 Gmask, Uint32 Bmask, Uint32 Amask) 347 Uint32 Rmask, Uint32 Gmask, Uint32 Bmask, Uint32 Amask)
348 { 348 {
349 SDL_PixelFormat *format; 349 SDL_PixelFormat *format;
350 Uint32 mask;
351 350
352 /* Allocate an empty pixel format structure */ 351 /* Allocate an empty pixel format structure */
353 format = SDL_calloc(1, sizeof(*format)); 352 format = SDL_malloc(sizeof(*format));
354 if (format == NULL) { 353 if (format == NULL) {
355 SDL_OutOfMemory(); 354 SDL_OutOfMemory();
356 return (NULL); 355 return (NULL);
357 } 356 }
358 357
359 /* Set up the format */ 358 /* Set up the format */
359 return SDL_InitFormat(format, bpp, Rmask, Gmask, Bmask, Amask);
360 }
361
362 SDL_PixelFormat *
363 SDL_InitFormat(SDL_PixelFormat *format, int bpp, Uint32 Rmask, Uint32 Gmask, Uint32 Bmask, Uint32 Amask)
364 {
365 Uint32 mask;
366
367 /* Set up the format */
368 SDL_zerop(format);
360 format->BitsPerPixel = bpp; 369 format->BitsPerPixel = bpp;
361 format->BytesPerPixel = (bpp + 7) / 8; 370 format->BytesPerPixel = (bpp + 7) / 8;
362 if (Rmask || Bmask || Gmask) { /* Packed pixels with custom mask */ 371 if (Rmask || Bmask || Gmask) { /* Packed pixels with custom mask */
363 format->Rshift = 0; 372 format->Rshift = 0;
364 format->Rloss = 8; 373 format->Rloss = 8;
424 format->Bmask = 0; 433 format->Bmask = 0;
425 format->Amask = 0; 434 format->Amask = 0;
426 } 435 }
427 format->palette = NULL; 436 format->palette = NULL;
428 437
429 return (format); 438 return format;
430 } 439 }
431 440
432 /* 441 /*
433 * Change any previous mappings from/to the new surface format 442 * Change any previous mappings from/to the new surface format
434 */ 443 */