bug fix for MacTel builds, using the same code on PPC as well (wxMask)

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@36753 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Stefan Csomor
2006-01-07 08:33:13 +00:00
parent 73c902d669
commit 93a2b888fc

View File

@@ -363,7 +363,11 @@ IconRef wxBitmapRefData::GetIconRef()
*dest++ = b ;
if ( mask )
*maskdest++ = *masksource++ ;
{
*maskdest++ = 0xFF - *masksource++ ;
masksource++ ;
masksource++ ;
}
else if ( hasAlpha )
*maskdest++ = a ;
else
@@ -518,9 +522,9 @@ CGImageRef wxBitmapRefData::CGImageCreate() const
for ( int y = 0 ; y < h ; ++y , sourcemaskstart += maskrowbytes)
{
unsigned char *sourcemask = sourcemaskstart ;
for ( int x = 0 ; x < w ; ++x , sourcemask++ , destalpha += 4 )
for ( int x = 0 ; x < w ; ++x , sourcemask+=3 , destalpha += 4 )
{
*destalpha = *sourcemask ;
*destalpha = 0xFF - *sourcemask ;
}
}
}
@@ -946,7 +950,8 @@ wxBitmap wxBitmap::GetSubBitmap(const wxRect &rect) const
for (int yy = 0; yy < destheight; ++yy, source += sourcelinesize , dest += destlinesize)
{
memcpy( dest , source , destlinesize ) ;
for (int xx = 0; xx < destlinesize; xx++ )
*(dest+xx) = 0xFF - *(source+xx*3) ;
}
maskbuf.UngetWriteBuf( maskbufsize ) ;
@@ -1148,7 +1153,7 @@ wxImage wxBitmap::ConvertToImage() const
if ( hasMask )
{
if ( *maskp++ == 0 )
if ( *maskp++ == 0xFF )
{
r = MASK_RED ;
g = MASK_GREEN ;
@@ -1156,6 +1161,8 @@ wxImage wxBitmap::ConvertToImage() const
}
else if ( r == MASK_RED && g == MASK_GREEN && b == MASK_BLUE )
b = MASK_BLUE_REPLACEMENT ;
maskp++ ;
maskp++ ;
}
else if ( hasAlpha )
*alpha++ = a ;
@@ -1367,8 +1374,8 @@ void *wxMask::GetRawAccess() const
return m_memBuf.GetData() ;
}
// this can be a k8IndexedGrayPixelFormat GWorld, because it never stores other values than black or white
// so no QD colorizing will occur when blitting
// The default ColorTable for k8IndexedGrayPixelFormat in Intel seems to be broken, so we'll use an non-indexed
// bitmap mask instead, in order to keep the code simple, the change is done for ppc implementations as well
void wxMask::RealizeNative()
{
@@ -1379,7 +1386,8 @@ void wxMask::RealizeNative()
}
Rect rect = { 0 , 0 , m_height , m_width } ;
verify_noerr( NewGWorldFromPtr( (GWorldPtr*) &m_maskBitmap , k8IndexedGrayPixelFormat , &rect , NULL , NULL , 0 ,
verify_noerr( NewGWorldFromPtr( (GWorldPtr*) &m_maskBitmap , k24RGBPixelFormat , &rect , NULL , NULL , 0 ,
(char*) m_memBuf.GetData() , m_bytesPerRow ) ) ;
}
@@ -1403,7 +1411,7 @@ bool wxMask::Create(const wxBitmap& bitmap)
{
m_width = bitmap.GetWidth() ;
m_height = bitmap.GetHeight() ;
m_bytesPerRow = ( m_width + 3 ) & 0xFFFFFFC ;
m_bytesPerRow = ( m_width * 3 + 3 ) & 0xFFFFFFC ;
size_t size = m_bytesPerRow * m_height ;
unsigned char * destdatabase = (unsigned char*) m_memBuf.GetWriteBuf( size ) ;
@@ -1425,9 +1433,17 @@ bool wxMask::Create(const wxBitmap& bitmap)
b = *srcdata++ ;
if ( ( r + g + b ) > 0x10 )
*destdata++ = 0x00 ;
else
{
*destdata++ = 0xFF ;
*destdata++ = 0xFF ;
*destdata++ = 0xFF ;
}
else
{
*destdata++ = 0x00 ;
*destdata++ = 0x00 ;
*destdata++ = 0x00 ;
}
}
}
@@ -1443,7 +1459,7 @@ bool wxMask::Create(const wxBitmap& bitmap, const wxColour& colour)
{
m_width = bitmap.GetWidth() ;
m_height = bitmap.GetHeight() ;
m_bytesPerRow = ( m_width + 3 ) & 0xFFFFFFC ;
m_bytesPerRow = ( m_width * 3 + 3 ) & 0xFFFFFFC ;
size_t size = m_bytesPerRow * m_height ;
unsigned char * destdatabase = (unsigned char*) m_memBuf.GetWriteBuf( size ) ;
@@ -1465,9 +1481,17 @@ bool wxMask::Create(const wxBitmap& bitmap, const wxColour& colour)
b = *srcdata++ ;
if ( colour == wxColour( r , g , b) )
*destdata++ = 0x00 ;
else
{
*destdata++ = 0xFF ;
*destdata++ = 0xFF ;
*destdata++ = 0xFF ;
}
else
{
*destdata++ = 0x00 ;
*destdata++ = 0x00 ;
*destdata++ = 0x00 ;
}
}
}