diff --git a/docs/changes.txt b/docs/changes.txt index fdd806b24b..9e6b8e30c6 100644 --- a/docs/changes.txt +++ b/docs/changes.txt @@ -270,7 +270,7 @@ All: wxQueueEvent() replacing wxPostEvent(). - wxString now uses std::[w]string internally by default, meaning that it is now thread-safe if the standard library provided with your compiler is. -- Added wxCmdLineParser::AddUsageText() (Marcin 'Malcom' Malich) +- Added wxCmdLineParser::AddUsageText() (Marcin 'Malcom' Malich). All (Unix): @@ -348,6 +348,7 @@ All (GUI): - Allow having menu separators with ids != wxID_SEPARATOR (Jeff Tupper) - Fix appending items to sorted wxComboCtrl after creation (Jaakko Salli) - Don't blit area larger than necessary in wxBufferedDC::UnMask (Liang Jian) +- Fixed wxPixelData compilation (Leonardo Fernandes). wxGTK: diff --git a/include/wx/rawbmp.h b/include/wx/rawbmp.h index 9de976c0ea..df5db7d23e 100644 --- a/include/wx/rawbmp.h +++ b/include/wx/rawbmp.h @@ -309,7 +309,7 @@ struct wxPixelDataOut typedef wxImagePixelFormat PixelFormat; // the type of the pixel components - typedef typename dummyPixelFormat::ChannelType ChannelType; + typedef typename PixelFormat::ChannelType ChannelType; // the pixel data we're working with typedef @@ -405,12 +405,16 @@ struct wxPixelDataOut // data access // ----------- - // access to invidividual colour components + // access to individual colour components ChannelType& Red() { return m_pRGB[PixelFormat::RED]; } ChannelType& Green() { return m_pRGB[PixelFormat::GREEN]; } ChannelType& Blue() { return m_pRGB[PixelFormat::BLUE]; } ChannelType& Alpha() { return *m_pAlpha; } + // address the pixel contents directly (always RGB, without alpha) + typename PixelFormat::PixelType& Data() + { return *(typename PixelFormat::PixelType *)m_pRGB; } + // private: -- see comment in the beginning of the file // pointer into RGB buffer @@ -425,7 +429,7 @@ struct wxPixelDataOut { m_width = image.GetWidth(); m_height = image.GetHeight(); - m_stride = Iterator::SizePixel * m_width; + m_stride = Iterator::PixelFormat::SizePixel * m_width; } // initializes us with the given region of the specified image @@ -433,7 +437,7 @@ struct wxPixelDataOut const wxPoint& pt, const wxSize& sz) : m_image(image), m_pixels(image) { - m_stride = Iterator::SizePixel * m_width; + m_stride = Iterator::PixelFormat::SizePixel * m_width; InitRect(pt, sz); } @@ -442,7 +446,7 @@ struct wxPixelDataOut wxPixelDataIn(ImageType& image, const wxRect& rect) : m_image(image), m_pixels(image) { - m_stride = Iterator::SizePixel * m_width; + m_stride = Iterator::PixelFormat::SizePixel * m_width; InitRect(rect.GetPosition(), rect.GetSize()); } @@ -675,7 +679,7 @@ struct wxPixelDataOut #endif //wxUSE_GUI -template > +template ::Format > class wxPixelData : public wxPixelDataOut::template wxPixelDataIn { diff --git a/tests/Makefile.in b/tests/Makefile.in index cdc0b755f1..945554e88f 100644 --- a/tests/Makefile.in +++ b/tests/Makefile.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 diff --git a/tests/image/rawbmp.cpp b/tests/image/rawbmp.cpp new file mode 100644 index 0000000000..be37a83242 --- /dev/null +++ b/tests/image/rawbmp.cpp @@ -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 +// 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) ); +} diff --git a/tests/makefile.bcc b/tests/makefile.bcc index 232de88194..5e211db3be 100644 --- a/tests/makefile.bcc +++ b/tests/makefile.bcc @@ -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 diff --git a/tests/makefile.gcc b/tests/makefile.gcc index 0d9e1d3186..920221b1fd 100644 --- a/tests/makefile.gcc +++ b/tests/makefile.gcc @@ -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) $< diff --git a/tests/makefile.vc b/tests/makefile.vc index 08d5e1ede0..67b4f4e8a7 100644 --- a/tests/makefile.vc +++ b/tests/makefile.vc @@ -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 diff --git a/tests/makefile.wat b/tests/makefile.wat index ec777b57b1..5093a6e9b2 100644 --- a/tests/makefile.wat +++ b/tests/makefile.wat @@ -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) $< diff --git a/tests/test.bkl b/tests/test.bkl index 292779bcac..8fa1ac432f 100644 --- a/tests/test.bkl +++ b/tests/test.bkl @@ -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 diff --git a/tests/test_test_gui.dsp b/tests/test_test_gui.dsp index 55dd1d27d1..807fa7ad94 100644 --- a/tests/test_test_gui.dsp +++ b/tests/test_test_gui.dsp @@ -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 diff --git a/tests/test_vc7_test_gui.vcproj b/tests/test_vc7_test_gui.vcproj index 99c8d2cd07..9969813b0f 100644 --- a/tests/test_vc7_test_gui.vcproj +++ b/tests/test_vc7_test_gui.vcproj @@ -706,6 +706,8 @@ + +