support for @2x notation for wxBITMAP_TYPE_PNG (non-resource) on retina displays
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@74511 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -116,7 +116,7 @@ public:
|
|||||||
wxBitmap(const wxSize& sz, int depth = -1) { (void)Create(sz, depth); }
|
wxBitmap(const wxSize& sz, int depth = -1) { (void)Create(sz, depth); }
|
||||||
|
|
||||||
// Convert from wxImage:
|
// Convert from wxImage:
|
||||||
wxBitmap(const wxImage& image, int depth = -1);
|
wxBitmap(const wxImage& image, int depth = -1, double scale = 1.0);
|
||||||
|
|
||||||
// Convert from wxIcon
|
// Convert from wxIcon
|
||||||
wxBitmap(const wxIcon& icon) { CopyFromIcon(icon); }
|
wxBitmap(const wxIcon& icon) { CopyFromIcon(icon); }
|
||||||
|
@@ -25,6 +25,8 @@
|
|||||||
|
|
||||||
#include "wx/rawbmp.h"
|
#include "wx/rawbmp.h"
|
||||||
|
|
||||||
|
#include "wx/filename.h"
|
||||||
|
|
||||||
IMPLEMENT_DYNAMIC_CLASS(wxBitmap, wxGDIObject)
|
IMPLEMENT_DYNAMIC_CLASS(wxBitmap, wxGDIObject)
|
||||||
IMPLEMENT_DYNAMIC_CLASS(wxMask, wxObject)
|
IMPLEMENT_DYNAMIC_CLASS(wxMask, wxObject)
|
||||||
|
|
||||||
@@ -1235,10 +1237,29 @@ bool wxBitmap::LoadFile(const wxString& filename, wxBitmapType type)
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
#if wxUSE_IMAGE
|
#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())
|
if (loadimage.IsOk())
|
||||||
{
|
{
|
||||||
*this = loadimage;
|
*this = wxBitmap(loadimage,-1,scale);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -1270,7 +1291,7 @@ bool wxBitmap::Create(const void* data, wxBitmapType type, int width, int height
|
|||||||
|
|
||||||
#if wxUSE_IMAGE
|
#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") );
|
wxCHECK_RET( image.IsOk(), wxT("invalid image") );
|
||||||
|
|
||||||
@@ -1280,7 +1301,7 @@ wxBitmap::wxBitmap(const wxImage& image, int depth)
|
|||||||
|
|
||||||
wxBitmapRefData* bitmapRefData;
|
wxBitmapRefData* bitmapRefData;
|
||||||
|
|
||||||
m_refData = bitmapRefData = new wxBitmapRefData( width , height , depth ) ;
|
m_refData = bitmapRefData = new wxBitmapRefData( width/scale, height/scale, depth, scale) ;
|
||||||
|
|
||||||
if ( bitmapRefData->IsOk())
|
if ( bitmapRefData->IsOk())
|
||||||
{
|
{
|
||||||
|
Reference in New Issue
Block a user