mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-07-22 22:00:39 -06:00
DolphinWX: Stop using XPM images
Using the XPM format for images has become a maintenance problem because people don't know how to create them. This commit removes all XPM images and all C files that contain PNG images. DolphinWX now uses the PNGs in the Resources folder instead, just like DolphinQt and DolphinQt2 do.
This commit is contained in:
@ -3,13 +3,18 @@
|
||||
// Refer to the license.txt file included.
|
||||
|
||||
#include <string>
|
||||
#include <wx/app.h>
|
||||
#include <wx/bitmap.h>
|
||||
#include <wx/gdicmn.h>
|
||||
#include <wx/image.h>
|
||||
#include <wx/msgdlg.h>
|
||||
#include <wx/mstream.h>
|
||||
#include <wx/toolbar.h>
|
||||
#include <wx/utils.h>
|
||||
|
||||
#include "Common/CommonPaths.h"
|
||||
#include "Common/FileUtil.h"
|
||||
|
||||
#include "DolphinWX/WxUtils.h"
|
||||
|
||||
#ifdef __APPLE__
|
||||
@ -55,10 +60,35 @@ void ShowErrorDialog(const wxString& error_msg)
|
||||
wxMessageBox(error_msg, _("Error"), wxOK | wxICON_ERROR);
|
||||
}
|
||||
|
||||
wxBitmap _wxGetBitmapFromMemory(const unsigned char* data, int length)
|
||||
wxBitmap LoadResourceBitmap(const std::string& name, bool allow_2x)
|
||||
{
|
||||
wxMemoryInputStream is(data, length);
|
||||
return(wxBitmap(wxImage(is, wxBITMAP_TYPE_ANY, -1), -1));
|
||||
const std::string path_base = File::GetSysDirectory() + RESOURCES_DIR + DIR_SEP + name;
|
||||
std::string path = path_base + ".png";
|
||||
#ifdef __APPLE__
|
||||
double scale_factor = 1.0;
|
||||
if (allow_2x && wxTheApp->GetTopWindow()->GetContentScaleFactor() >= 2)
|
||||
{
|
||||
const std::string path_2x = path_base + "@2x.png";
|
||||
if (File::Exists(path_2x))
|
||||
{
|
||||
path = path_2x;
|
||||
scale_factor = 2.0;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
wxImage image(StrToWxStr(path), wxBITMAP_TYPE_PNG);
|
||||
#ifdef __APPLE__
|
||||
return wxBitmap(image, -1, scale_factor);
|
||||
#else
|
||||
return wxBitmap(image);
|
||||
#endif
|
||||
}
|
||||
|
||||
wxBitmap LoadResourceBitmapPadded(const std::string& name, const wxSize& size)
|
||||
{
|
||||
wxImage image(StrToWxStr(File::GetSysDirectory() + RESOURCES_DIR + DIR_SEP + name + ".png"), wxBITMAP_TYPE_PNG);
|
||||
image.Resize(size, wxPoint(0, (size.GetHeight() - image.GetHeight()) / 2)); // Vertically centered
|
||||
return wxBitmap(image);
|
||||
}
|
||||
|
||||
wxBitmap CreateDisabledButtonBitmap(const wxBitmap& original)
|
||||
|
Reference in New Issue
Block a user