- png_set_write_fn( png_ptr, &wxinfo, _PNG_stream_writer, NULL);
+ png_set_write_fn( png_ptr, &wxinfo, wx_PNG_stream_writer, NULL);
+
+ const int iColorType = image->HasOption(wxIMAGE_OPTION_PNG_FORMAT)
+ ? image->GetOptionInt(wxIMAGE_OPTION_PNG_FORMAT)
+ : wxPNG_TYPE_COLOUR;
+ const int iBitDepth = image->HasOption(wxIMAGE_OPTION_PNG_BITDEPTH)
+ ? image->GetOptionInt(wxIMAGE_OPTION_PNG_BITDEPTH)
+ : 8;
+
+ wxASSERT_MSG( iBitDepth == 8 || iBitDepth == 16,
+ _T("PNG bit depth must be 8 or 16") );
+
+ bool bHasAlpha = image->HasAlpha();
+ bool bHasMask = image->HasMask();
+ bool bUseAlpha = bHasAlpha || bHasMask;
+
+ int iPngColorType;
+ if ( iColorType==wxPNG_TYPE_COLOUR )
+ {
+ iPngColorType = bUseAlpha ? PNG_COLOR_TYPE_RGB_ALPHA
+ : PNG_COLOR_TYPE_RGB;
+ }
+ else
+ {
+ iPngColorType = bUseAlpha ? PNG_COLOR_TYPE_GRAY_ALPHA
+ : PNG_COLOR_TYPE_GRAY;
+ }