@@ -384,14 +384,14 @@ HICON CreateDisabledIcon( HICON hIcon, int iconSize )
384384}
385385
386386// Loads an image file into a bitmap and optionally resizes it
387- HBITMAP LoadImageFile ( const wchar_t *path, const SIZE *pSize, bool bUseAlpha, bool bPremultiply, std::vector<unsigned int > *pButtonAnim )
387+ HBITMAP LoadImageFile ( const wchar_t *path, const SIZE *pSize, bool bUseAlpha, bool bPremultiply, std::vector<unsigned int > *pButtonAnim, UINT dpi )
388388{
389389 HBITMAP srcBmp=NULL ;
390390 if (_wcsicmp (PathFindExtension (path),L" .bmp" )==0 )
391391 {
392392 srcBmp=(HBITMAP)LoadImage (NULL ,path,IMAGE_BITMAP,0 ,0 ,LR_CREATEDIBSECTION|LR_LOADFROMFILE);
393393 }
394- if (srcBmp && !pSize)
394+ if (srcBmp && !pSize && !dpi )
395395 return srcBmp;
396396 CComPtr<IWICImagingFactory> pFactory;
397397 if (FAILED (pFactory.CoCreateInstance (CLSID_WICImagingFactory)))
@@ -482,6 +482,12 @@ HBITMAP LoadImageFile( const wchar_t *path, const SIZE *pSize, bool bUseAlpha, b
482482 else
483483 frameHeightD=frameWidthD*frameHeightS/frameWidthS;
484484 }
485+
486+ if (dpi)
487+ {
488+ frameWidthD=ScaleForDpi (dpi,frameWidthD);
489+ frameHeightD=ScaleForDpi (dpi,frameHeightD);
490+ }
485491 }
486492
487493 BITMAPINFO bi={0 };
@@ -946,7 +952,12 @@ UINT GetDpi(HWND hwnd)
946952 return dpi;
947953}
948954
955+ int ScaleForDpi (UINT dpi, int value)
956+ {
957+ return MulDiv (value, dpi, USER_DEFAULT_SCREEN_DPI);
958+ }
959+
949960int ScaleForDpi (HWND hwnd, int value)
950961{
951- return MulDiv (value, GetDpi (hwnd), USER_DEFAULT_SCREEN_DPI );
962+ return ScaleForDpi ( GetDpi (hwnd), value );
952963}
0 commit comments