When upgrade code from wxwidgets 3.1.6 to 3.1.7, auto scaling at higher DPI doesn't work using wxBITMAP_PNG()

Do you have a typical platform dependent issue you're battling with ? Ask it here. Make sure you mention your platform, compiler, and wxWidgets version.
[email protected]
Earned some good credits
Earned some good credits
Posts: 104
Joined: Fri Jan 08, 2021 8:19 am

When upgrade code from wxwidgets 3.1.6 to 3.1.7, auto scaling at higher DPI doesn't work using wxBITMAP_PNG()

Post by [email protected] »

Hi

We were using wxwidgets 3.1.6 source and recently updated the source to 3.1.7. Internally we were using .PNG images all at 100% DPI and using wxBITMAP_PNG() to load the image from the resource file (.rc).

When using 3.1.6 source, the image at 100% DPI was auto scaling at higher DPI e.g. 150% DPI without using any wxBitmapBundle(). After we updated the source to 3.1.7, the image at 100% DPI doesn't auto scale to 150% DPI but shows the image at 100% DPI. Do we need to change or set any configuration parameter or define to ensure the auto scaling works in 3.1.7 source. This is happening in windows system.

In some thread comments, I found that I need to set the following in our resource file (.rc)

Code: Select all

#define wxUSE_DPI_AWARE_MANIFEST 2
#include "wx/msw/wx.rc"
#define wxUSE_RC_MANIFEST
If true, is there anything else we can do at code level and not at .rc file to get this work as getting the .rc file compile from our Makefile would be complicated as it has to include the WXWIN\include folder to find "wx/msw/wx.rc" file.

Please help. Thanks.

Regards
Sree
ONEEYEMAN
Part Of The Furniture
Part Of The Furniture
Posts: 5989
Joined: Sat Apr 16, 2005 7:22 am
Location: USA, Ukraine

Re: When upgrade code from wxwidgets 3.1.6 to 3.1.7, auto scaling at higher DPI doesn't work using wxBITMAP_PNG()

Post by ONEEYEMAN »

Hi,
Adding DPI Aware option from manifest is the right thing to do even when using wxBitmapBundle.
Also, there was a change that simplifies adding manifest to MinGW compilers.

But in general you should start using bitmap bundle as I already told you.

Thank you.
[email protected]
Earned some good credits
Earned some good credits
Posts: 104
Joined: Fri Jan 08, 2021 8:19 am

Re: When upgrade code from wxwidgets 3.1.6 to 3.1.7, auto scaling at higher DPI doesn't work using wxBITMAP_PNG()

Post by [email protected] »

Sure.

I will look into it. Thank you for the support.

BTW:

Is there any other alternative way to add the wxwidgets manifest without adding the wx.rc into the .RC project file?

Regards
Sridhar
User avatar
doublemax
Moderator
Moderator
Posts: 17306
Joined: Fri Apr 21, 2006 8:03 pm
Location: $FCE2

Re: When upgrade code from wxwidgets 3.1.6 to 3.1.7, auto scaling at higher DPI doesn't work using wxBITMAP_PNG()

Post by doublemax »

The manifest can also be a separate file placed in the same directory as the executable.
The name must be the same as the executable. If the exe is "someapp.exe" the manifest must be named "someapp.manifest"
Use the source, Luke!
[email protected]
Earned some good credits
Earned some good credits
Posts: 104
Joined: Fri Jan 08, 2021 8:19 am

Re: When upgrade code from wxwidgets 3.1.6 to 3.1.7, auto scaling at higher DPI doesn't work using wxBITMAP_PNG()

Post by [email protected] »

Thank you for the response

I added the manifest as suggested in the .rc file and compiled the dll with the changes.
However, the image at 100% DPI is shown instead of scaling the image at 150% DPI when 150% is used on Windows.
Is there a way to know if the dpiware manifest is included or not in the code?

When I generate the manifest from .res file after including the following code in our .rc file

Code: Select all

#define wxUSE_DPI_AWARE_MANIFEST 2
#define wxUSE_RC_MANIFEST 1
#include "wx/msw/wx.rc"
is as follows:

Code: Select all

<?xml version='1.0' encoding='UTF-8' standalone='yes'?>
<assembly xmlns='urn:schemas-microsoft-com:asm.v1' manifestVersion='1.0'>
  <trustInfo xmlns="urn:schemas-microsoft-com:asm.v3">
    <security>
      <requestedPrivileges>
        <requestedExecutionLevel level='asInvoker' uiAccess='false' />
      </requestedPrivileges>
    </security>
  </trustInfo>
  <dependency>
    <dependentAssembly>
      <assemblyIdentity type='win32' name='Microsoft.VC90.CRT' version='9.0.21022.8' processorArchitecture='x86' publicKeyToken='1fc8b3b9a1e18e3b' />
    </dependentAssembly>
  </dependency>
  <dependency>
    <dependentAssembly>
      <assemblyIdentity type='win32'              name='Microsoft.Windows.Common-Controls'        version='6.0.0.0'                               processorArchitecture='*'                       publicKeyToken='6595b64144ccf1df'               language='*' />
    </dependentAssembly>
  </dependency>
</assembly>
So I not sure if wx_dpi_aware_pmv2.manifest is included or not

If there is a way to check, it would be great.

Regards
Sridhar
User avatar
doublemax
Moderator
Moderator
Posts: 17306
Joined: Fri Apr 21, 2006 8:03 pm
Location: $FCE2

Re: When upgrade code from wxwidgets 3.1.6 to 3.1.7, auto scaling at higher DPI doesn't work using wxBITMAP_PNG()

Post by doublemax »

You can check the resources in the executable with: http://www.angusj.com/resourcehacker/

Code: Select all

#define wxUSE_DPI_AWARE_MANIFEST 2
#include "wx/msw/wx.rc"
#define wxUSE_RC_MANIFEST
#define wxUSE_RC_MANIFEST should probably be before the include.
Use the source, Luke!
[email protected]
Earned some good credits
Earned some good credits
Posts: 104
Joined: Fri Jan 08, 2021 8:19 am

Re: When upgrade code from wxwidgets 3.1.6 to 3.1.7, auto scaling at higher DPI doesn't work using wxBITMAP_PNG()

Post by [email protected] »

Yes, it is included as :

Code: Select all

"#define wxUSE_DPI_AWARE_MANIFEST 2
#define wxUSE_RC_MANIFEST 1
#include "wx/msw/wx.rc"
Thank you for the reference link. I will check the resources in the dll.

Regards
Sridhar
[email protected]
Earned some good credits
Earned some good credits
Posts: 104
Joined: Fri Jan 08, 2021 8:19 am

Re: When upgrade code from wxwidgets 3.1.6 to 3.1.7, auto scaling at higher DPI doesn't work using wxBITMAP_PNG()

Post by [email protected] »

I just rechecked the dll using resource hacker :
It has two manifest files:
1. dpiware manifest included from wx.rc
Manifest-1.png

Code: Select all

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0" xmlns:asmv3="urn:schemas-microsoft-com:asm.v3">
  <dependency>
    <dependentAssembly>
      <assemblyIdentity type="win32" name="Microsoft.Windows.Common-Controls" version="6.0.0.0" processorArchitecture="*" publicKeyToken="6595b64144ccf1df" language="*" />
    </dependentAssembly>
  </dependency>
  <trustInfo xmlns="urn:schemas-microsoft-com:asm.v3">
    <security>
      <requestedPrivileges>
        <requestedExecutionLevel level="asInvoker" uiAccess="false" />
      </requestedPrivileges>
    </security>
  </trustInfo>
  <asmv3:application>
    <asmv3:windowsSettings>
      <dpiAwareness xmlns="http://schemas.microsoft.com/SMI/2016/WindowsSettings">PerMonitorV2, system</dpiAwareness>
      <dpiAware xmlns="http://schemas.microsoft.com/SMI/2005/WindowsSettings">true</dpiAware>
    </asmv3:windowsSettings>
  </asmv3:application>
  <compatibility xmlns="urn:schemas-microsoft-com:compatibility.v1">
    <application>
      <!-- Windows Vista -->
      <supportedOS Id="{e2011457-1546-43c5-a5fe-008deee3d3f0}" />
      <!-- Windows 7 -->
      <supportedOS Id="{35138b9a-5d96-4fbd-8e2d-a2440225f93a}" />
      <!-- Windows 8 -->
      <supportedOS Id="{4a2f28e3-53b9-4441-ba9c-d69d4a4a6e38}" />
      <!-- Windows 8.1 -->
      <supportedOS Id="{1f676c76-80e1-4239-95bb-83d0f6d0da78}" />
      <!-- Windows 10 -->
      <supportedOS Id="{8e0f7a12-bfb3-4fe8-b9a5-48fd50a15a9a}" />
    </application>
  </compatibility>
</assembly>

2. common dll specific manifest
Manifest-1.png

Code: Select all

<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
  <trustInfo xmlns="urn:schemas-microsoft-com:asm.v3">
    <security>
      <requestedPrivileges>
        <requestedExecutionLevel level="asInvoker" uiAccess="false"></requestedExecutionLevel>
      </requestedPrivileges>
    </security>
  </trustInfo>
  <dependency>
    <dependentAssembly>
      <assemblyIdentity type="win32" name="Microsoft.VC90.CRT" version="9.0.21022.8" processorArchitecture="x86" publicKeyToken="1fc8b3b9a1e18e3b"></assemblyIdentity>
    </dependentAssembly>
  </dependency>
  <dependency>
    <dependentAssembly>
      <assemblyIdentity type="win32" name="Microsoft.Windows.Common-Controls" version="6.0.0.0" processorArchitecture="*" publicKeyToken="6595b64144ccf1df" language="*"></assemblyIdentity>
    </dependentAssembly>
  </dependency>
</assembly>
It looks like both the manifests are included in the dll but the image at 100% DPI is not auto scaling to 150% DPI.

Am I missing anything?

Regards
Sridhar
Attachments
Manifest-2.png
Manifest-2.png (61.72 KiB) Viewed 123 times
User avatar
[email protected]
Filthy Rich wx Solver
Filthy Rich wx Solver
Posts: 205
Joined: Wed Jul 29, 2020 6:06 pm

Re: When upgrade code from wxwidgets 3.1.6 to 3.1.7, auto scaling at higher DPI doesn't work using wxBITMAP_PNG()

Post by [email protected] »

Do you see any visual difference when running the app with and without manifest? Without manifest, everything should look a little blurry, because the OS will scale it up.
It looks like both the manifests are included in the dll but the image at 100% DPI is not auto scaling to 150% DPI.
How exactly is the bitmap displayed?
ONEEYEMAN
Part Of The Furniture
Part Of The Furniture
Posts: 5989
Joined: Sat Apr 16, 2005 7:22 am
Location: USA, Ukraine

Re: When upgrade code from wxwidgets 3.1.6 to 3.1.7, auto scaling at higher DPI doesn't work using wxBITMAP_PNG()

Post by ONEEYEMAN »

Hi,
Why you don't want to use wxBitmapBundle?

Thank you.
PB
Part Of The Furniture
Part Of The Furniture
Posts: 3531
Joined: Sun Jan 03, 2010 5:45 pm

Re: When upgrade code from wxwidgets 3.1.6 to 3.1.7, auto scaling at higher DPI doesn't work using wxBITMAP_PNG()

Post by PB »

[email protected] wrote: Wed Jun 22, 2022 7:20 am Do you see any visual difference when running the app with and without manifest? Without manifest, everything should look a little blurry, because the OS will scale it up.
It looks like both the manifests are included in the dll but the image at 100% DPI is not auto scaling to 150% DPI.
JFYI, if one wants to be sure which DPI-aware mode an application is using (if any), I always recommend using Task Manager: In its Details tab, make sure that column "DPI Awareness" is displayed, and it contains "Per-Monitor (v2)" and not just "Per-Monitor" for the application.
[email protected]
Earned some good credits
Earned some good credits
Posts: 104
Joined: Fri Jan 08, 2021 8:19 am

Re: When upgrade code from wxwidgets 3.1.6 to 3.1.7, auto scaling at higher DPI doesn't work using wxBITMAP_PNG()

Post by [email protected] »

[email protected] wrote: Wed Jun 22, 2022 7:20 am Do you see any visual difference when running the app with and without manifest? Without manifest, everything should look a little blurry, because the OS will scale it up.
It looks like both the manifests are included in the dll but the image at 100% DPI is not auto scaling to 150% DPI.
How exactly is the bitmap displayed?
The image size is width=600 pixels height= 90 pixels. The image looks 600x90 even at 125%,150%,200% DPI. It is not increasing in width and height as per DPI to make it blurred. So the auto scaling is not working due to some reason.
[email protected]
Earned some good credits
Earned some good credits
Posts: 104
Joined: Fri Jan 08, 2021 8:19 am

Re: When upgrade code from wxwidgets 3.1.6 to 3.1.7, auto scaling at higher DPI doesn't work using wxBITMAP_PNG()

Post by [email protected] »

ONEEYEMAN wrote: Wed Jun 22, 2022 11:38 am Hi,
Why you don't want to use wxBitmapBundle?

Thank you.
We would like to use the wxBitmapBundle but would like to fix the auto scaling issue found in the code/configuration. Hence looking into this issue first. Is this anywhere related to wxBitmapBundle. I assume this is used to make the images at different DPI setting look better.

When only one image at 100% DPI is used, it should auto scale and look blurred at 200% DPI which is not happening at the moment. That's the issue.
[email protected]
Earned some good credits
Earned some good credits
Posts: 104
Joined: Fri Jan 08, 2021 8:19 am

Re: When upgrade code from wxwidgets 3.1.6 to 3.1.7, auto scaling at higher DPI doesn't work using wxBITMAP_PNG()

Post by [email protected] »

[email protected] wrote: Wed Jun 22, 2022 7:20 am JFYI, if one wants to be sure which DPI-aware mode an application is using (if any), I always recommend using Task Manager: In its Details tab, make sure that column "DPI Awareness" is displayed, and it contains "Per-Monitor (v2)" and not just "Per-Monitor" for the application.
Thank you. I will look into this and update the thread.
User avatar
doublemax
Moderator
Moderator
Posts: 17306
Joined: Fri Apr 21, 2006 8:03 pm
Location: $FCE2

Re: When upgrade code from wxwidgets 3.1.6 to 3.1.7, auto scaling at higher DPI doesn't work using wxBITMAP_PNG()

Post by doublemax »

[email protected] wrote: Thu Jun 23, 2022 11:46 am The image size is width=600 pixels height= 90 pixels. The image looks 600x90 even at 125%,150%,200% DPI. It is not increasing in width and height as per DPI to make it blurred. So the auto scaling is not working due to some reason.
Once again: How is the bitmap displayed? The automatic only works for controls that take a wxBitmapBundle as parameter, e.g. a wxStaticBitmap. It won't work if you draw a wxBitmap yourself onto a wxDC.
Use the source, Luke!
Post Reply