void wxMemoryDCImpl::DoSelect( const wxBitmap& bitmap ) { if ( m_selected.IsOk() ) { m_selected.EndRawAccess() ; wxDELETE(m_graphicContext); } m_selected = bitmap; if (m_selected.IsOk()) { if ( m_selected.GetDepth() != 1 ) m_selected.UseAlpha() ; m_selected.BeginRawAccess() ; m_width = bitmap.GetScaledWidth(); m_height = bitmap.GetScaledHeight(); m_contentScaleFactor = bitmap.GetScaleFactor(); CGColorSpaceRef genericColorSpace = wxMacGetGenericRGBColorSpace(); CGContextRef bmCtx = (CGContextRef) m_selected.GetHBITMAP(); if ( bmCtx ) { CGContextSetFillColorSpace( bmCtx, genericColorSpace ); CGContextSetStrokeColorSpace( bmCtx, genericColorSpace ); SetGraphicsContext( wxGraphicsContext::CreateFromNative( bmCtx ) ); } m_ok = (m_graphicContext != NULL) ; } else { m_ok = false; } }
static wxBitmap ConvertToDisabled(const wxBitmap& bmp) { #if wxVERSION_NUMBER >= 3100 && !defined(__WXMSW__) // Convert the image to disabled // It seems that m_bitmap.ConvertToDisabled() looses the scale // factor, so use this kind of conversion wxImage img = bmp.ConvertToImage(); img = img.ConvertToDisabled(); // Keep the original m_bitmap scale factor wxBitmap disabledBmp = wxBitmap(img, -1, bmp.GetScaleFactor()); return disabledBmp; #else return bmp.ConvertToDisabled(); #endif }
wxBitmap CreateDisabledButtonBitmap(const wxBitmap& original) { wxImage image = original.ConvertToImage(); return wxBitmap(image.ConvertToDisabled(240), wxBITMAP_SCREEN_DEPTH, original.GetScaleFactor()); }