support CGGraphics Masks, switch xbm interpretation to be in line with msw
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@41966 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -552,15 +552,37 @@ CGImageRef wxBitmapRefData::CGImageCreate() const
|
|||||||
membuf = new wxMemoryBuffer( m_memBuf ) ;
|
membuf = new wxMemoryBuffer( m_memBuf ) ;
|
||||||
}
|
}
|
||||||
|
|
||||||
CGColorSpaceRef colorSpace = wxMacGetGenericRGBColorSpace();
|
CGDataProviderRef dataProvider = NULL ;
|
||||||
CGDataProviderRef dataProvider =
|
if ( m_depth == 1 )
|
||||||
CGDataProviderCreateWithData(
|
{
|
||||||
membuf , (const void *)membuf->GetData() , imageSize,
|
wxMemoryBuffer* maskBuf = new wxMemoryBuffer( m_width * m_height );
|
||||||
wxMacMemoryBufferReleaseProc );
|
unsigned char * maskBufData = (unsigned char *) maskBuf->GetData();
|
||||||
image =
|
unsigned char * bufData = (unsigned char *) membuf->GetData() ;
|
||||||
|
// copy one color component
|
||||||
|
for( int i = 0 ; i < m_width * m_height ; ++i )
|
||||||
|
maskBufData[i] = bufData[i*4+3];
|
||||||
|
dataProvider =
|
||||||
|
CGDataProviderCreateWithData(
|
||||||
|
maskBuf , (const void *) maskBufData , m_width * m_height,
|
||||||
|
wxMacMemoryBufferReleaseProc );
|
||||||
|
// as we are now passing the mask buffer to the data provider, we have
|
||||||
|
// to release the membuf ourselves
|
||||||
|
delete membuf ;
|
||||||
|
|
||||||
|
image = ::CGImageMaskCreate( w, h, 8, 8, m_width , dataProvider, NULL, false );
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
CGColorSpaceRef colorSpace = wxMacGetGenericRGBColorSpace();
|
||||||
|
dataProvider =
|
||||||
|
CGDataProviderCreateWithData(
|
||||||
|
membuf , (const void *)membuf->GetData() , imageSize,
|
||||||
|
wxMacMemoryBufferReleaseProc );
|
||||||
|
image =
|
||||||
::CGImageCreate(
|
::CGImageCreate(
|
||||||
w, h, 8 , 32 , 4 * m_width , colorSpace, alphaInfo ,
|
w, h, 8 , 32 , 4 * m_width , colorSpace, alphaInfo ,
|
||||||
dataProvider, NULL , false , kCGRenderingIntentDefault );
|
dataProvider, NULL , false , kCGRenderingIntentDefault );
|
||||||
|
}
|
||||||
CGDataProviderRelease( dataProvider);
|
CGDataProviderRelease( dataProvider);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@@ -811,7 +833,7 @@ wxBitmap::wxBitmap(const char bits[], int the_width, int the_height, int no_bits
|
|||||||
bit = x % 8 ;
|
bit = x % 8 ;
|
||||||
mask = 1 << bit ;
|
mask = 1 << bit ;
|
||||||
|
|
||||||
if ( !(linestart[index] & mask ) )
|
if ( linestart[index] & mask )
|
||||||
{
|
{
|
||||||
*destination++ = 0xFF ;
|
*destination++ = 0xFF ;
|
||||||
*destination++ = 0 ;
|
*destination++ = 0 ;
|
||||||
|
Reference in New Issue
Block a user