小编auu*_*jay的帖子

DPI图形屏幕分辨率像素WinForm PrintPageEventArgs

对于我的应用程序正在运行的任何显示,Dpi点与像素如何相关?

int points;
Screen primary;

public Form1() {
  InitializeComponent();
  points = -1;
  primary = null;
}

void OnPaint(object sender, PaintEventArgs e) {
  if (points < 0) {
    points = (int)(e.Graphics.DpiX / 72.0F); // There are 72 points per inch
  }
  if (primary == null) {
    primary = Screen.PrimaryScreen;
    Console.WriteLine(primary.WorkingArea.Height);
    Console.WriteLine(primary.WorkingArea.Width);
    Console.WriteLine(primary.BitsPerPixel);
  }
}
Run Code Online (Sandbox Code Playgroud)

我现在有我需要的所有信息吗?

我可以使用以上任何信息来找出1200像素有多长吗?

c# printing graphics dpi winforms

5
推荐指数
1
解决办法
1万
查看次数

标签 统计

c# ×1

dpi ×1

graphics ×1

printing ×1

winforms ×1