Scaling problem HiDPI


I try something rather easy. Load an image, draw some text on it, output the image again.
Code simplified:

[code] Dim picFile As New FolderItem("/Users/mathiasmaes/Desktop/Schermveranderaar/lesverplaatsingen.png", FolderItem.PathTypeNative)

If picFile <> Nil Then
Dim pic As Picture
pic = Picture.Open(picFile)

pic = ModernizePicture(pic)

pic.Graphics.ForeColor = Color.Blue
pic.Graphics.TextUnit = FontUnits.Pixel
pic.Graphics.TextSize = 50

pic.Graphics.DrawString("M. Monteyne"), 60, 190)

Dim savelocation As New FolderItem("/Users/mathiasmaes/Desktop/Schermveranderaar/lesverplaatsingen1.png", FolderItem.PathTypeNative)
pic.Save(savelocation, Picture.SaveAsPNG)

End If[/code]

Original image:

Outputed image:

The text is on the right place, but the width is completely wrong, the original text on the image is way to small.
This probably has to do something with scaling or something, but I don’t know how to change this.

The code of modernizepicture is:

[code] Dim result As New Picture( input.Width, input.Height)
result.HorizontalResolution = input.HorizontalResolution
result.VerticalResolution = input.VerticalResolution
result.Graphics.DrawPicture( input, 0, 0 )

Return result[/code]

If this is HiDPI, then you need to have a correctly scaled graphics object.

In ModernizePicture, you could do this by modifying the Graphics.ScaleX and ScaleY properties, but I think the easiest way to get a picture set up properly is to use the Window.BitmapForCaching method. Use this in place of New Picture.

Dim result As Picture = Self.BitmapForCaching(input.Width, input.Height)

More information here: HiDPI Support

Hi Paul

Thanks for collaborating. Unfortunatly the BitmapForCaching method did not work. I read the help at and noticed that ther is a possibilty to just turn HiDPI off in the shared build settings. I went with this option. May not be best practice, but I’m in need of time and it’s not the intention to show images on Windows or other controls.