From: Vadim Zeitlin Date: Sat, 24 Mar 2012 18:24:15 +0000 (+0000) Subject: Implement wxGraphicsContext::SetInterpolationQuality() for wxMSW. X-Git-Url: https://git.saurik.com/wxWidgets.git/commitdiff_plain/c3562311c8fd0a0a6f7682fa229ad9083b4c9091 Implement wxGraphicsContext::SetInterpolationQuality() for wxMSW. Provide implementation of the previously stubbed out method. Closes #14134. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@70990 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- diff --git a/docs/changes.txt b/docs/changes.txt index cebec5ae5b..9b39bfaa0e 100644 --- a/docs/changes.txt +++ b/docs/changes.txt @@ -514,6 +514,7 @@ MSW: wxWebViewIE to improve the default behaviour (Allonii). - Update stretchable spaces in wxToolBar after tool removal (Catalin Raceanu). - Add support for horizontal mouse wheel events (Lauri Nurmi). +- Implement wxGraphicsContext::SetInterpolationQuality() (Eric Jarvi). OSX: diff --git a/interface/wx/graphics.h b/interface/wx/graphics.h index 6431067da9..d2104f4425 100644 --- a/interface/wx/graphics.h +++ b/interface/wx/graphics.h @@ -787,15 +787,17 @@ public: virtual wxAntialiasMode GetAntialiasMode() const ; /** - Sets the interpolation quality, returns true if it supported + Sets the interpolation quality, returns true if it is supported. + + Not implemented in Cairo backend currently. */ virtual bool SetInterpolationQuality(wxInterpolationQuality interpolation) = 0; - + /** - Returns the current interpolation quality + Returns the current interpolation quality. */ virtual wxInterpolationQuality GetInterpolationQuality() const; - + /** Sets the compositing operator, returns true if it supported */ diff --git a/src/msw/graphics.cpp b/src/msw/graphics.cpp index e5161c5d5b..af177f3365 100644 --- a/src/msw/graphics.cpp +++ b/src/msw/graphics.cpp @@ -1390,6 +1390,7 @@ void wxGDIPlusContext::Init(Graphics* graphics, int width, int height) m_context->SetTextRenderingHint(TextRenderingHintSystemDefault); m_context->SetPixelOffsetMode(PixelOffsetModeHalf); m_context->SetSmoothingMode(SmoothingModeHighQuality); + m_context->SetInterpolationMode(InterpolationModeHighQuality); m_state1 = m_context->Save(); m_state2 = m_context->Save(); } @@ -1535,10 +1536,41 @@ bool wxGDIPlusContext::SetAntialiasMode(wxAntialiasMode antialias) return true; } -bool wxGDIPlusContext::SetInterpolationQuality(wxInterpolationQuality WXUNUSED(interpolation)) +bool wxGDIPlusContext::SetInterpolationQuality(wxInterpolationQuality interpolation) { - // placeholder - return false; + if (m_interpolation == interpolation) + return true; + + m_interpolation = interpolation; + + InterpolationMode interpolationMode = InterpolationModeDefault; + switch (interpolation) + { + case wxINTERPOLATION_DEFAULT: + interpolationMode = InterpolationModeDefault; + break; + + case wxINTERPOLATION_NONE: + interpolationMode = InterpolationModeNearestNeighbor; + break; + + case wxINTERPOLATION_FAST: + interpolationMode = InterpolationModeLowQuality; + break; + + case wxINTERPOLATION_GOOD: + interpolationMode = InterpolationModeHighQuality; + break; + + case wxINTERPOLATION_BEST: + interpolationMode = InterpolationModeHighQualityBicubic; + break; + + default: + return false; + } + m_context->SetInterpolationMode(interpolationMode); + return true; } bool wxGDIPlusContext::SetCompositionMode(wxCompositionMode op)