comparison src/video/SDL_pixels.c @ 48:f97decee03a9

Mattias' patch
author Sam Lantinga <slouken@lokigames.com>
date Thu, 07 Jun 2001 14:53:18 +0000
parents 74212992fb08
children eda2f15ffb70
comparison
equal deleted inserted replaced
47:45b1c4303f87 48:f97decee03a9
462 static Uint8 *Map1toN(SDL_Palette *src, SDL_PixelFormat *dst) 462 static Uint8 *Map1toN(SDL_Palette *src, SDL_PixelFormat *dst)
463 { 463 {
464 Uint8 *map; 464 Uint8 *map;
465 int i; 465 int i;
466 int bpp; 466 int bpp;
467 unsigned alpha;
468 467
469 bpp = ((dst->BytesPerPixel == 3) ? 4 : dst->BytesPerPixel); 468 bpp = ((dst->BytesPerPixel == 3) ? 4 : dst->BytesPerPixel);
470 map = (Uint8 *)malloc(src->ncolors*bpp); 469 map = (Uint8 *)malloc(src->ncolors*bpp);
471 if ( map == NULL ) { 470 if ( map == NULL ) {
472 SDL_OutOfMemory(); 471 SDL_OutOfMemory();
473 return(NULL); 472 return(NULL);
474 } 473 }
475 474
476 alpha = dst->Amask ? SDL_ALPHA_OPAQUE : 0;
477 /* We memory copy to the pixel map so the endianness is preserved */ 475 /* We memory copy to the pixel map so the endianness is preserved */
478 for ( i=0; i<src->ncolors; ++i ) { 476 for ( i=0; i<src->ncolors; ++i ) {
479 ASSEMBLE_RGBA(&map[i*bpp], dst->BytesPerPixel, dst, 477 ASSEMBLE_RGBA(&map[i*bpp], dst->BytesPerPixel, dst,
480 src->colors[i].r, src->colors[i].g, 478 src->colors[i].r, src->colors[i].g,
481 src->colors[i].b, alpha); 479 src->colors[i].b, SDL_ALPHA_OPAQUE);
482 } 480 }
483 return(map); 481 return(map);
484 } 482 }
485 /* Map from BitField to Dithered-Palette to Palette */ 483 /* Map from BitField to Dithered-Palette to Palette */
486 static Uint8 *MapNto1(SDL_PixelFormat *src, SDL_Palette *dst, int *identical) 484 static Uint8 *MapNto1(SDL_PixelFormat *src, SDL_Palette *dst, int *identical)