fixed wxImagePixelData compilation (ticket #3003); added a unit test for it (to be extended to cover more wxImage methods...)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@53852 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -117,6 +117,7 @@ TEST_GUI_OBJECTS = \
|
||||
test_gui_point.o \
|
||||
test_gui_config.o \
|
||||
test_gui_textctrltest.o \
|
||||
test_gui_rawbmp.o \
|
||||
test_gui_selstoretest.o \
|
||||
test_gui_clientsize.o \
|
||||
test_gui_setsize.o
|
||||
@@ -505,6 +506,9 @@ test_gui_config.o: $(srcdir)/config/config.cpp $(TEST_GUI_ODEP)
|
||||
test_gui_textctrltest.o: $(srcdir)/controls/textctrltest.cpp $(TEST_GUI_ODEP)
|
||||
$(CXXC) -c -o $@ $(TEST_GUI_CXXFLAGS) $(srcdir)/controls/textctrltest.cpp
|
||||
|
||||
test_gui_rawbmp.o: $(srcdir)/image/rawbmp.cpp $(TEST_GUI_ODEP)
|
||||
$(CXXC) -c -o $@ $(TEST_GUI_CXXFLAGS) $(srcdir)/image/rawbmp.cpp
|
||||
|
||||
test_gui_selstoretest.o: $(srcdir)/misc/selstoretest.cpp $(TEST_GUI_ODEP)
|
||||
$(CXXC) -c -o $@ $(TEST_GUI_CXXFLAGS) $(srcdir)/misc/selstoretest.cpp
|
||||
|
||||
|
84
tests/image/rawbmp.cpp
Normal file
84
tests/image/rawbmp.cpp
Normal file
@@ -0,0 +1,84 @@
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// Name: tests/image/rawbmp.cpp
|
||||
// Purpose: Test for using raw bitmap access classes with wxImage
|
||||
// Author: Vadim Zeitlin
|
||||
// Created: 2008-05-30
|
||||
// RCS-ID: $Id$
|
||||
// Copyright: (c) 2008 Vadim Zeitlin <vadim@wxwidgets.org>
|
||||
// Licence: wxWindows licence
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// headers
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
#include "testprec.h"
|
||||
|
||||
#ifdef __BORLANDC__
|
||||
#pragma hdrstop
|
||||
#endif
|
||||
|
||||
#ifndef WX_PRECOMP
|
||||
#endif // WX_PRECOMP
|
||||
|
||||
#include "wx/image.h"
|
||||
#include "wx/rawbmp.h"
|
||||
|
||||
namespace
|
||||
{
|
||||
const int WIDTH = 10;
|
||||
const int HEIGHT = 10;
|
||||
}
|
||||
|
||||
#define ASSERT_COL_EQUAL(x, y) \
|
||||
CPPUNIT_ASSERT_EQUAL( (unsigned char)(x), (y) )
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// test class
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
class ImageRawTestCase : public CppUnit::TestCase
|
||||
{
|
||||
public:
|
||||
ImageRawTestCase() { }
|
||||
|
||||
private:
|
||||
CPPUNIT_TEST_SUITE( ImageRawTestCase );
|
||||
CPPUNIT_TEST( RGBImage );
|
||||
CPPUNIT_TEST_SUITE_END();
|
||||
|
||||
void RGBImage();
|
||||
|
||||
DECLARE_NO_COPY_CLASS(ImageRawTestCase)
|
||||
};
|
||||
|
||||
CPPUNIT_TEST_SUITE_REGISTRATION( ImageRawTestCase );
|
||||
CPPUNIT_TEST_SUITE_NAMED_REGISTRATION( ImageRawTestCase, "ImageRawTestCase" );
|
||||
|
||||
void ImageRawTestCase::RGBImage()
|
||||
{
|
||||
// create a check board image
|
||||
wxImage image(WIDTH, HEIGHT);
|
||||
|
||||
wxImagePixelData data(image);
|
||||
wxImagePixelData::Iterator p(data);
|
||||
for ( int y = 0; y < HEIGHT; y++ )
|
||||
{
|
||||
const wxImagePixelData::Iterator rowStart = p;
|
||||
|
||||
for ( int x = 0; x < WIDTH; x++ )
|
||||
{
|
||||
p.Data() = (x + y) % 2 ? 0 : -1;
|
||||
++p;
|
||||
}
|
||||
|
||||
p = rowStart;
|
||||
p.OffsetY(data, 1);
|
||||
}
|
||||
|
||||
// test a few pixels
|
||||
ASSERT_COL_EQUAL( 0xff, image.GetRed(0, 0) );
|
||||
ASSERT_COL_EQUAL( 0xff, image.GetBlue(1, 1) );
|
||||
ASSERT_COL_EQUAL( 0, image.GetGreen(0, 1) );
|
||||
ASSERT_COL_EQUAL( 0, image.GetGreen(1, 0) );
|
||||
}
|
@@ -104,6 +104,7 @@ TEST_GUI_OBJECTS = \
|
||||
$(OBJS)\test_gui_point.obj \
|
||||
$(OBJS)\test_gui_config.obj \
|
||||
$(OBJS)\test_gui_textctrltest.obj \
|
||||
$(OBJS)\test_gui_rawbmp.obj \
|
||||
$(OBJS)\test_gui_selstoretest.obj \
|
||||
$(OBJS)\test_gui_clientsize.obj \
|
||||
$(OBJS)\test_gui_setsize.obj
|
||||
@@ -540,6 +541,9 @@ $(OBJS)\test_gui_config.obj: .\config\config.cpp
|
||||
$(OBJS)\test_gui_textctrltest.obj: .\controls\textctrltest.cpp
|
||||
$(CXX) -q -c -P -o$@ $(TEST_GUI_CXXFLAGS) .\controls\textctrltest.cpp
|
||||
|
||||
$(OBJS)\test_gui_rawbmp.obj: .\image\rawbmp.cpp
|
||||
$(CXX) -q -c -P -o$@ $(TEST_GUI_CXXFLAGS) .\image\rawbmp.cpp
|
||||
|
||||
$(OBJS)\test_gui_selstoretest.obj: .\misc\selstoretest.cpp
|
||||
$(CXX) -q -c -P -o$@ $(TEST_GUI_CXXFLAGS) .\misc\selstoretest.cpp
|
||||
|
||||
|
@@ -97,6 +97,7 @@ TEST_GUI_OBJECTS = \
|
||||
$(OBJS)\test_gui_point.o \
|
||||
$(OBJS)\test_gui_config.o \
|
||||
$(OBJS)\test_gui_textctrltest.o \
|
||||
$(OBJS)\test_gui_rawbmp.o \
|
||||
$(OBJS)\test_gui_selstoretest.o \
|
||||
$(OBJS)\test_gui_clientsize.o \
|
||||
$(OBJS)\test_gui_setsize.o
|
||||
@@ -518,6 +519,9 @@ $(OBJS)\test_gui_config.o: ./config/config.cpp
|
||||
$(OBJS)\test_gui_textctrltest.o: ./controls/textctrltest.cpp
|
||||
$(CXX) -c -o $@ $(TEST_GUI_CXXFLAGS) $(CPPDEPS) $<
|
||||
|
||||
$(OBJS)\test_gui_rawbmp.o: ./image/rawbmp.cpp
|
||||
$(CXX) -c -o $@ $(TEST_GUI_CXXFLAGS) $(CPPDEPS) $<
|
||||
|
||||
$(OBJS)\test_gui_selstoretest.o: ./misc/selstoretest.cpp
|
||||
$(CXX) -c -o $@ $(TEST_GUI_CXXFLAGS) $(CPPDEPS) $<
|
||||
|
||||
|
@@ -100,6 +100,7 @@ TEST_GUI_OBJECTS = \
|
||||
$(OBJS)\test_gui_point.obj \
|
||||
$(OBJS)\test_gui_config.obj \
|
||||
$(OBJS)\test_gui_textctrltest.obj \
|
||||
$(OBJS)\test_gui_rawbmp.obj \
|
||||
$(OBJS)\test_gui_selstoretest.obj \
|
||||
$(OBJS)\test_gui_clientsize.obj \
|
||||
$(OBJS)\test_gui_setsize.obj
|
||||
@@ -625,6 +626,9 @@ $(OBJS)\test_gui_config.obj: .\config\config.cpp
|
||||
$(OBJS)\test_gui_textctrltest.obj: .\controls\textctrltest.cpp
|
||||
$(CXX) /c /nologo /TP /Fo$@ $(TEST_GUI_CXXFLAGS) .\controls\textctrltest.cpp
|
||||
|
||||
$(OBJS)\test_gui_rawbmp.obj: .\image\rawbmp.cpp
|
||||
$(CXX) /c /nologo /TP /Fo$@ $(TEST_GUI_CXXFLAGS) .\image\rawbmp.cpp
|
||||
|
||||
$(OBJS)\test_gui_selstoretest.obj: .\misc\selstoretest.cpp
|
||||
$(CXX) /c /nologo /TP /Fo$@ $(TEST_GUI_CXXFLAGS) .\misc\selstoretest.cpp
|
||||
|
||||
|
@@ -309,6 +309,7 @@ TEST_GUI_OBJECTS = &
|
||||
$(OBJS)\test_gui_point.obj &
|
||||
$(OBJS)\test_gui_config.obj &
|
||||
$(OBJS)\test_gui_textctrltest.obj &
|
||||
$(OBJS)\test_gui_rawbmp.obj &
|
||||
$(OBJS)\test_gui_selstoretest.obj &
|
||||
$(OBJS)\test_gui_clientsize.obj &
|
||||
$(OBJS)\test_gui_setsize.obj
|
||||
@@ -571,6 +572,9 @@ $(OBJS)\test_gui_config.obj : .AUTODEPEND .\config\config.cpp
|
||||
$(OBJS)\test_gui_textctrltest.obj : .AUTODEPEND .\controls\textctrltest.cpp
|
||||
$(CXX) -bt=nt -zq -fo=$^@ $(TEST_GUI_CXXFLAGS) $<
|
||||
|
||||
$(OBJS)\test_gui_rawbmp.obj : .AUTODEPEND .\image\rawbmp.cpp
|
||||
$(CXX) -bt=nt -zq -fo=$^@ $(TEST_GUI_CXXFLAGS) $<
|
||||
|
||||
$(OBJS)\test_gui_selstoretest.obj : .AUTODEPEND .\misc\selstoretest.cpp
|
||||
$(CXX) -bt=nt -zq -fo=$^@ $(TEST_GUI_CXXFLAGS) $<
|
||||
|
||||
|
@@ -96,6 +96,7 @@
|
||||
geometry/point.cpp
|
||||
config/config.cpp
|
||||
controls/textctrltest.cpp
|
||||
image/rawbmp.cpp
|
||||
misc/selstoretest.cpp
|
||||
window/clientsize.cpp
|
||||
window/setsize.cpp
|
||||
|
@@ -253,6 +253,10 @@ SOURCE=.\geometry\point.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\image\rawbmp.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\geometry\rect.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
@@ -706,6 +706,8 @@
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\geometry\point.cpp"/>
|
||||
<File
|
||||
RelativePath=".\image\rawbmp.cpp"/>
|
||||
<File
|
||||
RelativePath=".\geometry\rect.cpp"/>
|
||||
<File
|
||||
|
@@ -884,6 +884,9 @@
|
||||
<File
|
||||
RelativePath=".\geometry\point.cpp"
|
||||
/>
|
||||
<File
|
||||
RelativePath=".\image\rawbmp.cpp"
|
||||
/>
|
||||
<File
|
||||
RelativePath=".\geometry\rect.cpp"
|
||||
/>
|
||||
|
Reference in New Issue
Block a user