mask fixes for non-core graphics case (this build uses CopyDeepMask for painting, which apparently doesn't like 24RGB)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@37110 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
parent
7bdb1bc42b
commit
392e179f4f
@ -367,6 +367,7 @@ IconRef wxBitmapRefData::GetIconRef()
|
|||||||
*maskdest++ = 0xFF - *masksource++ ;
|
*maskdest++ = 0xFF - *masksource++ ;
|
||||||
masksource++ ;
|
masksource++ ;
|
||||||
masksource++ ;
|
masksource++ ;
|
||||||
|
masksource++ ;
|
||||||
}
|
}
|
||||||
else if ( hasAlpha )
|
else if ( hasAlpha )
|
||||||
*maskdest++ = a ;
|
*maskdest++ = a ;
|
||||||
@ -522,7 +523,7 @@ CGImageRef wxBitmapRefData::CGImageCreate() const
|
|||||||
for ( int y = 0 ; y < h ; ++y , sourcemaskstart += maskrowbytes)
|
for ( int y = 0 ; y < h ; ++y , sourcemaskstart += maskrowbytes)
|
||||||
{
|
{
|
||||||
unsigned char *sourcemask = sourcemaskstart ;
|
unsigned char *sourcemask = sourcemaskstart ;
|
||||||
for ( int x = 0 ; x < w ; ++x , sourcemask+=3 , destalpha += 4 )
|
for ( int x = 0 ; x < w ; ++x , sourcemask += 4 , destalpha += 4 )
|
||||||
{
|
{
|
||||||
*destalpha = 0xFF - *sourcemask ;
|
*destalpha = 0xFF - *sourcemask ;
|
||||||
}
|
}
|
||||||
@ -935,7 +936,7 @@ wxBitmap wxBitmap::GetSubBitmap(const wxRect &rect) const
|
|||||||
if ( M_BITMAPDATA->m_bitmapMask )
|
if ( M_BITMAPDATA->m_bitmapMask )
|
||||||
{
|
{
|
||||||
wxMemoryBuffer maskbuf ;
|
wxMemoryBuffer maskbuf ;
|
||||||
int rowBytes = ( destwidth + 3 ) & 0xFFFFFFC ;
|
int rowBytes = ( destwidth * 4 + 3 ) & 0xFFFFFFC ;
|
||||||
size_t maskbufsize = rowBytes * destheight ;
|
size_t maskbufsize = rowBytes * destheight ;
|
||||||
|
|
||||||
int sourcelinesize = M_BITMAPDATA->m_bitmapMask->GetBytesPerRow() ;
|
int sourcelinesize = M_BITMAPDATA->m_bitmapMask->GetBytesPerRow() ;
|
||||||
@ -945,13 +946,12 @@ wxBitmap wxBitmap::GetSubBitmap(const wxRect &rect) const
|
|||||||
unsigned char *destdata = (unsigned char * ) maskbuf.GetWriteBuf( maskbufsize ) ;
|
unsigned char *destdata = (unsigned char * ) maskbuf.GetWriteBuf( maskbufsize ) ;
|
||||||
wxASSERT( (source != NULL) && (destdata != NULL) ) ;
|
wxASSERT( (source != NULL) && (destdata != NULL) ) ;
|
||||||
|
|
||||||
source += rect.x * 3 + rect.y * sourcelinesize ;
|
source += rect.x * 4 + rect.y * sourcelinesize ;
|
||||||
unsigned char *dest = destdata ;
|
unsigned char *dest = destdata ;
|
||||||
|
|
||||||
for (int yy = 0; yy < destheight; ++yy, source += sourcelinesize , dest += destlinesize)
|
for (int yy = 0; yy < destheight; ++yy, source += sourcelinesize , dest += destlinesize)
|
||||||
{
|
{
|
||||||
for (int xx = 0; xx < destlinesize; xx++ )
|
memcpy( dest , source , destlinesize ) ;
|
||||||
*(dest+xx) = 0xFF - *(source+xx*3) ;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
maskbuf.UngetWriteBuf( maskbufsize ) ;
|
maskbuf.UngetWriteBuf( maskbufsize ) ;
|
||||||
@ -1164,6 +1164,7 @@ wxImage wxBitmap::ConvertToImage() const
|
|||||||
|
|
||||||
maskp++ ;
|
maskp++ ;
|
||||||
maskp++ ;
|
maskp++ ;
|
||||||
|
maskp++ ;
|
||||||
}
|
}
|
||||||
else if ( hasAlpha )
|
else if ( hasAlpha )
|
||||||
*alpha++ = a ;
|
*alpha++ = a ;
|
||||||
@ -1349,6 +1350,7 @@ wxMask::wxMask( const wxBitmap& bitmap )
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Construct a mask from a mono bitmap (copies the bitmap).
|
// Construct a mask from a mono bitmap (copies the bitmap).
|
||||||
|
|
||||||
wxMask::wxMask( const wxMemoryBuffer& data, int width , int height , int bytesPerRow )
|
wxMask::wxMask( const wxMemoryBuffer& data, int width , int height , int bytesPerRow )
|
||||||
{
|
{
|
||||||
Init() ;
|
Init() ;
|
||||||
@ -1389,12 +1391,13 @@ void wxMask::RealizeNative()
|
|||||||
Rect rect = { 0 , 0 , m_height , m_width } ;
|
Rect rect = { 0 , 0 , m_height , m_width } ;
|
||||||
|
|
||||||
OSStatus err = NewGWorldFromPtr(
|
OSStatus err = NewGWorldFromPtr(
|
||||||
(GWorldPtr*) &m_maskBitmap , k24RGBPixelFormat , &rect , NULL , NULL , 0 ,
|
(GWorldPtr*) &m_maskBitmap , k32ARGBPixelFormat , &rect , NULL , NULL , 0 ,
|
||||||
(char*) m_memBuf.GetData() , m_bytesPerRow ) ;
|
(char*) m_memBuf.GetData() , m_bytesPerRow ) ;
|
||||||
verify_noerr( err ) ;
|
verify_noerr( err ) ;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Create a mask from a mono bitmap (copies the bitmap).
|
// Create a mask from a mono bitmap (copies the bitmap).
|
||||||
|
|
||||||
bool wxMask::Create(const wxMemoryBuffer& data,int width , int height , int bytesPerRow)
|
bool wxMask::Create(const wxMemoryBuffer& data,int width , int height , int bytesPerRow)
|
||||||
{
|
{
|
||||||
m_memBuf = data ;
|
m_memBuf = data ;
|
||||||
@ -1414,7 +1417,7 @@ bool wxMask::Create(const wxBitmap& bitmap)
|
|||||||
{
|
{
|
||||||
m_width = bitmap.GetWidth() ;
|
m_width = bitmap.GetWidth() ;
|
||||||
m_height = bitmap.GetHeight() ;
|
m_height = bitmap.GetHeight() ;
|
||||||
m_bytesPerRow = ( m_width * 3 + 3 ) & 0xFFFFFFC ;
|
m_bytesPerRow = ( m_width * 4 + 3 ) & 0xFFFFFFC ;
|
||||||
|
|
||||||
size_t size = m_bytesPerRow * m_height ;
|
size_t size = m_bytesPerRow * m_height ;
|
||||||
unsigned char * destdatabase = (unsigned char*) m_memBuf.GetWriteBuf( size ) ;
|
unsigned char * destdatabase = (unsigned char*) m_memBuf.GetWriteBuf( size ) ;
|
||||||
@ -1440,12 +1443,14 @@ bool wxMask::Create(const wxBitmap& bitmap)
|
|||||||
*destdata++ = 0xFF ;
|
*destdata++ = 0xFF ;
|
||||||
*destdata++ = 0xFF ;
|
*destdata++ = 0xFF ;
|
||||||
*destdata++ = 0xFF ;
|
*destdata++ = 0xFF ;
|
||||||
|
*destdata++ = 0xFF ;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
*destdata++ = 0x00 ;
|
*destdata++ = 0x00 ;
|
||||||
*destdata++ = 0x00 ;
|
*destdata++ = 0x00 ;
|
||||||
*destdata++ = 0x00 ;
|
*destdata++ = 0x00 ;
|
||||||
|
*destdata++ = 0x00 ;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1462,7 +1467,7 @@ bool wxMask::Create(const wxBitmap& bitmap, const wxColour& colour)
|
|||||||
{
|
{
|
||||||
m_width = bitmap.GetWidth() ;
|
m_width = bitmap.GetWidth() ;
|
||||||
m_height = bitmap.GetHeight() ;
|
m_height = bitmap.GetHeight() ;
|
||||||
m_bytesPerRow = ( m_width * 3 + 3 ) & 0xFFFFFFC ;
|
m_bytesPerRow = ( m_width * 4 + 3 ) & 0xFFFFFFC ;
|
||||||
|
|
||||||
size_t size = m_bytesPerRow * m_height ;
|
size_t size = m_bytesPerRow * m_height ;
|
||||||
unsigned char * destdatabase = (unsigned char*) m_memBuf.GetWriteBuf( size ) ;
|
unsigned char * destdatabase = (unsigned char*) m_memBuf.GetWriteBuf( size ) ;
|
||||||
@ -1488,12 +1493,14 @@ bool wxMask::Create(const wxBitmap& bitmap, const wxColour& colour)
|
|||||||
*destdata++ = 0xFF ;
|
*destdata++ = 0xFF ;
|
||||||
*destdata++ = 0xFF ;
|
*destdata++ = 0xFF ;
|
||||||
*destdata++ = 0xFF ;
|
*destdata++ = 0xFF ;
|
||||||
|
*destdata++ = 0xFF ;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
*destdata++ = 0x00 ;
|
*destdata++ = 0x00 ;
|
||||||
*destdata++ = 0x00 ;
|
*destdata++ = 0x00 ;
|
||||||
*destdata++ = 0x00 ;
|
*destdata++ = 0x00 ;
|
||||||
|
*destdata++ = 0x00 ;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user