C#的gdi绘图的时候,不同的地方可能会用不同的单位去表示,其意义会跟随当前graphics的设置变化。
用下面的调用,获取当前graphics使用的单位。
GraphicsUnit unit = graphics.PageUnit;
public enum GraphicsUnit
{
World,
Display,
Pixel,
Point,
Inch,
Document,
Millimeter
}
字段说明:
Display 1
指定显示设备的度量单位。 通常,视频显示使用的单位是像素;打印机使用的单位是 1/100 英寸。
Document 5
将文档单位(1/300 英寸)指定为度量单位。
Inch 4
将英寸指定为度量单位。
Millimeter 6
将毫米指定为度量单位。
Pixel 2
将设备像素指定为度量单位。
Point 3
将打印机点(1/72 英寸)指定为度量单位。
World 0
将世界坐标系单位指定为度量单位。
然后根据需要进行转换。