+
+ if ( iPngColorType & PNG_COLOR_MASK_COLOR )
+ {
+ sig_bit.red =
+ sig_bit.green =
+ sig_bit.blue = (png_byte)iBitDepth;
+ iElements = 3;
+ }
+ else // grey
+ {
+ sig_bit.gray = (png_byte)iBitDepth;
+ iElements = 1;
+ }
+
+ if ( iPngColorType & PNG_COLOR_MASK_ALPHA )
+ {
+ sig_bit.alpha = (png_byte)iBitDepth;
+ iElements++;
+ }
+
+ if ( iBitDepth == 16 )
+ iElements *= 2;
+
+ // save the image resolution if we have it
+ int resX, resY;
+ switch ( GetResolutionFromOptions(*image, &resX, &resY) )
+ {
+ case wxIMAGE_RESOLUTION_INCHES:
+ {
+ const double INCHES_IN_METER = 10000.0 / 254;
+ resX = int(resX * INCHES_IN_METER);
+ resY = int(resY * INCHES_IN_METER);
+ }
+ break;
+
+ case wxIMAGE_RESOLUTION_CM:
+ resX *= 100;
+ resY *= 100;
+ break;
+
+ case wxIMAGE_RESOLUTION_NONE:
+ break;
+
+ default:
+ wxFAIL_MSG( _T("unsupported image resolution units") );
+ }
+
+ if ( resX && resY )
+ png_set_pHYs( png_ptr, info_ptr, resX, resY, PNG_RESOLUTION_METER );
+