From e788ceb8fa139a8e06378b4d380128c42da8bd86 Mon Sep 17 00:00:00 2001 From: Stefan Csomor Date: Fri, 28 Jun 2013 10:41:20 +0000 Subject: [PATCH] new method for contentScaleFactor on main screen git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@74302 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- src/osx/core/bitmap.cpp | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/src/osx/core/bitmap.cpp b/src/osx/core/bitmap.cpp index bf31f8a00c..4da8104bf9 100644 --- a/src/osx/core/bitmap.cpp +++ b/src/osx/core/bitmap.cpp @@ -1851,9 +1851,25 @@ bool wxBundleResourceHandler::LoadFile(wxBitmap *bitmap, { wxString ext = GetExtension().Lower(); wxCFStringRef resname(name); + wxCFStringRef resname2x(name+"@2x"); wxCFStringRef restype(ext); + double scale = 1.0; - wxCFRef imageURL(CFBundleCopyResourceURL(CFBundleGetMainBundle(), resname, restype, NULL)); + 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 ) + { + imageURL.reset(CFBundleCopyResourceURL(CFBundleGetMainBundle(), resname, restype, NULL)); + scale = 1.0; + } if ( imageURL.get() != NULL ) { @@ -1869,7 +1885,7 @@ bool wxBundleResourceHandler::LoadFile(wxBitmap *bitmap, kCGRenderingIntentDefault); if ( image != NULL ) { - bitmap->Create(image); + bitmap->Create(image,scale); CGImageRelease(image); } }