]> git.saurik.com Git - wxWidgets.git/blobdiff - src/common/image.cpp
more avoiding direct struct access
[wxWidgets.git] / src / common / image.cpp
index a055858d4d21fcc0796aaed7e7195fbd9f9cb2d4..1d82b39ca581000c1c07db1a04afbb731b1767de 100644 (file)
@@ -442,23 +442,16 @@ wxImage::Scale( int width, int height, wxImageResizeQuality quality ) const
     if ( old_width == width && old_height == height )
         return *this;
 
-    // resample the image using either the nearest neighbourhood, bilinear or
-    // bicubic method as specified
-    switch ( quality )
+    if (quality == wxIMAGE_QUALITY_HIGH)
     {
-        case wxIMAGE_QUALITY_BICUBIC:
-        case wxIMAGE_QUALITY_BILINEAR:
-            // both of these algorithms should be used for up-sampling the
-            // image only, when down-sampling always use box averaging for best
-            // results
-            if ( width < old_width && height < old_height )
-                image = ResampleBox(width, height);
-            else if ( quality == wxIMAGE_QUALITY_BILINEAR )
-                image = ResampleBilinear(width, height);
-            else if ( quality == wxIMAGE_QUALITY_BICUBIC )
-                image = ResampleBicubic(width, height);
-            break;
+        quality = (width < old_width && height < old_height)
+            ? wxIMAGE_QUALITY_BOX_AVERAGE
+            : wxIMAGE_QUALITY_BICUBIC;
+    }
 
+    // Resample the image using the method as specified.
+    switch ( quality )
+    {
         case wxIMAGE_QUALITY_NEAREST:
             if ( old_width % width == 0 && old_width >= width &&
                 old_height % height == 0 && old_height >= height )
@@ -468,6 +461,18 @@ wxImage::Scale( int width, int height, wxImageResizeQuality quality ) const
 
             image = ResampleNearest(width, height);
             break;
+
+        case wxIMAGE_QUALITY_BILINEAR:
+            image = ResampleBilinear(width, height);
+            break;
+
+        case wxIMAGE_QUALITY_BICUBIC:
+            image = ResampleBicubic(width, height);
+            break;
+
+        case wxIMAGE_QUALITY_BOX_AVERAGE:
+            image = ResampleBox(width, height);
+            break;
     }
 
     // If the original image has a mask, apply the mask to the new image