r2 = *p++;
g2 = *p++;
b2 = *p++;
+ ++p; // jump over alpha
wxImageHistogramEntry&
entry = h[wxImageHistogram:: MakeKey(r2, g2, b2)];
if ( IsTransparent(a) )
{
*ptrDst++ = rMask;
- *ptrDst++ = bMask;
*ptrDst++ = gMask;
+ *ptrDst++ = bMask;
break;
}
// else: !transparent
if ( IsTransparent(a) )
{
*ptrDst++ = rMask;
- *ptrDst++ = bMask;
*ptrDst++ = gMask;
+ *ptrDst++ = bMask;
break;
}
else // !transparent
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 );
+
png_set_sBIT( png_ptr, info_ptr, &sig_bit );
png_write_info( png_ptr, info_ptr );
png_set_shift( png_ptr, &sig_bit );