Graphics g = this.DrawingPanel.CreateGraphics();
g.PageUnit = GraphicsUnit.Inch;
myPen.Width = 2 / g.DpiX;
Rectangle bmrt = new Rectangle(1, 1, 5, 3);
g.DrawLine(myPen, 1, 1, 6, 4);
g.DrawRectangle(myPen, bmrt);下面就像把 Rectangle bmrt 范围内的图保存为一个bmp,Graphics g中的其他区域就不要了或者有其他方法能够 new一个指定inch大小的bmp(注不是指定像素大小而是指定实际尺寸大小)谢谢
g.PageUnit = GraphicsUnit.Inch;
myPen.Width = 2 / g.DpiX;
Rectangle bmrt = new Rectangle(1, 1, 5, 3);
g.DrawLine(myPen, 1, 1, 6, 4);
g.DrawRectangle(myPen, bmrt);下面就像把 Rectangle bmrt 范围内的图保存为一个bmp,Graphics g中的其他区域就不要了或者有其他方法能够 new一个指定inch大小的bmp(注不是指定像素大小而是指定实际尺寸大小)谢谢
Graphics g = Graphics.FromImage(bm);
g.DrawRectangle(myPen, bmrt);
bm.Save("c:\\test.bmp",ImageFormat.Bmp);
bm.Dispose();
bm = null;
Rectangle bmrt = new Rectangle(1, 1, 5, 3); int inchWidth=bmrt.Width;
g.PageUnit = GraphicsUnit.Pixel;
int pixelWidth=bmrt.Width;pixelWidth/inchWidth 就可以得出一个比例了;
本质上就是比例问题,我现在就是这么转换的,但是比较麻烦如果能直接将Graphics中的某个Rectangle范围内的东西保存为bmp就方便了
http://www.netcsharp.cn/topictag-3.aspx