From 92d9cb3fd5c5690b9b27917b0750475177e5f21f Mon Sep 17 00:00:00 2001 From: Charlie Fenton Date: Tue, 26 Aug 2014 03:56:21 -0700 Subject: [PATCH] MGR: On MS Windows, adjust Simple View images from skin file for users DPI setting. --- clientgui/SkinManager.cpp | 39 +++++++++++++++++++++++++++++-- clientgui/sg_BoincSimpleFrame.cpp | 14 ----------- clientgui/sg_ProjectPanel.cpp | 24 ++++++++++++++++--- 3 files changed, 58 insertions(+), 19 deletions(-) diff --git a/clientgui/SkinManager.cpp b/clientgui/SkinManager.cpp index 43fa059ce2..2665fae3a8 100644 --- a/clientgui/SkinManager.cpp +++ b/clientgui/SkinManager.cpp @@ -29,6 +29,7 @@ #include "BOINCGUIApp.h" #include "BOINCBaseFrame.h" #include "SkinManager.h" +#include "MainDocument.h" #include "version.h" @@ -152,13 +153,36 @@ bool CSkinImage::SetDefaults(wxString strComponentName, const char** ppDefaultBi bool CSkinImage::Validate() { if (!m_bmpBitmap.Ok()) { if (!m_strDesiredBitmap.IsEmpty()) { - m_bmpBitmap = wxBitmap(wxImage(m_strDesiredBitmap, wxBITMAP_TYPE_ANY)); + wxImage img = wxImage(m_strDesiredBitmap, wxBITMAP_TYPE_ANY); + if (img.IsOk()) { +#ifdef __WXMSW__ + if ((GetXDPIScaling() > 1.05) || (GetYDPIScaling() > 1.05)) { + img.Rescale((int) (img.GetWidth()*GetXDPIScaling()), + (int) (img.GetHeight()*GetYDPIScaling()), + wxIMAGE_QUALITY_BILINEAR + ); + } +#endif + m_bmpBitmap = wxBitmap(img); + } } if (!m_bmpBitmap.Ok()) { if (show_error_msgs) { fprintf(stderr, "Skin Manager: Failed to load '%s' image. Using default.\n", (const char *)m_strComponentName.mb_str()); } m_bmpBitmap = wxBitmap(m_ppDefaultBitmap); +#ifdef __WXMSW__ + if ((GetXDPIScaling() > 1.05) || (GetYDPIScaling() > 1.05)) { + wxImage img = m_bmpBitmap.ConvertToImage(); + img.Rescale((int) (img.GetWidth()*GetXDPIScaling()), + (int) (img.GetHeight()*GetYDPIScaling()), + wxIMAGE_QUALITY_BILINEAR + ); + wxBitmap *bm = new wxBitmap(img); + m_bmpBitmap = *bm; + delete bm; + } +#endif wxASSERT(m_bmpBitmap.Ok()); } } @@ -480,7 +504,18 @@ int CSkinAdvanced::Parse(MIOFILE& in) { wxString(strBuffer.c_str(), wxConvUTF8) ); if (boinc_file_exists(str.c_str())) { - m_bitmapApplicationLogo = wxBitmap(wxImage(str.c_str(), wxBITMAP_TYPE_ANY)); + wxImage img = wxImage(str.c_str(), wxBITMAP_TYPE_ANY); + if (img.IsOk()) { +#ifdef __WXMSW__ + if ((GetXDPIScaling() > 1.05) || (GetYDPIScaling() > 1.05)) { + img.Rescale((int) (img.GetWidth()*GetXDPIScaling()), + (int) (img.GetHeight()*GetYDPIScaling()), + wxIMAGE_QUALITY_BILINEAR + ); + } +#endif + m_bitmapApplicationLogo = wxBitmap(img); + } } } continue; diff --git a/clientgui/sg_BoincSimpleFrame.cpp b/clientgui/sg_BoincSimpleFrame.cpp index f94e2f3ad1..9e744a781f 100755 --- a/clientgui/sg_BoincSimpleFrame.cpp +++ b/clientgui/sg_BoincSimpleFrame.cpp @@ -929,22 +929,8 @@ void CSimpleGUIPanel::SetBackgroundBitmap() { dc.SetPen(bgPen); dc.DrawRectangle(panelRect); #endif - dc.DrawBitmap(*pSkinSimple->GetBackgroundImage()->GetBitmap(), 0, 0, false); -#ifdef __WXMSW__ - if ((GetXDPIScaling() > 1.05) || (GetYDPIScaling() > 1.05)) { - wxImage img = m_bmpBg.ConvertToImage(); - img.Rescale((int) (img.GetWidth()*GetXDPIScaling()), - (int) (img.GetHeight()*GetYDPIScaling()), - wxIMAGE_QUALITY_BILINEAR - ); - wxBitmap *bm = new wxBitmap(img); - m_bmpBg = *bm; - delete bm; - } -#endif - wxLogTrace(wxT("Function Start/End"), wxT("CSimpleGUIPanel::SetBackgroundBitmap - Function End")); } diff --git a/clientgui/sg_ProjectPanel.cpp b/clientgui/sg_ProjectPanel.cpp index 4c257d50ba..51b3cb0995 100644 --- a/clientgui/sg_ProjectPanel.cpp +++ b/clientgui/sg_ProjectPanel.cpp @@ -530,11 +530,29 @@ wxBitmap* CSimpleProjectPanel::GetProjectSpecificBitmap(char* project_url) { // Only update it if project specific is found if(boinc_resolve_filename(GetProjectIconLoc(project_url).c_str(), defaultIcnPath, sizeof(defaultIcnPath)) == 0) { - wxBitmap* projectBM = new wxBitmap(); + wxBitmap* projectBM; wxString strIconPath = wxString(defaultIcnPath,wxConvUTF8); if (wxFile::Exists(strIconPath)) { - if ( projectBM->LoadFile(strIconPath, wxBITMAP_TYPE_ANY) ) { - return projectBM; +#ifdef __WXMSW__ + if ((GetXDPIScaling() > 1.05) || (GetYDPIScaling() > 1.05)) { + wxImage img = wxImage(strIconPath, wxBITMAP_TYPE_ANY); + if (img.IsOk()) { + img.Rescale((int) (img.GetWidth()*GetXDPIScaling()), + (int) (img.GetHeight()*GetYDPIScaling()), + wxIMAGE_QUALITY_BILINEAR + ); + projectBM = new wxBitmap(img); + if (projectBM->IsOk()) { + return projectBM; + } + } + } else +#endif + { + projectBM = new wxBitmap(); + if ( projectBM->LoadFile(strIconPath, wxBITMAP_TYPE_ANY) ) { + return projectBM; + } } } }