Pixel and Millimeter Conversion formula _ Application Tips

Source: Internet
Author: User
Tags constant
Pixel and millimeter conversions
The transformation also needs to know another parameter: DPI (how many dots per inch)
Number of pixels/DPI = inches
Number of inches * 25.4 = mm

There is a common way to display devices, whether they are printers or screens.
First with GetDeviceCaps (device handle, LOGPIXELSX)
Or
GetDeviceCaps (device handle, logpixelsy) gets the number of pixels per inch of the device
Note separately: px and py
One inch equals 25.4mm.
So the millimeter is converted to pixels in the formula
Conversion in horizontal direction: X * px/25.4
Conversion in vertical direction: Y * py/25.4
Pixel conversion to mm x * 25.4/px
Write this in the program
Mycontrol.height: = 10{mm} * pixelsperinch * 254 div;
The numerator and the denominator multiply by 10, and the floating-point operation is converted to an integer operation, which is more efficient


The display parameters that JavaScript can get

Screen.

Availheight Gets the work area height of the system screen, excluding the microsoft®windows® taskbar.
Availwidth Gets the operating area width of the system screen, excluding the Windows taskbar.
Bufferdepth Sets or gets the number of bits per pixel used for the outer bitmap buffer color of the screen.
ColorDepth gets the number of bits per pixel used for the target setting or buffer.
DEVICEXDPI Sets or gets the number of dots per inch (DPI) at the system screen level.
DEVICEYDPI Sets or gets the number of dots per inch (DPI) of the system screen vertically.
fontSmoothingEnabled gets whether the user has the option to enable rounded screen font corners in Display settings in Control Panel.
Height gets the vertical resolution of the screen.
LOGICALXDPI gets the regular number of dots per inch (DPI) of the system screen.
LOGICALYDPI gets the normal number of dots per inch (DPI) on the system screen.
UpdateInterval Sets or gets the update interval for the screen.
Width gets the vertical resolution of the screen.


Commonly used standard resolutions such as 1024x768 or 800x600 the DPI is computed as a constant: 96, so the calculated millimeter-pixel relationship is also approximately equal to a constant:
Basically 1 millimeters equals 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.