View Single Post
Old 6th August 2017, 14:32   #9
mgrand
Junior Member
 
Join Date: Jul 2017
Posts: 8
If anybody interested, here is the piece of code I used to show different bitmaps according to the DPI setting

PHP Code:
ManifestDPIAware true

!define MUI_PAGE_CUSTOMFUNCTION_SHOW showHiDpi
!insertmacro MUI_PAGE_WELCOME
!insertmacro MUI_PAGE_LICENSE "Resource\license.rtf"
!insertmacro MUI_PAGE_COMPONENTS
!insertmacro MUI_PAGE_INSTFILES
!define MUI_PAGE_CUSTOMFUNCTION_SHOW showHiDpi
!insertmacro MUI_PAGE_FINISH

Function .onInit
    File 
/oname=$PLUGINSDIR\welcome96.bmp Resource\welcome96.bmp
    File 
/oname=$PLUGINSDIR\welcome120.bmp Resource\welcome120.bmp
    File 
/oname=$PLUGINSDIR\welcome144.bmp Resource\welcome144.bmp
    File 
/oname=$PLUGINSDIR\welcome192.bmp Resource\welcome192.bmp

    File 
/oname=$PLUGINSDIR\header96.bmp Resource\header96.bmp
    File 
/oname=$PLUGINSDIR\header120.bmp Resource\header120.bmp
    File 
/oname=$PLUGINSDIR\header144.bmp Resource\header144.bmp
    File 
/oname=$PLUGINSDIR\header192.bmp Resource\header192.bmp
FunctionEnd

Function showHiDpi
    System
::Call USER32::GetDpiForSystem()i.r0 
    
${If} $0 U<= 
        System
::Call USER32::GetDC(i0)i.r1 
        System
::Call GDI32::GetDeviceCaps(ir1,i88)i.r0 
        System
::Call USER32::ReleaseDC(i0,ir1
    ${EndIf} 

    ${
Unless} $== 120
    
${AndUnless} $== 144
    
${AndUnless} $== 192
        StrCpy 
$0 96
    
${EndIf}

    ${
NSD_SetImage$mui.WelcomePage.Image $PLUGINSDIR\welcome$0.bmp $mui.WelcomePage.Image.Bitmap
    
${NSD_SetImage$mui.FinishPage.Image $PLUGINSDIR\welcome$0.bmp $mui.FinishPage.Image.Bitmap
    SetBrandingImage 
/IMGID=1046 "$PLUGINSDIR\header$0.bmp"
FunctionEnd 
Also, it's important to note that HiDPI bitmaps size is not exactly the standard size multiplied by the scaling factor. Here are the values I used to fit perfectly (at least on Windows 10):

Header bitmap:
96dpi: 150x57
120dpi: 175x70
144dpi: 225x83
192dpi: 300x109


Welcome/Finish bitmap:
96dpi: 164x314
120dpi: 191x386
144dpi: 245x458
192dpi: 327x603
mgrand is offline   Reply With Quote