jingwood / d2dlib

A .NET library for hardware-accelerated, high performance, immediate mode rendering via Direct2D.
MIT License
234 stars 40 forks source link

High DPI support #29

Open jingwood opened 4 years ago

jingwood commented 4 years ago

Currently, only support a default DPI 96, there should be APIs available to support variable DPI settings.

Related to #26

jingwood commented 3 years ago

Added GetAPI and SetDPI method. https://github.com/jingwood/d2dlib/commit/ec1cd27df6094e5b041415a607343d27f36acc23

HubKing commented 2 years ago

What is the correct usage of this? There seems to be no documentation.

My monitor is set to use 200% system DPI, and I had set the form's AutoScaleMode to Dpi. When I tried to draw a bitmap on a D2DControl by fitting the control and with correct aspect ratio, the image was big and clipped (only the second quadrant was showing). I kind of thought it could be some sort of DPI issue, but I could know how to fix it. So, I came here to ask if this is a bug, and saw this post.

With GetDPI, I get my monitor's DPI, which was 192/192. After seeing "Currently, only support a default DPI 96", I called SetDPI(96,96) and now the image looked correctly. But is this the correct way? Is that what you recommend that I should do in my situation?