Best way to handle drawing in HiDPI

What’s the best way to handle the drawing (e.g. custom controls) in HiDPI mode?
I want to have pixel exact drawing for our custom controls.
Is it the best way to get the ScaleFactor reset the ScaleX and ScaleY to 1 and then multiply all values with the scalefactor?

Sample project

See screenshot below.

Code for the left side (normal drawing):

[code]Dim Width As Integer = 50
Dim Height As Integer = 10

g.ForeColor = &cff0000

Dim points(6) as Integer
points(1)=10
points(2)=5
points(3)=40
points(4)=40
points(5)=5
points(6)=60

g.DrawPolygon points

g.DrawLine 10, 50, Width, 50

g.FillRect 10, 60, 1, 1[/code]

Code for the right side (regarding the ScaleFactor):

[code]
Dim Scaling As Double = Self.ScaleFactor
Dim Width As Integer = 50
Dim Height As Integer = 10

g.ScaleX = 1
g.ScaleY = 1

g.ForeColor = &cff0000

Dim points(6) as Integer
points(1)=10 * Scaling
points(2)=5 * Scaling
points(3)=40 * Scaling
points(4)=40 * Scaling
points(5)=5 * Scaling
points(6)=60 * Scaling

g.DrawPolygon points

g.DrawLine 10 * Scaling, 50 * Scaling, Width * Scaling, 50 * Scaling

g.FillRect 10 * Scaling, 60 * Scaling, 1, 1[/code]

Any suggestions?

Keep doing what you’re doing. That’s the correct way to get 1px lines.

Thank you for your feedback Greg.
I just wanted to get sure that I’m on the right way ;-).

Not sure from the reply which is the correct way:

  1. Normal drawing
  2. The scalefactor way?

[quote=343845:@Ask Greiffenberg]Not sure from the reply which is the correct way:

  1. Normal drawing
  2. The scalefactor way?[/quote]

As “normal drawing” results in double-pixeled lines I gues the scalefactor way is the correct way ;-).

Right. If you want your drawing to look identical between 1x and 2x, you don’t need to do anything. OTOH, if you want to get truly 1px lines, set the ScaleX and ScaleY properties to 1.0 and do your drawing at twice the size.

You could just do this for the lines that you want to draw.