png_structp png_ptr = png_create_read_struct
(
PNG_LIBPNG_VER_STRING,
- (voidp) NULL,
+ NULL,
wx_png_error,
wx_png_warning
);
// SaveFile() helpers
// ----------------------------------------------------------------------------
-static int PaletteFind(const png_color& clr,
- const png_color *pal, int palCount)
+#if wxUSE_PALETTE
+
+static int PaletteFind(const png_color& clr, const png_color *pal, int palCount)
{
for (int i = 0; i < palCount; ++i)
{
return wxNOT_FOUND;
}
+#endif // wxUSE_PALETTE
+
// ----------------------------------------------------------------------------
// writing PNGs
// ----------------------------------------------------------------------------
bool bUsePalette = false;
#endif // wxUSE_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;
+ }
+
bool bUseAlpha = !bUsePalette && (bHasAlpha || bHasMask);
png_color mask;
*pData++ = 0;
break;
+#if wxUSE_PALETTE
case wxPNG_TYPE_PALETTE:
*pData++ = (unsigned char) PaletteFind(clr,
palette, numPalette);
break;
+#endif // wxUSE_PALETTE
}
if ( bUseAlpha )