像素与毫米的一致性
我正在做:
PhysicalParameters()
{
IntPtr DeskTopHWND = GetDesktopWindow();
IntPtr HDC = GetDC(DeskTopHWND);
int mmX = GetDeviceCaps(HDC, HORZSIZE);
int mmY = GetDeviceCaps(HDC, VERTSIZE);
int pxX = GetDeviceCaps(HDC, HORZRES);
int pxY = GetDeviceCaps(HDC, VERTRES);
ReleaseDC(DeskTopHWND, HDC);
double CoeffPIX_MM_X = 1.0 * mmX / pxX;
double CoeffPIX_MM_Y = 1.0 * mmY / pxY;
}
两者的结果都是 0.25
但我所看到的(MS Word' WysiWyg )应该约为 0.27
请解释一下主题。
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
典型的 LCD 显示器的密度为每英寸 96 像素。这转换为像素大小为 0.0104167 英寸或 0.265 毫米。
然而制造技术差异很大,因此像素尺寸不固定。不同的显示器和设备会有不同的间距和密度。所以简短的答案是像素和测量单位之间没有相关性。像素是您(或设备制造商)想要的任何尺寸。
参考文献:
Typical LCD monitors have a 96 pixel-per-inch density. This translates to a pixel size of 0.0104167 inch or 0.265 mm.
However manufacturing techniques differ drastically, and therefore pixel sizes are not fixed. Different monitors and devices will have difference pitches and densities. So the short answer is there is no correlation between pixels and a unit of measure. A pixel is whatever size you (or a manufacturer of a device) want it to be.
References:
每个设备的 HORZSIZE、HORZRES、VERTSIZE 和 VERTRES 都会略有不同。
Each device is going to have a slightly different HORZSIZE, HORZRES, VERTSIZE and VERTRES.
对 HORZSIZE 调用
GetDeviceCaps
实际上并不会获取显示器的水平尺寸 - 它会获取当前分辨率下 96 DPI 显示器的尺寸。当然,96 DPI 是默认值 - 用户可以设置系统 DPI,如果设置准确,您将获得适合显示器尺寸的正确值。不过,几乎没有人这样做 - 因此假设 96 DPI,您几乎总是会返回值。
Calling
GetDeviceCaps
for HORZSIZE doesn't actually get the horizontal size of your monitor - it gets what the size would be if it was a 96 DPI monitor at the current resolution.The 96 DPI is the default, of course - users can set the system DPI and if they set it accurately, you will get the right value back for the size of the monitor. Hardly anyone does this, though - so you will almost always get back values assuming 96 DPI.