gui:windows: Implement image DPI scaling

This should reproduce the old non-DPI aware pre-wxWidgets 3.0 behaviour
for the main dialogs, except the font rendering should be better.

And add comments that I should have already added but didn't.
This commit is contained in:
Jonathan Li 2015-09-07 18:33:14 +01:00
parent 59ffed85ba
commit bcc125ceb6
2 changed files with 11 additions and 4 deletions

View File

@ -21,6 +21,8 @@
#include <wx/wfstream.h>
#include <wx/imaglist.h>
#include "MSWstuff.h"
#include "Resources/EmbeddedImage.h"
#include "Resources/BackgroundLogo.h"
#include "Resources/ButtonIcon_Camera.h"
@ -145,7 +147,8 @@ const wxBitmap& Pcsx2App::GetLogoBitmap()
wxImage img;
EmbeddedImage<res_BackgroundLogo> temp; // because gcc can't allow non-const temporaries.
LoadImageAny( img, useTheme, mess, L"BackgroundLogo", temp );
logo = new wxBitmap( img );
float scale = MSW_GetDPIScale(); // 1.0 for non-Windows
logo = new wxBitmap(img.Scale(img.GetWidth() * scale, img.GetHeight() * scale, wxIMAGE_QUALITY_HIGH));
return *logo;
}
@ -167,7 +170,8 @@ const wxBitmap& Pcsx2App::GetScreenshotBitmap()
wxImage img;
EmbeddedImage<res_ButtonIcon_Camera> temp; // because gcc can't allow non-const temporaries.
LoadImageAny(img, useTheme, mess, L"ButtonIcon_Camera", temp);
screenshot = new wxBitmap(img);
float scale = MSW_GetDPIScale(); // 1.0 for non-Windows
screenshot = new wxBitmap(img.Scale(img.GetWidth() * scale, img.GetHeight() * scale, wxIMAGE_QUALITY_HIGH));
return *screenshot;
}
@ -177,7 +181,7 @@ wxImageList& Pcsx2App::GetImgList_Config()
ScopedPtr<wxImageList>& images( GetResourceCache().ConfigImages );
if( !images )
{
int image_size = g_Conf->Listbook_ImageSize;
int image_size = MSW_GetDPIScale() * g_Conf->Listbook_ImageSize;
images = new wxImageList(image_size, image_size);
wxFileName mess;
bool useTheme = (g_Conf->DeskTheme != L"default");
@ -219,6 +223,7 @@ wxImageList& Pcsx2App::GetImgList_Config()
return *images;
}
// This stuff seems unused?
wxImageList& Pcsx2App::GetImgList_Toolbars()
{
ScopedPtr<wxImageList>& images( GetResourceCache().ToolbarImages );

View File

@ -28,11 +28,13 @@ void MSW_SetWindowAfter( WXWidget hwnd, WXWidget hwndAfter )
#endif
}
// Text scales automatically on Windows but that's about it. The dialog widths
// and images need to be scaled manually.
float MSW_GetDPIScale()
{
#ifdef __WXMSW__
HDC screen = GetDC(0);
float scale = GetDeviceCaps(screen, LOGPIXELSX) / 96.0;
float scale = GetDeviceCaps(screen, LOGPIXELSX) / 96.0; // 96.0 dpi = 100% scale
ReleaseDC(NULL, screen);
return scale;