+// some "predefined" pixel formats
+// -------------------------------
+
+// wxImage format is common to all platforms
+typedef wxPixelFormat<unsigned char, 24, 0, 1, 2> wxImagePixelFormat;
+
+// the (most common) native bitmap format without alpha support
+#if defined(__WXMSW__)
+ // under MSW the RGB components are reversed, they're in BGR order
+ typedef wxPixelFormat<unsigned char, 24, 2, 1, 0> wxNativePixelFormat;
+
+ #define wxPIXEL_FORMAT_ALPHA 3
+#elif defined(__WXMAC__)
+ // under Mac, first component is unused but still present, hence we use
+ // 32bpp, not 24
+ typedef wxPixelFormat<unsigned char, 32, 1, 2, 3> wxNativePixelFormat;
+
+ #define wxPIXEL_FORMAT_ALPHA 0
+#elif defined(__WXCOCOA__)
+ // Cocoa is standard RGB or RGBA (normally it is RGBA)
+ typedef wxPixelFormat<unsigned char, 24, 0, 1, 2> wxNativePixelFormat;
+
+ #define wxPIXEL_FORMAT_ALPHA 3
+#elif defined(__WXGTK__)
+ // Under GTK+ 2.X we use GdkPixbuf, which is standard RGB or RGBA
+ typedef wxPixelFormat<unsigned char, 24, 0, 1, 2> wxNativePixelFormat;
+
+ #define wxPIXEL_FORMAT_ALPHA 3
+#elif defined(__WXPM__)
+ // Under PM, we can use standard RGB or RGBA
+ typedef wxPixelFormat<unsigned char, 24, 0, 1, 2> wxNativePixelFormat;
+
+ #define wxPIXEL_FORMAT_ALPHA 3
+#elif defined(__WXDFB__)
+ // Under DirectFB, RGB components are reversed, they're in BGR order
+ typedef wxPixelFormat<unsigned char, 24, 2, 1, 0> wxNativePixelFormat;
+
+ #define wxPIXEL_FORMAT_ALPHA 3
+#endif
+
+// the (most common) native format for bitmaps with alpha channel
+#ifdef wxPIXEL_FORMAT_ALPHA
+ typedef wxPixelFormat<unsigned char, 32,
+ wxNativePixelFormat::RED,
+ wxNativePixelFormat::GREEN,
+ wxNativePixelFormat::BLUE,
+ wxPIXEL_FORMAT_ALPHA> wxAlphaPixelFormat;
+#endif // wxPIXEL_FORMAT_ALPHA
+
+// we also define the (default/best) pixel format for the given class: this is
+// used as default value for the pixel format in wxPixelIterator template
+template <class T> struct wxPixelFormatFor;
+
+#if wxUSE_IMAGE
+// wxPixelFormatFor is only defined for wxImage, attempt to use it with other
+// classes (wxBitmap...) will result in compile errors which is exactly what we
+// want
+template <>
+struct wxPixelFormatFor<wxImage>
+{
+ typedef wxImagePixelFormat Format;
+};
+#endif //wxUSE_IMAGE
+
+// ----------------------------------------------------------------------------
+// wxPixelData
+// ----------------------------------------------------------------------------
+
+/*
+ wxPixelDataBase is just a helper for wxPixelData: it contains things common
+ to both wxImage and wxBitmap specializations.
+ */
+class wxPixelDataBase
+{
+public:
+ // origin of the rectangular region we represent
+ wxPoint GetOrigin() const { return m_ptOrigin; }
+
+ // width and height of the region we represent