createSnapshotOfNativeWindow on non 1.0 scale mode (higher DPI)

createSnapshotOfNativeWindow works great, but if you are using scale higher than 100% this will return a larger image, and rescaling makes it looks blurry. Even when using Graphics::ResamplingQuality::highResamplingQuality

		Image tempImage = createSnapshotOfNativeWindow(childWindowHandle);
		if (tempImage.isValid() && tempImage.getWidth() > 0)
		{
			lastScreenshot = tempImage;
			//
			if (isDPIAware)
			{
				if (scaleFactor != 1.0f)
					lastScreenshot = tempImage.rescaled(getWidth(), getHeight() - yPos, Graphics::ResamplingQuality::highResamplingQuality);
			}
			else
			{
				if (lastScreenshot.getWidth() != getWidth() || lastScreenshot.getHeight() != (getHeight() - yPos))
					lastScreenshot = tempImage.rescaled(getWidth(), getHeight() - yPos, Graphics::ResamplingQuality::highResamplingQuality);
			}
		}

So I wonder if there’s an alternative way to handle this. I’m trying to get the contents of my bridged external process window. :wink:

Cheers, WilliamK

This commit should get the image resized correctly so it’s in logical pixels instead of physical pixels, but it uses StretchBlt() which will still rescale so it will look blurry at higher scale factors. I’m not sure if there’s even a way for us to get a high-DPI image using the GDI methods unfortunately.

Thank you so much, will test it out today. :slight_smile:

Cheers