mono / xwt

A cross-platform UI toolkit for creating desktop applications with .NET and Mono
MIT License
1.37k stars 241 forks source link

High-DPI image scaling #401

Open ksigne opened 10 years ago

ksigne commented 10 years ago

Hello Lluis! I've tried to draw GDI image on XWT context (wpf backend actually), but on 125% UI setting it became corrupted. I've already gathered scaling factor from Screen.ScaleFactor and used it to increase physical size of generated bitmap. After messing around with stuff I found this code is the reason (in Xwt.WPF, ImageHandler.cs method WPFImage.Draw):

if (bmpImage != null && (bmpImage.PixelHeight != idesc.Size.Height || bmpImage.PixelWidth != idesc.Size.Width))
f = new TransformedBitmap (bmpImage, new ScaleTransform (idesc.Size.Width / bmpImage.PixelWidth, idesc.Size.Height / bmpImage.PixelHeight));

If high DPI setting, idesc.Size will be obviously less size and we don't need to rescale image. Please clarify if I miss some in API to prevent image blurring without erasing this code.

slluis commented 9 years ago

I think the above commit should fix the issue. Can you verify?

sgmunn commented 9 years ago

We had to revert this because it caused a regression in the designer. We will re-examine this issue.