]> git.saurik.com Git - wxWidgets.git/commitdiff
Add a unit test for wxImage::Scale() method.
authorVadim Zeitlin <vadim@wxwidgets.org>
Mon, 1 Jul 2013 14:47:12 +0000 (14:47 +0000)
committerVadim Zeitlin <vadim@wxwidgets.org>
Mon, 1 Jul 2013 14:47:12 +0000 (14:47 +0000)
Check that resizing the test horse image produces the same results in the
future as it does now, by saving the current results in files and verifying
that images resized directly and loaded from these files are the same.

See #15281.

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@74318 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

18 files changed:
tests/image/horse_bicubic_100x100.png [new file with mode: 0644]
tests/image/horse_bicubic_150x150.png [new file with mode: 0644]
tests/image/horse_bicubic_300x300.png [new file with mode: 0644]
tests/image/horse_bicubic_50x50.png [new file with mode: 0644]
tests/image/horse_bilinear_100x100.png [new file with mode: 0644]
tests/image/horse_bilinear_150x150.png [new file with mode: 0644]
tests/image/horse_bilinear_300x300.png [new file with mode: 0644]
tests/image/horse_bilinear_50x50.png [new file with mode: 0644]
tests/image/horse_box_average_100x100.png [new file with mode: 0644]
tests/image/horse_box_average_150x150.png [new file with mode: 0644]
tests/image/horse_box_average_300x300.png [new file with mode: 0644]
tests/image/horse_box_average_50x50.png [new file with mode: 0644]
tests/image/image.cpp
tests/makefile.bcc
tests/makefile.gcc
tests/makefile.vc
tests/makefile.wat
tests/test.bkl

diff --git a/tests/image/horse_bicubic_100x100.png b/tests/image/horse_bicubic_100x100.png
new file mode 100644 (file)
index 0000000..1ac57b0
Binary files /dev/null and b/tests/image/horse_bicubic_100x100.png differ
diff --git a/tests/image/horse_bicubic_150x150.png b/tests/image/horse_bicubic_150x150.png
new file mode 100644 (file)
index 0000000..7e4c81d
Binary files /dev/null and b/tests/image/horse_bicubic_150x150.png differ
diff --git a/tests/image/horse_bicubic_300x300.png b/tests/image/horse_bicubic_300x300.png
new file mode 100644 (file)
index 0000000..1bcce1c
Binary files /dev/null and b/tests/image/horse_bicubic_300x300.png differ
diff --git a/tests/image/horse_bicubic_50x50.png b/tests/image/horse_bicubic_50x50.png
new file mode 100644 (file)
index 0000000..1ad94a2
Binary files /dev/null and b/tests/image/horse_bicubic_50x50.png differ
diff --git a/tests/image/horse_bilinear_100x100.png b/tests/image/horse_bilinear_100x100.png
new file mode 100644 (file)
index 0000000..390ed58
Binary files /dev/null and b/tests/image/horse_bilinear_100x100.png differ
diff --git a/tests/image/horse_bilinear_150x150.png b/tests/image/horse_bilinear_150x150.png
new file mode 100644 (file)
index 0000000..b17ca3a
Binary files /dev/null and b/tests/image/horse_bilinear_150x150.png differ
diff --git a/tests/image/horse_bilinear_300x300.png b/tests/image/horse_bilinear_300x300.png
new file mode 100644 (file)
index 0000000..d4c5d06
Binary files /dev/null and b/tests/image/horse_bilinear_300x300.png differ
diff --git a/tests/image/horse_bilinear_50x50.png b/tests/image/horse_bilinear_50x50.png
new file mode 100644 (file)
index 0000000..6e7a7ee
Binary files /dev/null and b/tests/image/horse_bilinear_50x50.png differ
diff --git a/tests/image/horse_box_average_100x100.png b/tests/image/horse_box_average_100x100.png
new file mode 100644 (file)
index 0000000..7e4b0a0
Binary files /dev/null and b/tests/image/horse_box_average_100x100.png differ
diff --git a/tests/image/horse_box_average_150x150.png b/tests/image/horse_box_average_150x150.png
new file mode 100644 (file)
index 0000000..bd42d0c
Binary files /dev/null and b/tests/image/horse_box_average_150x150.png differ
diff --git a/tests/image/horse_box_average_300x300.png b/tests/image/horse_box_average_300x300.png
new file mode 100644 (file)
index 0000000..bb4bb6b
Binary files /dev/null and b/tests/image/horse_box_average_300x300.png differ
diff --git a/tests/image/horse_box_average_50x50.png b/tests/image/horse_box_average_50x50.png
new file mode 100644 (file)
index 0000000..5d06ced
Binary files /dev/null and b/tests/image/horse_box_average_50x50.png differ
index f0f8ad2c4c6e8d846c2a6bf8e5e60dff31fdfd56..0201f271e51aca92a6c3a2fe48a667d8d19ff3cb 100644 (file)
@@ -79,6 +79,7 @@ private:
         CPPUNIT_TEST( GIFComment );
         CPPUNIT_TEST( DibPadding );
         CPPUNIT_TEST( BMPFlippingAndRLECompression );
+        CPPUNIT_TEST( ScaleCompare );
     CPPUNIT_TEST_SUITE_END();
 
     void LoadFromSocketStream();
@@ -94,6 +95,7 @@ private:
     void GIFComment();
     void DibPadding();
     void BMPFlippingAndRLECompression();
+    void ScaleCompare();
 
     DECLARE_NO_COPY_CLASS(ImageTestCase)
 };
@@ -1343,6 +1345,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
 
 
index 74b2218b56e53189ba161c38ad1cb41d1efd2a4e..331b2563cb7c4ca5792d5b8f6a95987888f10ffa 100644 (file)
@@ -486,7 +486,7 @@ data:
 \r
 data-images: \r
        if not exist image mkdir image\r
-       for %f in (horse_grey.bmp horse_grey_flipped.bmp horse_rle4.bmp horse_rle4_flipped.bmp horse_rle8.bmp horse_rle8_flipped.bmp) do if not exist image\%f copy .\image\%f image\r
+       for %f in (horse_grey.bmp horse_grey_flipped.bmp horse_rle4.bmp horse_rle4_flipped.bmp horse_rle8.bmp horse_rle8_flipped.bmp horse_bicubic_50x50.png horse_bicubic_100x100.png horse_bicubic_150x150.png horse_bicubic_300x300.png horse_bilinear_50x50.png horse_bilinear_100x100.png horse_bilinear_150x150.png horse_bilinear_300x300.png horse_box_average_50x50.png horse_box_average_100x100.png horse_box_average_150x150.png horse_box_average_300x300.png) do if not exist image\%f copy .\image\%f image
 \r
 fr: \r
        if not exist $(OBJS)\intl\fr mkdir $(OBJS)\intl\fr\r
index 252a63a5c0292b7a26d865459364e45d532aa83e..b64a38ad07b7a9240942286547793e003d9902c5 100644 (file)
@@ -475,7 +475,7 @@ data:
 \r
 data-images: \r
        if not exist image mkdir image\r
-       for %%f in (horse_grey.bmp horse_grey_flipped.bmp horse_rle4.bmp horse_rle4_flipped.bmp horse_rle8.bmp horse_rle8_flipped.bmp) do if not exist image\%%f copy .\image\%%f image\r
+       for %%f in (horse_grey.bmp horse_grey_flipped.bmp horse_rle4.bmp horse_rle4_flipped.bmp horse_rle8.bmp horse_rle8_flipped.bmp horse_bicubic_50x50.png horse_bicubic_100x100.png horse_bicubic_150x150.png horse_bicubic_300x300.png horse_bilinear_50x50.png horse_bilinear_100x100.png horse_bilinear_150x150.png horse_bilinear_300x300.png horse_box_average_50x50.png horse_box_average_100x100.png horse_box_average_150x150.png horse_box_average_300x300.png) do if not exist image\%%f copy .\image\%%f image
 \r
 fr: \r
        if not exist $(OBJS)\intl\fr mkdir $(OBJS)\intl\fr\r
index 5890b203a1813a95d9653cd5abe92f1e062f4857..4054a2f575df24efcd4eadbb37d0dc5655465431 100644 (file)
@@ -626,7 +626,7 @@ data:
 \r
 data-images: \r
        if not exist image mkdir image\r
-       for %f in (horse_grey.bmp horse_grey_flipped.bmp horse_rle4.bmp horse_rle4_flipped.bmp horse_rle8.bmp horse_rle8_flipped.bmp) do if not exist image\%f copy .\image\%f image\r
+       for %f in (horse_grey.bmp horse_grey_flipped.bmp horse_rle4.bmp horse_rle4_flipped.bmp horse_rle8.bmp horse_rle8_flipped.bmp horse_bicubic_50x50.png horse_bicubic_100x100.png horse_bicubic_150x150.png horse_bicubic_300x300.png horse_bilinear_50x50.png horse_bilinear_100x100.png horse_bilinear_150x150.png horse_bilinear_300x300.png horse_box_average_50x50.png horse_box_average_100x100.png horse_box_average_150x150.png horse_box_average_300x300.png) do if not exist image\%f copy .\image\%f image
 \r
 fr: \r
        if not exist $(OBJS)\intl\fr mkdir $(OBJS)\intl\fr\r
index 8c4d53fdb55f65fdcb847dc47868f7718e2b4912..88a3f23823189208a3f4d227cbce71afb7441829 100644 (file)
@@ -535,7 +535,7 @@ data : .SYMBOLIC
 \r
 data-images : .SYMBOLIC \r
        if not exist image mkdir image\r
-       for %f in (horse_grey.bmp horse_grey_flipped.bmp horse_rle4.bmp horse_rle4_flipped.bmp horse_rle8.bmp horse_rle8_flipped.bmp) do if not exist image\%f copy .\image\%f image\r
+       for %f in (horse_grey.bmp horse_grey_flipped.bmp horse_rle4.bmp horse_rle4_flipped.bmp horse_rle8.bmp horse_rle8_flipped.bmp horse_bicubic_50x50.png horse_bicubic_100x100.png horse_bicubic_150x150.png horse_bicubic_300x300.png horse_bilinear_50x50.png horse_bilinear_100x100.png horse_bilinear_150x150.png horse_bilinear_300x300.png horse_box_average_50x50.png horse_box_average_100x100.png horse_box_average_150x150.png horse_box_average_300x300.png) do if not exist image\%f copy .\image\%f image
 \r
 fr : .SYMBOLIC \r
        if not exist $(OBJS)\intl\fr mkdir $(OBJS)\intl\fr\r
index cedfbe8c58f6d7ef5580cbc21acf6724a53d5a11..4fc52db5a830858c25524e0ced8de3fea7ec7027 100644 (file)
     <wx-data id="data-images">
         <srcdir>$(SRCDIR)/image</srcdir>
         <dstdir>image</dstdir>
-        <files>horse_grey.bmp  horse_grey_flipped.bmp
-               horse_rle4.bmp  horse_rle4_flipped.bmp
-               horse_rle8.bmp  horse_rle8_flipped.bmp</files>
+        <files>
+            horse_grey.bmp horse_grey_flipped.bmp
+            horse_rle4.bmp horse_rle4_flipped.bmp
+            horse_rle8.bmp horse_rle8_flipped.bmp
+
+            horse_bicubic_50x50.png
+            horse_bicubic_100x100.png
+            horse_bicubic_150x150.png
+            horse_bicubic_300x300.png
+
+            horse_bilinear_50x50.png
+            horse_bilinear_100x100.png
+            horse_bilinear_150x150.png
+            horse_bilinear_300x300.png
+
+            horse_box_average_50x50.png
+            horse_box_average_100x100.png
+            horse_box_average_150x150.png
+            horse_box_average_300x300.png
+        </files>
     </wx-data>
 
     <template id="catalog">