MCPcopy Create free account
hub / github.com/dolphin-emu/dolphin / LoadResourceBitmap

Function LoadResourceBitmap

Source/Core/DolphinWX/WxUtils.cpp:63–94  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

61}
62
63wxBitmap LoadResourceBitmap(const std::string& name, const wxSize& padded_size)
64{
65 const std::string path_base = File::GetSysDirectory() + RESOURCES_DIR + DIR_SEP + name;
66 std::string path = path_base + ".png";
67 double scale_factor = 1.0;
68#ifdef __APPLE__
69 if (wxTheApp->GetTopWindow()->GetContentScaleFactor() >= 2)
70 {
71 const std::string path_2x = path_base + "@2x.png";
72 if (File::Exists(path_2x))
73 {
74 path = path_2x;
75 scale_factor = 2.0;
76 }
77 }
78#endif
79 wxImage image(StrToWxStr(path), wxBITMAP_TYPE_PNG);
80
81 if (padded_size != wxSize())
82 {
83 // Add padding if necessary (or crop, but images aren't supposed to be large enough to require that).
84 // The image will be left-aligned and vertically centered.
85 const wxSize scaled_padded_size = padded_size * scale_factor;
86 image.Resize(scaled_padded_size, wxPoint(0, (scaled_padded_size.GetHeight() - image.GetHeight()) / 2));
87 }
88
89#ifdef __APPLE__
90 return wxBitmap(image, -1, scale_factor);
91#else
92 return wxBitmap(image);
93#endif
94}
95
96wxBitmap CreateDisabledButtonBitmap(const wxBitmap& original)
97{

Callers 7

CreateGUIControlsMethod · 0.85
InitBitmapsMethod · 0.85
AboutDolphinMethod · 0.85
CRenderFrameMethod · 0.85
CBreakPointBarMethod · 0.85
CWatchToolbarMethod · 0.85
InitBitmapsMethod · 0.85

Calls 10

GetSysDirectoryFunction · 0.85
StrToWxStrFunction · 0.85
wxSizeFunction · 0.85
GetContentScaleFactorMethod · 0.80
GetTopWindowMethod · 0.80
ResizeMethod · 0.80
wxBitmapClass · 0.70
ExistsFunction · 0.50
wxPointFunction · 0.50
GetHeightMethod · 0.45

Tested by

no test coverage detected