+ if (!testAlpha)
+ {
+ return;
+ }
+
+
+ CPPUNIT_ASSERT( actual.HasAlpha() );
+
+ WX_ASSERT_MESSAGE
+ (
+ ("Compare alpha test '%s' for saving failed", handler.GetExtension()),
+
+ memcmp(actual.GetAlpha(), expected.GetAlpha(),
+ expected.GetWidth() * expected.GetHeight()) == 0
+ );
+}
+
+void ImageTestCase::CompareSavedImage()
+{
+ wxImage expected24("horse.png");
+ CPPUNIT_ASSERT( expected24.IsOk() );
+ CPPUNIT_ASSERT( !expected24.HasAlpha() );
+
+ // Create an image with alpha based on the loaded image
+ wxImage expected32(expected24);
+ expected32.SetAlpha();
+
+ int width = expected32.GetWidth();
+ int height = expected32.GetHeight();
+ for (int y = 0; y < height; ++y)
+ {
+ for (int x = 0; x < width; ++x)
+ {
+ expected32.SetAlpha(x, y, (x*y) & wxIMAGE_ALPHA_OPAQUE);
+ }
+ }
+
+ const wxList& list = wxImage::GetHandlers();
+ for ( wxList::compatibility_iterator node = list.GetFirst();
+ node; node = node->GetNext() )
+ {
+ wxImageHandler *handler = (wxImageHandler *) node->GetData();
+
+ CompareImage(*handler, expected24);
+ CompareImage(*handler, expected32);