How do Dpi Points relate to Pixels for any display my application is running on?
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);
}
}
Do I now have all of the information I need?
Can I use any of the information above to find out just how long 1200 pixels is?
DPI literally stands for "Dots Per Inch" - where dots==pixels. So to determine how long 1200 pixels is:
int inchesLong = (1200 / e.Graphics.DpiX);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With