Conversion Formula of pixels and millimeters

Source: Internet
Author: User

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.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.