public static double MillimeterToPixel_X(double length) //length是毫米,1厘米=10毫米
{
System.Windows.Forms.Panel p = new System.Windows.Forms.Panel();
System.Drawing.Graphics g = System.Drawing.Graphics.FromHwnd(p.Handle);
//1英寸=25.4mm=96DPI,那么1mm=96/25.4DPI
return (((double)g.DpiX / 25.4) * (double)length);
}
public static double MillimeterToPixel_Y(double length) //length是毫米,1厘米=10毫米
{
System.Windows.Forms.Panel p = new System.Windows.Forms.Panel();
System.Drawing.Graphics g = System.Drawing.Graphics.FromHwnd(p.Handle);
//1英寸=25.4mm=96DPI,那么1mm=96/25.4DPI
return (((double)g.DpiY / 25.4) * (double)length);
}