From 229b438d423e861fcf9d2e072ecf152d25b85429 Mon Sep 17 00:00:00 2001 From: Sam Lantinga Date: Sat, 29 Mar 2014 12:27:27 -0700 Subject: [PATCH] Fixed assertion loading button.bmp in testgamecontroller --- test/testgamecontroller.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/test/testgamecontroller.c b/test/testgamecontroller.c index f762ce622..f5ef6fb0b 100644 --- a/test/testgamecontroller.c +++ b/test/testgamecontroller.c @@ -85,9 +85,13 @@ LoadTexture(SDL_Renderer *renderer, char *file, SDL_bool transparent) } else { /* Set transparent pixel as the pixel at (0,0) */ if (transparent) { - SDL_assert(!temp->format->palette); - SDL_assert(temp->format->BitsPerPixel == 24); - SDL_SetColorKey(temp, SDL_TRUE, (*(Uint32 *) temp->pixels) & 0x00FFFFFF); + if (temp->format->BytesPerPixel == 1) { + SDL_SetColorKey(temp, SDL_TRUE, *(Uint8 *)temp->pixels); + } else { + SDL_assert(!temp->format->palette); + SDL_assert(temp->format->BitsPerPixel == 24); + SDL_SetColorKey(temp, SDL_TRUE, (*(Uint32 *)temp->pixels) & 0x00FFFFFF); + } } texture = SDL_CreateTextureFromSurface(renderer, temp);