When explicitly requesting saving as a palettised image but then later on that turns out to not be possible (or desired) the image would be marked as PNG_COLOR_TYPE_GRAY or PNG_COLOR_TYPE_GRAY_ALPHA. Simply set the colour type to RGB if this occurs also updated the unit test to catch this case.
This is similar to the fix in r66590 but that one was related to wxUSE_PALETTE == 0 cases.
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@66617
c3d73ce0-8a6f-49c7-b76d-
6d57e0e08775
}
#else
bool bUsePalette = false;
}
#else
bool bUsePalette = false;
- if (iColorType == wxPNG_TYPE_PALETTE)
+ /*
+ If saving palettised was requested but it was decided we can't use a
+ palette then reset the colour type to RGB.
+ */
+ if (!bUsePalette && iColorType == wxPNG_TYPE_PALETTE)
{
iColorType = wxPNG_TYPE_COLOUR;
}
{
iColorType = wxPNG_TYPE_COLOUR;
}
bool bUseAlpha = !bUsePalette && (bHasAlpha || bHasMask);
bool bUseAlpha = !bUsePalette && (bHasAlpha || bHasMask);
+ /*
+ Explicitly make known we want a palettised PNG. If we don't then this
+ particular image gets saved as a true colour image because there's an
+ alpha channel present and the PNG saver prefers to keep the alpha over
+ saving as a palettised image that has alpha converted to a mask.
+ */
+ expected8.SetOption(wxIMAGE_OPTION_PNG_FORMAT, wxPNG_TYPE_PALETTE);
+
/*
The image contains 256 indexed colours and needs another palette entry
for storing the transparency index. This results in wanting 257 palette
/*
The image contains 256 indexed colours and needs another palette entry
for storing the transparency index. This results in wanting 257 palette
red[paletteCount-2], green[paletteCount-2], blue[paletteCount-2]);
expected8.SetPalette(newPal);
red[paletteCount-2], green[paletteCount-2], blue[paletteCount-2]);
expected8.SetPalette(newPal);
- /*
- Explicitly make known we want a palettised PNG. If we don't then this
- particular image gets saved as a true colour image because there's an
- alpha channel present and the PNG saver prefers to keep the alpha over
- saving as a palettised image that has alpha converted to a mask.
- */
- expected8.SetOption(wxIMAGE_OPTION_PNG_FORMAT, wxPNG_TYPE_PALETTE);
wxImage ref8 = expected8;
wxImage ref8 = expected8;