X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/e26d5213eccaaf7806e0b0594b642b12a01209e2..55809d1394516044a90fa34b12070d0f3e9f1439:/src/common/image.cpp?ds=sidebyside diff --git a/src/common/image.cpp b/src/common/image.cpp index be43304ba9..d91c445e04 100644 --- a/src/common/image.cpp +++ b/src/common/image.cpp @@ -754,20 +754,17 @@ wxImage wxImage::BlurHorizontal(int blurRadius) unsigned char* dst_alpha = NULL; // Check for a mask or alpha - if ( M_IMGDATA->m_hasMask ) + if ( src_alpha ) + { + ret_image.SetAlpha(); + dst_alpha = ret_image.GetAlpha(); + } + else if ( M_IMGDATA->m_hasMask ) { ret_image.SetMaskColour(M_IMGDATA->m_maskRed, M_IMGDATA->m_maskGreen, M_IMGDATA->m_maskBlue); } - else - { - if ( src_alpha ) - { - ret_image.SetAlpha(); - dst_alpha = ret_image.GetAlpha(); - } - } // number of pixels we average over const int blurArea = blurRadius*2 + 1; @@ -872,20 +869,17 @@ wxImage wxImage::BlurVertical(int blurRadius) unsigned char* dst_alpha = NULL; // Check for a mask or alpha - if ( M_IMGDATA->m_hasMask ) + if ( src_alpha ) + { + ret_image.SetAlpha(); + dst_alpha = ret_image.GetAlpha(); + } + else if ( M_IMGDATA->m_hasMask ) { ret_image.SetMaskColour(M_IMGDATA->m_maskRed, M_IMGDATA->m_maskGreen, M_IMGDATA->m_maskBlue); } - else - { - if ( src_alpha ) - { - ret_image.SetAlpha(); - dst_alpha = ret_image.GetAlpha(); - } - } // number of pixels we average over const int blurArea = blurRadius*2 + 1; @@ -2651,6 +2645,42 @@ bool wxImageHandler::CallDoCanRead(wxInputStream& stream) #endif // wxUSE_STREAMS +/* static */ +wxImageResolution +wxImageHandler::GetResolutionFromOptions(const wxImage& image, int *x, int *y) +{ + wxCHECK_MSG( x && y, wxIMAGE_RESOLUTION_NONE, _T("NULL pointer") ); + + if ( image.HasOption(wxIMAGE_OPTION_RESOLUTIONX) && + image.HasOption(wxIMAGE_OPTION_RESOLUTIONY) ) + { + *x = image.GetOptionInt(wxIMAGE_OPTION_RESOLUTIONX); + *y = image.GetOptionInt(wxIMAGE_OPTION_RESOLUTIONY); + } + else if ( image.HasOption(wxIMAGE_OPTION_RESOLUTION) ) + { + *x = + *y = image.GetOptionInt(wxIMAGE_OPTION_RESOLUTION); + } + else // no resolution options specified + { + *x = + *y = 0; + + return wxIMAGE_RESOLUTION_NONE; + } + + // get the resolution unit too + int resUnit = image.GetOptionInt(wxIMAGE_OPTION_RESOLUTIONUNIT); + if ( !resUnit ) + { + // this is the default + resUnit = wxIMAGE_RESOLUTION_INCHES; + } + + return (wxImageResolution)resUnit; +} + // ---------------------------------------------------------------------------- // image histogram stuff // ---------------------------------------------------------------------------- @@ -3095,8 +3125,8 @@ class wxImageModule: public wxModule DECLARE_DYNAMIC_CLASS(wxImageModule) public: wxImageModule() {} - bool OnInit() { wxImage::InitStandardHandlers(); return true; }; - void OnExit() { wxImage::CleanUpHandlers(); }; + bool OnInit() { wxImage::InitStandardHandlers(); return true; } + void OnExit() { wxImage::CleanUpHandlers(); } }; IMPLEMENT_DYNAMIC_CLASS(wxImageModule, wxModule)