对于我的应用程序正在运行的任何显示,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);
  }
}

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

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

最佳答案

DPI实际代表“每英寸点数”-其中点==像素。因此,确定1200像素有多长时间:

int inchesLong = (1200 / e.Graphics.DpiX);

关于c# - DPI图形屏幕分辨率像素WinForm PrintPageEventArgs,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/5122050/

10-12 19:20