Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

C# Scaling GDI positions but not font size or line thickness

Tags:

c#

gdi+

I need to do a lot of drawing on a grid with spacing of 12.5 pixels X and 20 pixels Y (the PICA scale). The font needs to be a specific size and the lines need to still be one pixel thick. Currently I'm saving these values in floats and multiplying them (for example, text starting on row 3, column 6 is drawn as coords 2f*cx,5f*cy). I'd like to avoid all this unnecessary multiplication by using a scale transform, but unfortunately those affect the font size and line thickness as well. Is there a way to avoid this? Or would the compiler be silently doing this for me as the cx/cy values are constants?

like image 343
Patrick Avatar asked Dec 18 '25 04:12

Patrick


1 Answers

...also, Microsoft has left a little "hack" for us if you don't want lines to be scaled. Set the width of the line to 0px, and it will always be drawn a single pixel thick.

like image 161
Pedery Avatar answered Dec 20 '25 18:12

Pedery



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!