// Author: Stefan Csomor
// Modified by:
// Created: 1998-01-01
-// RCS-ID: $Id$
// Copyright: (c) Stefan Csomor
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
#include "wx/rawbmp.h"
+#include "wx/filename.h"
+
IMPLEMENT_DYNAMIC_CLASS(wxBitmap, wxGDIObject)
IMPLEMENT_DYNAMIC_CLASS(wxMask, wxObject)
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;
}
#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") );
wxBitmapRefData* bitmapRefData;
- m_refData = bitmapRefData = new wxBitmapRefData( width , height , depth ) ;
+ m_refData = bitmapRefData = new wxBitmapRefData( width/scale, height/scale, depth, scale) ;
if ( bitmapRefData->IsOk())
{
{
wxString ext = GetExtension().Lower();
wxCFStringRef resname(name);
+ wxCFStringRef resname2x(name+"@2x");
wxCFStringRef restype(ext);
+ double scale = 1.0;
+
+ wxCFRef<CFURLRef> imageURL;
+
+ if ( wxOSXGetMainScreenContentScaleFactor() > 1.9 )
+ {
+ imageURL.reset(CFBundleCopyResourceURL(CFBundleGetMainBundle(), resname2x, restype, NULL));
+ scale = 2.0;
+ }
- wxCFRef<CFURLRef> imageURL(CFBundleCopyResourceURL(CFBundleGetMainBundle(), resname, restype, NULL));
+ if ( imageURL.get() == NULL )
+ {
+ imageURL.reset(CFBundleCopyResourceURL(CFBundleGetMainBundle(), resname, restype, NULL));
+ scale = 1.0;
+ }
if ( imageURL.get() != NULL )
{
kCGRenderingIntentDefault);
if ( image != NULL )
{
- bitmap->Create(image);
+ bitmap->Create(image,scale);
CGImageRelease(image);
}
}