windows程序设计中一个不理解的地方

bobo_包子 2012-02-22 02:35:53
Within a Windows program you can use the GetDeviceCaps function to obtain the assumed resolution in dots per inch that the user selected in the Display applet of the Control Panel. To get these values—which in theory could be different if the video display doesn't have square pixels—you use the indices LOGPIXELSX and LOGPIXELSY. The name LOGPIXELS stands for "logical pixels," which basically means "not the actual resolution in pixels per inch."

The device capabilities that you obtain from GetDeviceCaps with the HORZSIZE and VERTSIZE indices are documented (as I indicated earlier) as "Width, in millimeters, of the physical screen" and "Height, in millimeters, of the physical screen." These should be documented as a "logical width" and a "logical height," because the values are derived from the HORZRES, VERTRES, LOGPIXELSX, and LOGPIXELSY values. The formulas are

Horizontal Size (mm) = 25.4 × Horizontal Resolution (pixels)/ Logical Pixels X (dots per inch)

Vertical Size (mm) = 25.4 × Vertical Resolution (pixels)/ Logical Pixels Y (dots per inch)

The 25.4 constant is necessary to convert from inches to millimeters.

This may seem backward and illogical. After all, your video display has a size in millimeters that you can actually measure with a ruler (at least approximately). But Windows 98 doesn't care about that size. Instead it calculates a display size in millimeters based on the pixel size of the display the user selects and also the resolution the user selects for sizing the system font. Change the pixel size of your display and according to GetDeviceCaps the metrical size changes. How much sense does that make?

It makes more sense than you might suspect. Let's suppose you have a 17-inch monitor. The actual display size will probably be about 12 inches by 9 inches. Suppose you were running Windows with the minimum required pixel dimensions of 640 by 480. This means that the actual resolution is 53 dots per inch. A 10-point font—perfectly readable on paper—on the screen would be only 7 pixels in height from the top of the A to the bottom of the q. Such a font would be ugly and just about unreadable. (Ask people who ran Windows on the old Color Graphics Adapter.)


PS:windows程序设计第五章的内容,上面的这段话不理解,望哪位理解了的出来帮忙解释下
...全文
204 12 打赏 收藏 转发到动态 举报
写回复
用AI写文章
12 条回复
切换为时间正序
请发表友善的回复…
发表回复
副组长 2012-02-23
  • 打赏
  • 举报
回复
有一个概念叫DPI(Dot per inch),就是每英寸多少点。早期的显示器72DPI,后来的都96或者更高,打印机300到1440吧?反正是高的多。这里指的是最大的能力。
这段文字说,Windows不管屏幕宽和高是多少,用DPI来度量显示质量。17英寸的显示器,你把它设置成1920*1024,每英寸的点子不就是多了吗?显示东西不就更细致吗?但是如果你把它设置成640*480,每英寸的点子不就少了吗?显示东西不就粗糙了吗?
一个10磅的文字,你把它印到纸上,能看的很清楚,为什么呢,打印机有1440的DPI,可以用好多的点子来表示这个字,所以清楚。但是在显示器上,由于你的DPI很低,只有7个像元可以用来表示这个文字,那不是很粗糙吗?
希望你能明白了。
cbzjzsb123 2012-02-22
  • 打赏
  • 举报
回复
我没有看懂你在说什么
schlafenhamster 2012-02-22
  • 打赏
  • 举报
回复
机器翻译结果:
“这似乎是落后的,不符合逻辑的。毕竟,你的视频显示有一个以毫米计的大小,你可以用实际皮尺来测量(至少大约)。但Windows 98不在乎,大小。相反,它在用户选择的显示器上,以毫米和分辨率的基础上,来计算显示器的像素大小,以及用户所选的系统字体大小。根据 GetDeviceCaps 所改变的大小来改变你的显示的像素大小。他们有多大意义呢
它比你怀疑有意义的多。让我们假设你有一个17寸显示器。实际显示尺寸可能会9乘12英寸。假设你要求的像素尺寸最小的640*480。这意味着实际的分辨率是53点每英寸。一个10点字体在纸上很好读,而屏幕上就只剩下7个像素高。从A顶部到q的底部。这样一个字体将丑陋并不能读。(问那些用老图形转接器跑窗口程序的人吧。)”
人工改了改。
长尾巴的悟空 2012-02-22
  • 打赏
  • 举报
回复
你能整个中文吗?
Eleven 2012-02-22
  • 打赏
  • 举报
回复
Bing的翻译:

这似乎很落后,不合逻辑。毕竟,您的视频显示在您可以实际用来衡量标尺 (至少大约) 的毫米的大小。但是,Windows 98 不关心这种尺寸。而是它计算以毫米为单位基于用户选择的显示的像素大小的显示大小,也该决议在用户选择的系统字体大小。更改您的显示,并根据 GetDeviceCaps 计量大小的变化的像素大小。多少都有意义?


更有意义不是您可能怀疑。让我们假设你有 17 英寸显示器。实际显示的大小可能会约 12 英寸 × 9 英寸。假设你运行 Windows 640 由 480 最低所需的像素尺寸。这意味着实际的分辨率是每英寸 53 点。10 点的字体 — — 纸上完全可读 — — 在屏幕上将是仅在高度从 A 的顶部到底部的 q 7 像素。这种字体将丑陋,只是无法读取。(问老彩色图形适配器运行 Windows 的人)。
bobo_包子 2012-02-22
  • 打赏
  • 举报
回复
[Quote=引用 3 楼 dream0411 的回复:]

1 feet = 12 inches

一块屏幕,4 feet宽,3 feet高,可显示640像素宽,480像素高,你算下每英寸可容纳约多少像素点?

640 / 48 = 13.333333333333333333333333333333333333333333;
480 / 36 = 13.333333333333333333333333333333333333333333;
[/Quote]

3Q 可是对这段话还是不能理解透彻
zero_226 2012-02-22
  • 打赏
  • 举报
回复
好长的一段英文。。。。。
zhxingway 2012-02-22
  • 打赏
  • 举报
回复

英文基础差,不好意思了。。
dream0411 2012-02-22
  • 打赏
  • 举报
回复
1 feet = 12 inches

一块屏幕,4 feet宽,3 feet高,可显示640像素宽,480像素高,你算下每英寸可容纳约多少像素点?

640 / 48 = 13.333333333333333333333333333333333333333333;
480 / 36 = 13.333333333333333333333333333333333333333333;
bobo_包子 2012-02-22
  • 打赏
  • 举报
回复
csdn这么萧条 顶
bobo_包子 2012-02-22
  • 打赏
  • 举报
回复
Now hook up a video projector to your PC. Let's say the projected video display is a 4 feet wide and 3 feet high. That same 640 by 480 pixel dimension now implies a resolution of about 13 dots per inch. It would be ridiculous to try displaying a 10-point font under such conditions.

这里的13又是如何得到的

16,472

社区成员

发帖
与我相关
我的任务
社区描述
VC/MFC相关问题讨论
社区管理员
  • 基础类社区
  • Web++
  • encoderlee
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

        VC/MFC社区版块或许是CSDN最“古老”的版块了,记忆之中,与CSDN的年龄几乎差不多。随着时间的推移,MFC技术渐渐的偏离了开发主流,若干年之后的今天,当我们面对着微软的这个经典之笔,内心充满着敬意,那些曾经的记忆,可以说代表着二十年前曾经的辉煌……
        向经典致敬,或许是老一代程序员内心里面难以释怀的感受。互联网大行其道的今天,我们期待着MFC技术能够恢复其曾经的辉煌,或许这个期待会永远成为一种“梦想”,或许一切皆有可能……
        我们希望这个版块可以很好的适配Web时代,期待更好的互联网技术能够使得MFC技术框架得以重现活力,……

试试用AI创作助手写篇文章吧