X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/dcc36b34be1e1492894a5be7a027d99d3e74ebd9..29f86fc1827816c9ab21202bb773caff854c2c10:/src/common/imagpng.cpp diff --git a/src/common/imagpng.cpp b/src/common/imagpng.cpp index 009f133de9..0a5c3c4826 100644 --- a/src/common/imagpng.cpp +++ b/src/common/imagpng.cpp @@ -1,5 +1,5 @@ ///////////////////////////////////////////////////////////////////////////// -// Name: src/common/imagepng.cpp +// Name: src/common/imagpng.cpp // Purpose: wxImage PNG handler // Author: Robert Roebling // RCS-ID: $Id$ @@ -42,12 +42,6 @@ // For memcpy #include -#ifdef __SALFORDC__ -#ifdef FAR -#undef FAR -#endif -#endif - // ---------------------------------------------------------------------------- // constants // ---------------------------------------------------------------------------- @@ -748,6 +742,33 @@ bool wxPNGHandler::SaveFile( wxImage *image, wxOutputStream& stream, bool verbos 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 );