mirror of
https://git.do.srb2.org/STJr/SRB2.git
synced 2025-01-31 21:50:48 +00:00
Compare the PNG's palette with the game's palette instead of assuming they are the same
This commit is contained in:
parent
15008f31a7
commit
4d847f4223
1 changed files with 17 additions and 1 deletions
|
@ -887,8 +887,24 @@ static png_bytep *PNG_Read(
|
||||||
// matches the color count of SRB2's palette: 256 colors.
|
// matches the color count of SRB2's palette: 256 colors.
|
||||||
if (png_get_PLTE(png_ptr, png_info_ptr, &palette, &palette_size))
|
if (png_get_PLTE(png_ptr, png_info_ptr, &palette, &palette_size))
|
||||||
{
|
{
|
||||||
if (palette_size == 256)
|
if (palette_size == 256 && pMasterPalette)
|
||||||
|
{
|
||||||
|
png_colorp pal = palette;
|
||||||
|
INT32 i;
|
||||||
|
|
||||||
usepal = true;
|
usepal = true;
|
||||||
|
|
||||||
|
for (i = 0; i < 256; i++)
|
||||||
|
{
|
||||||
|
UINT32 rgb = R_PutRgbaRGBA(pal->red, pal->green, pal->blue, 0xFF);
|
||||||
|
if (rgb != pMasterPalette[i].rgba)
|
||||||
|
{
|
||||||
|
usepal = false;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
pal++;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// If any of the tRNS colors have an alpha lower than 0xFF, and that
|
// If any of the tRNS colors have an alpha lower than 0xFF, and that
|
||||||
|
|
Loading…
Reference in a new issue