From 107d4afb0891aa57246ef3960f09279132fec4bc Mon Sep 17 00:00:00 2001 From: EmptyChaos Date: Sun, 14 Aug 2016 19:54:01 +0000 Subject: WX: HiDPI: Dolphin Main UI (CFrame) --- Source/Core/DolphinWX/ISOFile.cpp | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) (limited to 'Source/Core/DolphinWX/ISOFile.cpp') diff --git a/Source/Core/DolphinWX/ISOFile.cpp b/Source/Core/DolphinWX/ISOFile.cpp index 1b986c02c6..54669a34a5 100644 --- a/Source/Core/DolphinWX/ISOFile.cpp +++ b/Source/Core/DolphinWX/ISOFile.cpp @@ -283,19 +283,16 @@ bool GameListItem::ReadPNGBanner(const std::string& path) wxBitmap GameListItem::ScaleBanner(wxImage* image) { - const double gui_scale = wxTheApp->GetTopWindow()->GetContentScaleFactor(); + wxWindow* window = wxTheApp->GetTopWindow(); + const double gui_scale = window->GetContentScaleFactor() * (window->FromDIP(1024) / 1024.0); const double target_width = DVD_BANNER_WIDTH * gui_scale; const double target_height = DVD_BANNER_HEIGHT * gui_scale; const double banner_scale = std::min(target_width / image->GetWidth(), target_height / image->GetHeight()); image->Rescale(image->GetWidth() * banner_scale, image->GetHeight() * banner_scale, - wxIMAGE_QUALITY_HIGH); + wxIMAGE_QUALITY_BICUBIC); image->Resize(wxSize(target_width, target_height), wxPoint(), 0xFF, 0xFF, 0xFF); -#ifdef __APPLE__ - return wxBitmap(*image, -1, gui_scale); -#else - return wxBitmap(*image, -1); -#endif + return wxBitmap(*image, wxBITMAP_SCREEN_DEPTH, window->GetContentScaleFactor()); } std::string GameListItem::GetDescription(DiscIO::Language language) const -- cgit v1.2.3 From 3b11581aff0fc7b1e248f1e9a67e35854f7c32b8 Mon Sep 17 00:00:00 2001 From: EmptyChaos Date: Wed, 3 Aug 2016 11:14:52 +0000 Subject: WX: HiDPI: ISOProperties And related ARCodeAddEdit/PatchAddEdit. Change ISOFile to use wxImage instead of wxBitmap since bitmaps require a screen context and banner images have a fixed resolution. --- Source/Core/DolphinWX/ISOFile.cpp | 31 ++++++++----------------------- 1 file changed, 8 insertions(+), 23 deletions(-) (limited to 'Source/Core/DolphinWX/ISOFile.cpp') diff --git a/Source/Core/DolphinWX/ISOFile.cpp b/Source/Core/DolphinWX/ISOFile.cpp index 54669a34a5..05379a98a8 100644 --- a/Source/Core/DolphinWX/ISOFile.cpp +++ b/Source/Core/DolphinWX/ISOFile.cpp @@ -38,9 +38,6 @@ static const u32 CACHE_REVISION = 0x127; // Last changed in PR 3309 -#define DVD_BANNER_WIDTH 96 -#define DVD_BANNER_HEIGHT 32 - static std::string GetLanguageString(DiscIO::Language language, std::map strings) { @@ -165,13 +162,12 @@ GameListItem::GameListItem(const std::string& _rFileName, // Volume banner. Typical for everything that isn't a DOL or ELF. if (!m_pImage.empty()) { - wxImage image(m_ImageWidth, m_ImageHeight, &m_pImage[0], true); - m_Bitmap = ScaleBanner(&image); + // Need to make explicit copy as wxImage uses reference counting for copies combined with only + // taking a pointer, not the content, when given a buffer to its constructor. + m_image.Create(m_ImageWidth, m_ImageHeight, false); + std::memcpy(m_image.GetData(), m_pImage.data(), m_pImage.size()); return; } - - // Fallback in case no banner is available. - ReadPNGBanner(File::GetSysDirectory() + RESOURCES_DIR + DIR_SEP + "nobanner.png"); } GameListItem::~GameListItem() @@ -277,22 +273,11 @@ bool GameListItem::ReadPNGBanner(const std::string& path) return false; wxImage image(StrToWxStr(path), wxBITMAP_TYPE_PNG); - m_Bitmap = ScaleBanner(&image); - return true; -} + if (!image.IsOk()) + return false; -wxBitmap GameListItem::ScaleBanner(wxImage* image) -{ - wxWindow* window = wxTheApp->GetTopWindow(); - const double gui_scale = window->GetContentScaleFactor() * (window->FromDIP(1024) / 1024.0); - const double target_width = DVD_BANNER_WIDTH * gui_scale; - const double target_height = DVD_BANNER_HEIGHT * gui_scale; - const double banner_scale = - std::min(target_width / image->GetWidth(), target_height / image->GetHeight()); - image->Rescale(image->GetWidth() * banner_scale, image->GetHeight() * banner_scale, - wxIMAGE_QUALITY_BICUBIC); - image->Resize(wxSize(target_width, target_height), wxPoint(), 0xFF, 0xFF, 0xFF); - return wxBitmap(*image, wxBITMAP_SCREEN_DEPTH, window->GetContentScaleFactor()); + m_image = image; + return true; } std::string GameListItem::GetDescription(DiscIO::Language language) const -- cgit v1.2.3