test/testsprite2.c
changeset 3560 5543db4239e6
parent 3536 0267b8b1595c
child 3596 f638ded38b8a
equal deleted inserted replaced
3559:5f26a7eb5ff0 3560:5543db4239e6
    55     sprite_w = temp->w;
    55     sprite_w = temp->w;
    56     sprite_h = temp->h;
    56     sprite_h = temp->h;
    57 
    57 
    58     /* Set transparent pixel as the pixel at (0,0) */
    58     /* Set transparent pixel as the pixel at (0,0) */
    59     if (temp->format->palette) {
    59     if (temp->format->palette) {
    60         SDL_SetColorKey(temp, SDL_SRCCOLORKEY, *(Uint8 *) temp->pixels);
    60         SDL_SetColorKey(temp, 1, *(Uint8 *) temp->pixels);
    61     } else {
    61     } else {
    62         switch (temp->format->BitsPerPixel) {
    62         switch (temp->format->BitsPerPixel) {
    63         case 15:
    63         case 15:
    64             SDL_SetColorKey(temp, SDL_SRCCOLORKEY,
    64             SDL_SetColorKey(temp, 1, (*(Uint16 *) temp->pixels) & 0x00007FFF);
    65                             (*(Uint16 *) temp->pixels) & 0x00007FFF);
       
    66             break;
    65             break;
    67         case 16:
    66         case 16:
    68             SDL_SetColorKey(temp, SDL_SRCCOLORKEY, *(Uint16 *) temp->pixels);
    67             SDL_SetColorKey(temp, 1, *(Uint16 *) temp->pixels);
    69             break;
    68             break;
    70         case 24:
    69         case 24:
    71             SDL_SetColorKey(temp, SDL_SRCCOLORKEY,
    70             SDL_SetColorKey(temp, 1, (*(Uint32 *) temp->pixels) & 0x00FFFFFF);
    72                             (*(Uint32 *) temp->pixels) & 0x00FFFFFF);
       
    73             break;
    71             break;
    74         case 32:
    72         case 32:
    75             SDL_SetColorKey(temp, SDL_SRCCOLORKEY, *(Uint32 *) temp->pixels);
    73             SDL_SetColorKey(temp, 1, *(Uint32 *) temp->pixels);
    76             break;
    74             break;
    77         }
    75         }
    78     }
    76     }
    79 
    77 
    80     /* Create textures from the image */
    78     /* Create textures from the image */