applying patch 1873285

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@52135 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Stefan Csomor
2008-02-27 08:11:33 +00:00
parent 58d0deaac1
commit 0d0b1695e0

View File

@@ -272,19 +272,21 @@ bool wxBitmapRefData::Create( int w , int h , int d )
m_width = wxMax(1, w);
m_height = wxMax(1, h);
m_depth = d ;
m_hBitmap = NULL ;
m_bytesPerRow = GetBestBytesPerRow( w * 4 ) ;
size_t size = m_bytesPerRow * h ;
void* data = m_memBuf.GetWriteBuf( size ) ;
if ( data != NULL )
{
memset( data , 0 , size ) ;
m_memBuf.UngetWriteBuf( size ) ;
m_hBitmap = NULL ;
m_hBitmap = CGBitmapContextCreate((char*) data, m_width, m_height, 8, m_bytesPerRow, wxMacGetGenericRGBColorSpace(), kCGImageAlphaNoneSkipFirst );
wxASSERT_MSG( m_hBitmap , wxT("Unable to create CGBitmapContext context") ) ;
CGContextTranslateCTM( m_hBitmap, 0, m_height );
CGContextScaleCTM( m_hBitmap, 1, -1 );
} /* data != NULL */
m_ok = ( m_hBitmap != NULL ) ;
return m_ok ;
@@ -881,8 +883,12 @@ wxBitmap::~wxBitmap()
wxBitmap::wxBitmap(const char bits[], int the_width, int the_height, int no_bits)
{
m_refData = new wxBitmapRefData( the_width , the_height , no_bits ) ;
wxBitmapRefData* bitmapRefData;
m_refData = bitmapRefData = new wxBitmapRefData( the_width , the_height , no_bits ) ;
if (bitmapRefData->IsOk())
{
if ( no_bits == 1 )
{
int linesize = ( the_width / (sizeof(unsigned char) * 8)) ;
@@ -926,6 +932,7 @@ wxBitmap::wxBitmap(const char bits[], int the_width, int the_height, int no_bits
{
wxFAIL_MSG(wxT("multicolor BITMAPs not yet implemented"));
}
} /* bitmapRefData->IsOk() */
}
wxBitmap::wxBitmap(int w, int h, int d)
@@ -1127,8 +1134,12 @@ wxBitmap::wxBitmap(const wxImage& image, int depth)
int width = image.GetWidth();
int height = image.GetHeight();
m_refData = new wxBitmapRefData( width , height , depth ) ;
wxBitmapRefData* bitmapRefData;
m_refData = bitmapRefData = new wxBitmapRefData( width , height , depth ) ;
if ( bitmapRefData->IsOk())
{
// Create picture
bool hasAlpha = false ;
@@ -1184,6 +1195,7 @@ wxBitmap::wxBitmap(const wxImage& image, int depth)
}
if ( image.HasMask() )
SetMask( new wxMask( *this , wxColour( image.GetMaskRed() , image.GetMaskGreen() , image.GetMaskBlue() ) ) ) ;
} /* bitmapRefData->IsOk() */
}
wxImage wxBitmap::ConvertToImage() const