当前位置: 移动技术网 > IT编程>开发语言>c# > C#实现将像素转换为页面单位的方法

C#实现将像素转换为页面单位的方法

2019年07月18日  | 移动技术网IT编程  | 我要评论

本文实例讲述了c#实现将像素转换为页面单位的方法。分享给大家供大家参考。具体实现方法如下:

using system;
using system.collections.generic;
using system.componentmodel;
using system.data;
using system.drawing;
using system.text;
using system.windows.forms;
using system.drawing.drawing2d;
namespace advanced_drawing
{
  public partial class form3 : form
  {
    public form3()
    {
      initializecomponent();
    }
    private void button1_click(object sender, eventargs e)
    {
      graphics g = this.creategraphics();
      g.pageunit = graphicsunit.inch;
      g.pagescale = 1;
      pointf[] bottomright = new pointf[] { new pointf(this.clientsize.width, this.clientsize.height) };
      g.transformpoints(coordinatespace.page, coordinatespace.device, bottomright);
      rectangle rect = new rectangle(0, 0, 10, 10);
      pen pen=new pen(color.red);
      g.drawrectangle(pen, rect);
    }
  }
}

希望本文所述对大家的c#程序设计有所帮助。

如对本文有疑问, 点击进行留言回复!!

相关文章:

验证码:
移动技术网