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):
- 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<wxImage> compilation (Leonardo Fernandes).
wxGTK:
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
// 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
{
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
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);
}
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());
}
#endif //wxUSE_GUI
-template <class Image, class PixelFormat = wxPixelFormatFor<Image> >
+template <class Image, class PixelFormat = typename wxPixelFormatFor<Image>::Format >
class wxPixelData :
public wxPixelDataOut<Image>::template wxPixelDataIn<PixelFormat>
{
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
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
--- /dev/null
+///////////////////////////////////////////////////////////////////////////////
+// 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) );
+}
$(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
$(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
$(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
$(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) $<
$(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
$(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
$(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
$(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) $<
geometry/point.cpp
config/config.cpp
controls/textctrltest.cpp
+ image/rawbmp.cpp
misc/selstoretest.cpp
window/clientsize.cpp
window/setsize.cpp
# End Source File\r
# Begin Source File\r
\r
+SOURCE=.\image\rawbmp.cpp\r
+# End Source File\r
+# Begin Source File\r
+\r
SOURCE=.\geometry\rect.cpp\r
# End Source File\r
# Begin Source File\r
</File>\r
<File\r
RelativePath=".\geometry\point.cpp"/>\r
+ <File\r
+ RelativePath=".\image\rawbmp.cpp"/>\r
<File\r
RelativePath=".\geometry\rect.cpp"/>\r
<File\r
<File\r
RelativePath=".\geometry\point.cpp"\r
/>\r
+ <File\r
+ RelativePath=".\image\rawbmp.cpp"\r
+ />\r
<File\r
RelativePath=".\geometry\rect.cpp"\r
/>\r