簡體   English   中英

C#繪制具有精度坐標的矩形。 怎么樣?

[英]C# drawing Rectangle with precision coordinates. How?

如何在C#中使用精度坐標繪制矩形?

例:

Rectangle test1 = new Rectangle(X, Y, Width, Height);

寬度高度值似乎必須是整數

是否有可能以某種方式給出矩形, 英寸尺寸的坐標

Rectangle test2 = new Rectangle(100, 50, 1.93inches, 0.52inches);

謝謝你的幫助。

您必須轉換知道英寸和像素之間的轉換,這取決於屏幕分辨率。 我想你可以這樣做:

Graphics graphics = this.CreateGraphics();
var dpiX = graphics.DpiX;
var dpiY = graphics.DpiY;
var rectangle = new Rectangle(100, 50, Math.Round(1.93 * dpiX), Math.Round(0.52 * dpiY));

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM