+#ifdef wxHAVE_RAW_BITMAP
+
+#include "wx/rawbmp.h"
+
+class MyRawBitmapFrame : public wxFrame
+{
+public:
+ enum
+ {
+ BORDER = 15,
+ SIZE = 150,
+ REAL_SIZE = SIZE - 2*BORDER
+ };
+
+ MyRawBitmapFrame(wxFrame *parent)
+ : wxFrame(parent, -1, _T("Raw bitmaps (how exciting)")),
+ m_bitmap(SIZE, SIZE, 32)
+ {
+ SetClientSize(SIZE, SIZE);
+
+ // another possibility: wxNativePixelData (don't forget to remove code
+ // setting alpha in the loop below then)
+ typedef wxAlphaPixelData Data;
+
+ Data data(m_bitmap, wxPoint(BORDER, BORDER), wxSize(REAL_SIZE, REAL_SIZE));
+ if ( !data )
+ {
+ wxLogError(_T("Failed to gain raw access to bitmap data"));
+ return;
+ }
+
+ data.UseAlpha();
+
+ Data::Iterator p(data);
+
+ for ( int y = 0; y < REAL_SIZE; ++y )
+ {
+ Data::Iterator rowStart = p;
+
+ int r = y < REAL_SIZE/3 ? 255 : 0,
+ g = (REAL_SIZE/3 <= y) && (y < 2*(REAL_SIZE/3)) ? 255 : 0,
+ b = 2*(REAL_SIZE/3) <= y ? 255 : 0;
+
+ for ( int x = 0; x < REAL_SIZE; ++x )
+ {
+ p.Red() = r;
+ p.Green() = g;
+ p.Blue() = b;
+ p.Alpha() = (Data::Iterator::ChannelType)((x*255.)/REAL_SIZE);
+
+ ++p; // same as p.OffsetX(1)
+ }
+
+ p = rowStart;
+ p.OffsetY(data, 1);
+ }
+ }
+
+ void OnPaint(wxPaintEvent& WXUNUSED(event))
+ {
+ wxPaintDC dc( this );
+ dc.DrawText(_T("This is alpha and raw bitmap test"), 0, BORDER);
+ dc.DrawText(_T("This is alpha and raw bitmap test"), 0, SIZE/2 - BORDER);
+ dc.DrawText(_T("This is alpha and raw bitmap test"), 0, SIZE - 2*BORDER);
+ dc.DrawBitmap( m_bitmap, 0, 0, TRUE /* use mask */ );
+ }
+
+private:
+ wxBitmap m_bitmap;
+
+ DECLARE_EVENT_TABLE()
+};
+
+#endif // wxHAVE_RAW_BITMAP
+