new method for contentScaleFactor on main screen

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@74301 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Stefan Csomor 2013-06-27 12:48:46 +00:00
parent c944835aaa
commit 9c4672b0f8
2 changed files with 12 additions and 1 deletions

View File

@ -42,6 +42,7 @@ OSStatus WXDLLIMPEXP_CORE wxMacDrawCGImage(
WX_NSImage WXDLLIMPEXP_CORE wxOSXGetNSImageFromCGImage( CGImageRef image, double scale = 1.0 );
CGImageRef WXDLLIMPEXP_CORE wxOSXCreateCGImageFromNSImage( WX_NSImage nsimage, double *scale = NULL );
CGContextRef WXDLLIMPEXP_CORE wxOSXCreateBitmapContextFromNSImage( WX_NSImage nsimage);
double WXDLLIMPEXP_CORE wxOSXGetMainScreenContentScaleFactor();
wxBitmap WXDLLIMPEXP_CORE wxOSXCreateSystemBitmap(const wxString& id, const wxString &client, const wxSize& size);
WXWindow WXDLLIMPEXP_CORE wxOSXGetMainWindow();

View File

@ -428,7 +428,7 @@ CGContextRef WXDLLIMPEXP_CORE wxOSXCreateBitmapContextFromNSImage( WX_NSImage ns
CGContextRef hbitmap = NULL;
if (nsimage != nil)
{
CGFloat scale = [[NSScreen mainScreen] backingScaleFactor];
double scale = wxOSXGetMainScreenContentScaleFactor();
NSSize imageSize = [nsimage size];
@ -446,6 +446,16 @@ CGContextRef WXDLLIMPEXP_CORE wxOSXCreateBitmapContextFromNSImage( WX_NSImage ns
return hbitmap;
}
double WXDLLIMPEXP_CORE wxOSXGetMainScreenContentScaleFactor()
{
#if (MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_7)
if ( [ [NSScreen mainScreen] respondsToSelector:@selector(backingScaleFactor)] )
return [[NSScreen mainScreen] backingScaleFactor];
else
#endif
return 1.0;
}
CGImageRef wxOSXCreateCGImageFromNSImage( WX_NSImage nsimage, double *scaleptr )
{
// based on http://www.mail-archive.com/cocoa-dev@lists.apple.com/msg18065.html