WxPixelData
A class template with ready to use implementations for getting direct and efficient access to wxBitmap's internal data and wxImage's internal data through a standard interface.
Example
wxBitmap bmp(width, size, 24); // explicit depth important under MSW
wxNativePixelData data(bmp);
if ( !data )
{
// ... raw access to bitmap data unavailable, do something else ...
return;
}
if ( data.GetWidth() < 20 || data.GetHeight() < 20 )
{
// ... complain: the bitmap it too small ...
return;
}
wxNativePixelData::Iterator p(data);
// we draw a (10, 10)-(20, 20) rect manually using the given r, g, b
p.Offset(data, 10, 10);
for ( int y = 0; y < 10; ++y )
{
wxNativePixelData::Iterator rowStart = p;
for ( int x = 0; x < 10; ++x, ++p )
{
p.Red() = r;
p.Green() = g;
p.Blue() = b;
}
p = rowStart;
p.OffsetY(data, 1);
}