X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/cefe588637b8ef15042aadf437188158087bb462..80a779275ae04443c568dca919adb26cf6f5002c:/src/mac/carbon/dcmemory.cpp diff --git a/src/mac/carbon/dcmemory.cpp b/src/mac/carbon/dcmemory.cpp index c085610570..ee44e18330 100644 --- a/src/mac/carbon/dcmemory.cpp +++ b/src/mac/carbon/dcmemory.cpp @@ -1,17 +1,18 @@ ///////////////////////////////////////////////////////////////////////////// -// Name: dcmemory.cpp +// Name: src/mac/carbon/dcmemory.cpp // Purpose: wxMemoryDC class // Author: Stefan Csomor // Modified by: // Created: 01/02/97 // RCS-ID: $Id$ // Copyright: (c) Stefan Csomor -// Licence: wxWindows licence +// Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// #include "wx/wxprec.h" #include "wx/dcmemory.h" + #include "wx/mac/private.h" //----------------------------------------------------------------------------- @@ -20,7 +21,7 @@ IMPLEMENT_DYNAMIC_CLASS(wxMemoryDC,wxPaintDC) -wxMemoryDC::wxMemoryDC() +wxMemoryDC::wxMemoryDC( const wxBitmap& bitmap ) : m_selected() { m_ok = true; @@ -29,6 +30,9 @@ wxMemoryDC::wxMemoryDC() SetPen(*wxBLACK_PEN); SetFont(*wxNORMAL_FONT); m_ok = false; + + if ( bitmap.IsOk() ) + SelectObject(bitmap); } wxMemoryDC::wxMemoryDC( wxDC *WXUNUSED(dc) ) @@ -77,7 +81,8 @@ void wxMemoryDC::SelectObject( const wxBitmap& bitmap ) if (m_selected.Ok()) { #if wxMAC_USE_CORE_GRAPHICS - m_selected.UseAlpha() ; + if ( m_selected.GetDepth() != 1 ) + m_selected.UseAlpha() ; void * data = m_selected.BeginRawAccess() ; int bitsPerComp = 8 ; @@ -86,7 +91,7 @@ void wxMemoryDC::SelectObject( const wxBitmap& bitmap ) int h = bitmap.GetHeight() ; // TODO: should this be kCGImageAlphaPremultiplied[First,Last] ? - CGImageAlphaInfo a = kCGImageAlphaNoneSkipFirst ; + CGImageAlphaInfo a = kCGImageAlphaNoneSkipFirst ; CGColorSpaceRef genericColorSpace = wxMacGetGenericRGBColorSpace(); CGContextRef bmCtx = CGBitmapContextCreate( data , w, h, bitsPerComp , bytesPerPixel * w , genericColorSpace, a ); @@ -94,15 +99,16 @@ void wxMemoryDC::SelectObject( const wxBitmap& bitmap ) if ( bmCtx ) { - CGContextSetFillColorSpace( bmCtx, genericColorSpace ); - CGContextSetStrokeColorSpace( bmCtx, genericColorSpace ); + CGContextSetFillColorSpace( bmCtx, genericColorSpace ); + CGContextSetStrokeColorSpace( bmCtx, genericColorSpace ); CGContextTranslateCTM( bmCtx , 0 , m_selected.GetHeight() ) ; CGContextScaleCTM( bmCtx , 1 , -1 ) ; - m_graphicContext = new wxMacCGContext( bmCtx ) ; + m_graphicContext = new wxMacCGContext( bmCtx ) ; m_graphicContext->SetPen( m_pen ) ; - m_graphicContext->SetBrush( m_brush ) ; + m_graphicContext->SetBrush( m_brush ) ; + m_graphicContext->SetFont( m_font ) ; } m_ok = (m_graphicContext != NULL) ;