Fixed images with no alpha channel rendering incorrectly
See https://forums.wesnoth.org/viewtopic.php?p=625159#p625159
Since this problem can also be solved with make_neutral_surface, and is_neutral already
check a surface's alpha mask, I moved the is-not-indexed check to is_neutral and made use
of it for the on-load standardization check.
(cherry-picked from commit 6babb773d2
)
This commit is contained in:
parent
202e3141d3
commit
0a409c391f
3 changed files with 11 additions and 10 deletions
|
@ -58,6 +58,7 @@
|
|||
associated options as Wesnoth now uses SDL_image to write PNG files.
|
||||
* Fixed regression where unit filters in [disable] weapon specials would not
|
||||
match the attacking unit.
|
||||
* Fixed images with no alpha channel rendering incorrectly.
|
||||
|
||||
## Version 1.13.12
|
||||
### Security fixes
|
||||
|
|
|
@ -546,13 +546,11 @@ static std::string get_localized_path(const std::string& file, const std::string
|
|||
}
|
||||
|
||||
// Ensure PNG images with an indexed palette are converted to 32-bit RGBA.
|
||||
// The format used is really ARGB8888, but same difference.
|
||||
// TODO: should this be moved to sdl/utils.*pp?
|
||||
static void discard_indexed_palette(surface& surf)
|
||||
static void standardize_surface_format(surface& surf)
|
||||
{
|
||||
if(!surf.null() && SDL_ISPIXELFORMAT_INDEXED(surf->format->format) == SDL_TRUE) {
|
||||
if(!surf.null() && !is_neutral(surf)) {
|
||||
surf = make_neutral_surface(surf);
|
||||
assert(SDL_ISPIXELFORMAT_INDEXED(surf->format->format) == SDL_FALSE);
|
||||
assert(is_neutral(surf));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -565,7 +563,7 @@ static void add_localized_overlay(const std::string& ovr_file, surface& orig_sur
|
|||
return;
|
||||
}
|
||||
|
||||
discard_indexed_palette(ovr_surf);
|
||||
standardize_surface_format(ovr_surf);
|
||||
|
||||
SDL_Rect area {0, 0, ovr_surf->w, ovr_surf->h};
|
||||
|
||||
|
@ -589,7 +587,7 @@ static surface load_image_file(const image::locator& loc)
|
|||
filesystem::rwops_ptr rwops = filesystem::make_read_RWops(location);
|
||||
res = IMG_Load_RW(rwops.release(), true); // SDL takes ownership of rwops
|
||||
|
||||
discard_indexed_palette(res);
|
||||
standardize_surface_format(res);
|
||||
|
||||
// If there was no standalone localized image, check if there is an overlay.
|
||||
if(!res.null() && loc_location.empty()) {
|
||||
|
|
|
@ -39,9 +39,11 @@ version_info sdl_get_version()
|
|||
|
||||
bool is_neutral(const surface& surf)
|
||||
{
|
||||
return (surf->format->BytesPerPixel == 4 &&
|
||||
surf->format->Rmask == SDL_RED_MASK &&
|
||||
(surf->format->Amask | SDL_ALPHA_MASK) == SDL_ALPHA_MASK);
|
||||
return
|
||||
SDL_ISPIXELFORMAT_INDEXED(surf->format->format) == SDL_FALSE &&
|
||||
surf->format->BytesPerPixel == 4 &&
|
||||
surf->format->Rmask == SDL_RED_MASK &&
|
||||
(surf->format->Amask | SDL_ALPHA_MASK) == SDL_ALPHA_MASK;
|
||||
}
|
||||
|
||||
static SDL_PixelFormat& get_neutral_pixel_format()
|
||||
|
|
Loading…
Add table
Reference in a new issue