From e5476c653dd820b935e809b3fe4397c28e650e78 Mon Sep 17 00:00:00 2001 From: Sylvain Becker Date: Sat, 15 Dec 2018 14:50:12 +0100 Subject: [PATCH] Fixed bug 4425 - promote to alpha format, palette surface with alpha values. SDL_CreateTextureFromSurface() forgets to choose a texture format with alpha for surfaces that have palettes with alpha values. --- src/render/SDL_render.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/render/SDL_render.c b/src/render/SDL_render.c index 1344453f3..adbfe1491 100644 --- a/src/render/SDL_render.c +++ b/src/render/SDL_render.c @@ -1205,6 +1205,18 @@ SDL_CreateTextureFromSurface(SDL_Renderer * renderer, SDL_Surface * surface) } else { needAlpha = SDL_FALSE; } + + /* If Palette contains alpha values, promotes to alpha format */ + if (fmt->palette) { + for (i = 0; i < fmt->palette->ncolors; i++) { + Uint8 alpha_value = fmt->palette->colors[i].a; + if (alpha_value != 0 || alpha_value != SDL_ALPHA_OPAQUE) { + needAlpha = SDL_TRUE; + break; + } + } + } + format = renderer->info.texture_formats[0]; for (i = 0; i < renderer->info.num_texture_formats; ++i) { if (!SDL_ISPIXELFORMAT_FOURCC(renderer->info.texture_formats[i]) &&