Conversion between pixels and millimeters
The conversion also needs to know another parameter: DPI (How many points per inch)
Elephant prime number/DPI = inches
Inches x 25.4 = millimeters
There is a common method for display devices, whether they are printers or screens.
First use getdevicecaps (device handle, logpixelsx)
Or
Getdevicecaps (device handle, logpixelsy) obtains the number of devices per inch
Recorded as: Px and Py
1 inch equals 25.4
The formula for converting millimeters into pixels is
Horizontal conversion: x * Px/25.4
Vertical conversion: y * PY/25.4
Pixel conversion to mm x * 25.4/PX
InProgramWrite in
Mycontrol. Height: = 10 {mm} * pixelsperinch * 10 Div 254;
The numerator and denominator multiply by 10 to convert the floating point operation into an integer operation, which is more efficient.
Display parameters available in Javascript
Screen.
Availheight: gets the height of the operating area of the System screen, excluding the Microsoft Windows taskbar.
Availwidth: Obtain the operating area width of the System screen and exclude the Windows taskbar.
Bufferdepth is used to set or obtain the number of bits per pixel used for the off-screen bitmap buffer color.
Colordepth gets the number of bits per pixel of the color used for the target setting or buffer.
Devicexdpi is used to set or obtain the number of points per inch (DPI) at the system screen level.
Deviceydpi is used to set or obtain the value of the number of points (DPI) perpendicular to the System screen per inch.
Fontsmoothingenabled: Gets whether the option of rounding the font corners of the screen is enabled in the display settings of the control panel.
Height to obtain the vertical resolution of the screen.
Logicalxdpi is used to obtain the regular value of the number of points per inch (DPI) at the system screen level.
Logicalydpi obtains the general value of the system screen vertical point per inch (DPI.
Updateinterval sets or obtains the update interval of the screen.
Width to obtain the vertical resolution of the screen.
The DPI calculated by standard resolutions such as 1024x768 or 800x600 is a constant: 96. Therefore, the relationship between the calculated millimeters and pixels is approximately equal to a constant:
Basically, 1mm is about 3.78 pixels.