Refactored code to get access to wxBitmap's bit values in wxCairoContext ctor (MSW).
Use simpler version of wxAlphaPixelData and wxNativePixelData ctors and invoke respective accessors to obtain bitmap size.
This commit is contained in:
@@ -1436,11 +1436,11 @@ wxCairoBitmapData::wxCairoBitmapData( wxGraphicsRenderer* renderer, const wxBitm
|
|||||||
wxCHECK_RET( pixData, wxT("Failed to gain raw access to bitmap data."));
|
wxCHECK_RET( pixData, wxT("Failed to gain raw access to bitmap data."));
|
||||||
|
|
||||||
wxAlphaPixelData::Iterator p(pixData);
|
wxAlphaPixelData::Iterator p(pixData);
|
||||||
for (int y=0; y<m_height; y++)
|
for (int y=0; y < pixData.GetHeight(); y++)
|
||||||
{
|
{
|
||||||
wxAlphaPixelData::Iterator rowStart = p;
|
wxAlphaPixelData::Iterator rowStart = p;
|
||||||
wxUint32* const rowStartDst = data;
|
wxUint32* const rowStartDst = data;
|
||||||
for (int x=0; x<m_width; x++)
|
for (int x=0; x < pixData.GetWidth(); x++)
|
||||||
{
|
{
|
||||||
// Each pixel in CAIRO_FORMAT_ARGB32 is a 32-bit quantity,
|
// Each pixel in CAIRO_FORMAT_ARGB32 is a 32-bit quantity,
|
||||||
// with alpha in the upper 8 bits, then red, then green, then
|
// with alpha in the upper 8 bits, then red, then green, then
|
||||||
@@ -1477,16 +1477,15 @@ wxCairoBitmapData::wxCairoBitmapData( wxGraphicsRenderer* renderer, const wxBitm
|
|||||||
}
|
}
|
||||||
else // no alpha
|
else // no alpha
|
||||||
{
|
{
|
||||||
wxNativePixelData
|
wxNativePixelData pixData(bmpSource);
|
||||||
pixData(bmpSource, wxPoint(0, 0), wxSize(m_width, m_height));
|
|
||||||
wxCHECK_RET( pixData, wxT("Failed to gain raw access to bitmap data."));
|
wxCHECK_RET( pixData, wxT("Failed to gain raw access to bitmap data."));
|
||||||
|
|
||||||
wxNativePixelData::Iterator p(pixData);
|
wxNativePixelData::Iterator p(pixData);
|
||||||
for (int y=0; y<m_height; y++)
|
for (int y=0; y < pixData.GetHeight(); y++)
|
||||||
{
|
{
|
||||||
wxNativePixelData::Iterator rowStart = p;
|
wxNativePixelData::Iterator rowStart = p;
|
||||||
wxUint32* const rowStartDst = data;
|
wxUint32* const rowStartDst = data;
|
||||||
for (int x=0; x<m_width; x++)
|
for (int x=0; x < pixData.GetWidth(); x++)
|
||||||
{
|
{
|
||||||
// Each pixel in CAIRO_FORMAT_RGB24 is a 32-bit quantity, with
|
// Each pixel in CAIRO_FORMAT_RGB24 is a 32-bit quantity, with
|
||||||
// the upper 8 bits unused. Red, Green, and Blue are stored in
|
// the upper 8 bits unused. Red, Green, and Blue are stored in
|
||||||
@@ -1514,16 +1513,15 @@ wxCairoBitmapData::wxCairoBitmapData( wxGraphicsRenderer* renderer, const wxBitm
|
|||||||
{
|
{
|
||||||
wxBitmap bmpMask = bmp.GetMask()->GetBitmap();
|
wxBitmap bmpMask = bmp.GetMask()->GetBitmap();
|
||||||
data = (wxUint32*)m_buffer;
|
data = (wxUint32*)m_buffer;
|
||||||
wxNativePixelData
|
wxNativePixelData pixData(bmpMask);
|
||||||
pixData(bmpMask, wxPoint(0, 0), wxSize(m_width, m_height));
|
|
||||||
wxCHECK_RET( pixData, wxT("Failed to gain raw access to mask data."));
|
wxCHECK_RET( pixData, wxT("Failed to gain raw access to mask data."));
|
||||||
|
|
||||||
wxNativePixelData::Iterator p(pixData);
|
wxNativePixelData::Iterator p(pixData);
|
||||||
for (int y=0; y<m_height; y++)
|
for (int y=0; y < pixData.GetHeight(); y++)
|
||||||
{
|
{
|
||||||
wxNativePixelData::Iterator rowStart = p;
|
wxNativePixelData::Iterator rowStart = p;
|
||||||
wxUint32* const rowStartDst = data;
|
wxUint32* const rowStartDst = data;
|
||||||
for (int x=0; x<m_width; x++)
|
for (int x=0; x < pixData.GetWidth(); x++)
|
||||||
{
|
{
|
||||||
if (p.Red()+p.Green()+p.Blue() == 0)
|
if (p.Red()+p.Green()+p.Blue() == 0)
|
||||||
*data = 0;
|
*data = 0;
|
||||||
|
|||||||
Reference in New Issue
Block a user