Fixed bug 5037 - Regression 2.0.12 Alpha value of 0 on palette may become opaque

(see also bug 3827)
This commit is contained in:
Sylvain Becker
2020-03-17 09:35:42 +01:00
parent 36d5845152
commit 838bbf1f7a
4 changed files with 60 additions and 19 deletions

View File

@@ -1165,12 +1165,10 @@ SDL_CreateTextureFromSurface(SDL_Renderer * renderer, SDL_Surface * surface)
/* 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;
}
SDL_bool is_opaque, has_alpha_channel;
SDL_DetectPalette(fmt->palette, &is_opaque, &has_alpha_channel);
if (!is_opaque) {
needAlpha = SDL_TRUE;
}
}