]> git.saurik.com Git - wxWidgets.git/blobdiff - tests/image/image.cpp
Make @genericAppearance Doxygen macro consistent with @appearance.
[wxWidgets.git] / tests / image / image.cpp
index f0f8ad2c4c6e8d846c2a6bf8e5e60dff31fdfd56..66023ff5443ea866c462240087045574883f7c7d 100644 (file)
@@ -3,7 +3,6 @@
 // Purpose:     Test wxImage
 // Author:      Francesco Montorsi
 // Created:     2009-05-31
-// RCS-ID:      $Id$
 // Copyright:   (c) 2009 Francesco Montorsi
 // Licence:     wxWindows licence
 ///////////////////////////////////////////////////////////////////////////////
@@ -79,6 +78,7 @@ private:
         CPPUNIT_TEST( GIFComment );
         CPPUNIT_TEST( DibPadding );
         CPPUNIT_TEST( BMPFlippingAndRLECompression );
+        CPPUNIT_TEST( ScaleCompare );
     CPPUNIT_TEST_SUITE_END();
 
     void LoadFromSocketStream();
@@ -94,6 +94,7 @@ private:
     void GIFComment();
     void DibPadding();
     void BMPFlippingAndRLECompression();
+    void ScaleCompare();
 
     DECLARE_NO_COPY_CLASS(ImageTestCase)
 };
@@ -1343,6 +1344,48 @@ void ImageTestCase::BMPFlippingAndRLECompression()
 
     CompareBMPImage("image/horse_rle4.bmp", "image/horse_rle4_flipped.bmp");
 }
+
+
+#define ASSERT_IMAGE_EQUAL_TO_FILE(image, file) \
+    { \
+        wxImage imageFromFile(file); \
+        CPPUNIT_ASSERT_MESSAGE( "Failed to load " file, imageFromFile.IsOk() ); \
+        CPPUNIT_ASSERT_EQUAL( imageFromFile, image ); \
+    }
+
+void ImageTestCase::ScaleCompare()
+{
+    wxImage original;
+    CPPUNIT_ASSERT(original.LoadFile("horse.bmp"));
+
+    ASSERT_IMAGE_EQUAL_TO_FILE(original.Scale( 50,  50, wxIMAGE_QUALITY_BICUBIC),
+                               "image/horse_bicubic_50x50.png");
+    ASSERT_IMAGE_EQUAL_TO_FILE(original.Scale(100, 100, wxIMAGE_QUALITY_BICUBIC),
+                               "image/horse_bicubic_100x100.png");
+    ASSERT_IMAGE_EQUAL_TO_FILE(original.Scale(150, 150, wxIMAGE_QUALITY_BICUBIC),
+                               "image/horse_bicubic_150x150.png");
+    ASSERT_IMAGE_EQUAL_TO_FILE(original.Scale(300, 300, wxIMAGE_QUALITY_BICUBIC),
+                               "image/horse_bicubic_300x300.png");
+
+    ASSERT_IMAGE_EQUAL_TO_FILE(original.Scale( 50,  50, wxIMAGE_QUALITY_BOX_AVERAGE),
+                               "image/horse_box_average_50x50.png");
+    ASSERT_IMAGE_EQUAL_TO_FILE(original.Scale(100, 100, wxIMAGE_QUALITY_BOX_AVERAGE),
+                               "image/horse_box_average_100x100.png");
+    ASSERT_IMAGE_EQUAL_TO_FILE(original.Scale(150, 150, wxIMAGE_QUALITY_BOX_AVERAGE),
+                               "image/horse_box_average_150x150.png");
+    ASSERT_IMAGE_EQUAL_TO_FILE(original.Scale(300, 300, wxIMAGE_QUALITY_BOX_AVERAGE),
+                               "image/horse_box_average_300x300.png");
+
+    ASSERT_IMAGE_EQUAL_TO_FILE(original.Scale( 50,  50, wxIMAGE_QUALITY_BILINEAR),
+                               "image/horse_bilinear_50x50.png");
+    ASSERT_IMAGE_EQUAL_TO_FILE(original.Scale(100, 100, wxIMAGE_QUALITY_BILINEAR),
+                               "image/horse_bilinear_100x100.png");
+    ASSERT_IMAGE_EQUAL_TO_FILE(original.Scale(150, 150, wxIMAGE_QUALITY_BILINEAR),
+                               "image/horse_bilinear_150x150.png");
+    ASSERT_IMAGE_EQUAL_TO_FILE(original.Scale(300, 300, wxIMAGE_QUALITY_BILINEAR),
+                               "image/horse_bilinear_300x300.png");
+}
+
 #endif //wxUSE_IMAGE