From: Robert Roebling Date: Sun, 29 Jan 2006 15:44:21 +0000 (+0000) Subject: Fix rawbitmap sample to clear bitmap first. X-Git-Url: https://git.saurik.com/wxWidgets.git/commitdiff_plain/6e5551ad85f73b14b02f42a26ab5609ab4b8d468 Fix rawbitmap sample to clear bitmap first. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@37210 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- diff --git a/samples/image/image.cpp b/samples/image/image.cpp index 04e04cd670..317fe045fb 100644 --- a/samples/image/image.cpp +++ b/samples/image/image.cpp @@ -304,8 +304,33 @@ public: // another possibility: wxNativePixelData (don't forget to remove code // setting alpha in the loop below then) typedef wxAlphaPixelData Data; + // typedef wxNativePixelData Data; + + // First, clear the whole bitmap by making it alpha + { + Data data( m_bitmap, wxPoint(0,0), wxSize(SIZE, 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 < SIZE; ++y ) + { + Data::Iterator rowStart = p; + for ( int x = 0; x < SIZE; ++x ) + { + p.Alpha() = 0; + ++p; // same as p.OffsetX(1) + } + p = rowStart; + p.OffsetY(data, 1); + } + } - Data data(m_bitmap, wxPoint(BORDER, BORDER), wxSize(REAL_SIZE, REAL_SIZE)); + // Then, draw colourful alpha-blended stripes + Data data(m_bitmap, wxPoint(BORDER, BORDER) , wxSize(REAL_SIZE, REAL_SIZE)); if ( !data ) { wxLogError(_T("Failed to gain raw access to bitmap data"));