From 21fcc06b7e569420fd1fd9376afbf51f5869a254 Mon Sep 17 00:00:00 2001 From: Glenn Maynard Date: Sat, 29 Oct 2005 21:52:50 +0000 Subject: [PATCH] fix long-standing bug: resize image to fit the dialog for when the default font size is changed (in Win2k, hidden away in display -> settings -> advanced -> general) --- .../LoadingWindow/LoadingWindow_Win32.cpp | 20 ++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/stepmania/src/arch/LoadingWindow/LoadingWindow_Win32.cpp b/stepmania/src/arch/LoadingWindow/LoadingWindow_Win32.cpp index a96954aaad..61a8986b09 100644 --- a/stepmania/src/arch/LoadingWindow/LoadingWindow_Win32.cpp +++ b/stepmania/src/arch/LoadingWindow/LoadingWindow_Win32.cpp @@ -10,6 +10,7 @@ #include "RageSurface.h" #include "RageSurfaceUtils.h" +#include "RageSurfaceUtils_Zoom.h" static HBITMAP g_hBitmap = NULL; /* Load a RageSurface into a GDI surface. */ @@ -40,13 +41,26 @@ static HBITMAP LoadWin32Surface( RageSurface *&s ) return bitmap; } -static HBITMAP LoadWin32Surface( CString sFile ) +static HBITMAP LoadWin32Surface( CString sFile, HWND hWnd ) { CString error; RageSurface *pSurface = RageSurfaceUtils::LoadFile( sFile, error ); if( pSurface == NULL ) return NULL; + /* Resize the splash image to fit the dialog. Stretch to fit horizontally, + * maintaining aspect ratio. */ + { + RECT r; + GetClientRect( hWnd, &r ); + + int iWidth = r.right; + float fRatio = (float) iWidth / pSurface->w; + int iHeight = lrintf( pSurface->h * fRatio ); + + RageSurfaceUtils::Zoom( pSurface, iWidth, iHeight ); + } + HBITMAP ret = LoadWin32Surface( pSurface ); delete pSurface; return ret; @@ -57,9 +71,9 @@ BOOL CALLBACK LoadingWindow_Win32::WndProc( HWND hWnd, UINT msg, WPARAM wParam, switch( msg ) { case WM_INITDIALOG: - g_hBitmap = LoadWin32Surface( "Data/splash.png" ); + g_hBitmap = LoadWin32Surface( "Data/splash.png", hWnd ); if( g_hBitmap == NULL ) - g_hBitmap = LoadWin32Surface( "Data/splash.bmp" ); + g_hBitmap = LoadWin32Surface( "Data/splash.bmp", hWnd ); SendMessage( GetDlgItem(hWnd,IDC_SPLASH), STM_SETIMAGE,