]>
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
7 // Copyright: (c) 2008 Vadim Zeitlin <vadim@wxwidgets.org>
8 // Licence: wxWindows licence
9 ///////////////////////////////////////////////////////////////////////////////
11 // ----------------------------------------------------------------------------
13 // ----------------------------------------------------------------------------
21 #ifdef wxHAS_RAW_BITMAP
27 #include "wx/rawbmp.h"
32 const int HEIGHT
= 10;
35 #define ASSERT_COL_EQUAL(x, y) \
36 CPPUNIT_ASSERT_EQUAL( (unsigned char)(x), (y) )
38 // ----------------------------------------------------------------------------
40 // ----------------------------------------------------------------------------
42 class ImageRawTestCase
: public CppUnit::TestCase
45 ImageRawTestCase() { }
48 CPPUNIT_TEST_SUITE( ImageRawTestCase
);
49 CPPUNIT_TEST( RGBImage
);
50 CPPUNIT_TEST_SUITE_END();
54 DECLARE_NO_COPY_CLASS(ImageRawTestCase
)
57 CPPUNIT_TEST_SUITE_REGISTRATION( ImageRawTestCase
);
58 CPPUNIT_TEST_SUITE_NAMED_REGISTRATION( ImageRawTestCase
, "ImageRawTestCase" );
60 void ImageRawTestCase::RGBImage()
62 // create a check board image
63 wxImage
image(WIDTH
, HEIGHT
);
65 wxImagePixelData
data(image
);
66 wxImagePixelData::Iterator
p(data
);
67 for ( int y
= 0; y
< HEIGHT
; y
++ )
69 const wxImagePixelData::Iterator rowStart
= p
;
71 for ( int x
= 0; x
< WIDTH
; x
++ )
75 p
.Blue() = (x
+ y
) % 2 ? 0 : -1;
84 ASSERT_COL_EQUAL( 0xff, image
.GetRed(0, 0) );
85 ASSERT_COL_EQUAL( 0xff, image
.GetBlue(1, 1) );
86 ASSERT_COL_EQUAL( 0, image
.GetGreen(0, 1) );
87 ASSERT_COL_EQUAL( 0, image
.GetGreen(1, 0) );
90 #endif // wxHAS_RAW_BITMAP