]>
git.saurik.com Git - wxWidgets.git/blob - tests/image/rawbmp.cpp
1 ///////////////////////////////////////////////////////////////////////////////
2 // Name: tests/image/rawbmp.cpp
3 // Purpose: Test for using raw bitmap access classes with wxImage
4 // Author: Vadim Zeitlin
6 // Copyright: (c) 2008 Vadim Zeitlin <vadim@wxwidgets.org>
7 // Licence: wxWindows licence
8 ///////////////////////////////////////////////////////////////////////////////
10 // ----------------------------------------------------------------------------
12 // ----------------------------------------------------------------------------
20 #ifdef wxHAS_RAW_BITMAP
26 #include "wx/rawbmp.h"
31 const int HEIGHT
= 10;
34 #define ASSERT_COL_EQUAL(x, y) \
35 CPPUNIT_ASSERT_EQUAL( (unsigned char)(x), (y) )
37 // ----------------------------------------------------------------------------
39 // ----------------------------------------------------------------------------
41 class ImageRawTestCase
: public CppUnit::TestCase
44 ImageRawTestCase() { }
47 CPPUNIT_TEST_SUITE( ImageRawTestCase
);
48 CPPUNIT_TEST( RGBImage
);
49 CPPUNIT_TEST_SUITE_END();
53 DECLARE_NO_COPY_CLASS(ImageRawTestCase
)
56 CPPUNIT_TEST_SUITE_REGISTRATION( ImageRawTestCase
);
57 CPPUNIT_TEST_SUITE_NAMED_REGISTRATION( ImageRawTestCase
, "ImageRawTestCase" );
59 void ImageRawTestCase::RGBImage()
61 // create a check board image
62 wxImage
image(WIDTH
, HEIGHT
);
64 wxImagePixelData
data(image
);
65 wxImagePixelData::Iterator
p(data
);
66 for ( int y
= 0; y
< HEIGHT
; y
++ )
68 const wxImagePixelData::Iterator rowStart
= p
;
70 for ( int x
= 0; x
< WIDTH
; x
++ )
74 p
.Blue() = (x
+ y
) % 2 ? 0 : -1;
83 ASSERT_COL_EQUAL( 0xff, image
.GetRed(0, 0) );
84 ASSERT_COL_EQUAL( 0xff, image
.GetBlue(1, 1) );
85 ASSERT_COL_EQUAL( 0, image
.GetGreen(0, 1) );
86 ASSERT_COL_EQUAL( 0, image
.GetGreen(1, 0) );
89 #endif // wxHAS_RAW_BITMAP