+
+ CGDataProviderRef dataProvider = NULL ;
+ if ( m_depth == 1 )
+ {
+ wxMemoryBuffer* maskBuf = new wxMemoryBuffer( m_width * m_height );
+ unsigned char * maskBufData = (unsigned char *) maskBuf->GetData();
+ 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 );
+ }