X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/e788ceb8fa139a8e06378b4d380128c42da8bd86..71a09c3579dd5cb4cd8fa7fdc143561cbff74e12:/src/osx/core/bitmap.cpp diff --git a/src/osx/core/bitmap.cpp b/src/osx/core/bitmap.cpp index 4da8104bf9..8ee6127b11 100644 --- a/src/osx/core/bitmap.cpp +++ b/src/osx/core/bitmap.cpp @@ -4,7 +4,6 @@ // Author: Stefan Csomor // Modified by: // Created: 1998-01-01 -// RCS-ID: $Id$ // Copyright: (c) Stefan Csomor // Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// @@ -25,6 +24,8 @@ #include "wx/rawbmp.h" +#include "wx/filename.h" + IMPLEMENT_DYNAMIC_CLASS(wxBitmap, wxGDIObject) IMPLEMENT_DYNAMIC_CLASS(wxMask, wxObject) @@ -1235,10 +1236,29 @@ bool wxBitmap::LoadFile(const wxString& filename, wxBitmapType type) else { #if wxUSE_IMAGE - wxImage loadimage(filename, type); + double scale = 1.0; + wxString fname = filename; + + if ( type == wxBITMAP_TYPE_PNG ) + { + if ( wxOSXGetMainScreenContentScaleFactor() > 1.9 ) + { + wxFileName fn(filename); + fn.MakeAbsolute(); + fn.SetName(fn.GetName()+"@2x"); + + if ( fn.Exists() ) + { + fname = fn.GetFullPath(); + scale = 2.0; + } + } + } + + wxImage loadimage(fname, type); if (loadimage.IsOk()) { - *this = loadimage; + *this = wxBitmap(loadimage,-1,scale); return true; } @@ -1270,7 +1290,7 @@ bool wxBitmap::Create(const void* data, wxBitmapType type, int width, int height #if wxUSE_IMAGE -wxBitmap::wxBitmap(const wxImage& image, int depth) +wxBitmap::wxBitmap(const wxImage& image, int depth, double scale) { wxCHECK_RET( image.IsOk(), wxT("invalid image") ); @@ -1280,7 +1300,7 @@ wxBitmap::wxBitmap(const wxImage& image, int depth) wxBitmapRefData* bitmapRefData; - m_refData = bitmapRefData = new wxBitmapRefData( width , height , depth ) ; + m_refData = bitmapRefData = new wxBitmapRefData( width/scale, height/scale, depth, scale) ; if ( bitmapRefData->IsOk()) { @@ -1857,13 +1877,11 @@ bool wxBundleResourceHandler::LoadFile(wxBitmap *bitmap, wxCFRef imageURL; -#if wxOSX_USE_COCOA if ( wxOSXGetMainScreenContentScaleFactor() > 1.9 ) { imageURL.reset(CFBundleCopyResourceURL(CFBundleGetMainBundle(), resname2x, restype, NULL)); scale = 2.0; } -#endif if ( imageURL.get() == NULL ) {