繁体   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