Skip to content

Commit

Permalink
Fixed bug 4425 - promote to alpha format, palette surface with alpha …
Browse files Browse the repository at this point in the history
…values.

SDL_CreateTextureFromSurface() forgets to choose a texture format with alpha for
surfaces that have palettes with alpha values.
  • Loading branch information
1bsyl committed Dec 15, 2018
1 parent bd08d72 commit e5476c6
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions src/render/SDL_render.c
Expand Up @@ -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]) &&
Expand Down

0 comments on commit e5476c6

Please sign in to comment.