问题描述
可可图大小(宽度和高度)以点为单位指定,这些点在《 OS X可可图指南》文档中的定义如下:
Cocoa drawing sizes (widths & heights) are specified in points which are defined as follows in the OS X Cocoa Drawing Guide documentation:
据此我知道一点是物理距离.因此,例如,如果我的屏幕是20英寸宽,则可以使用20 x 72 = 1440个水平宽度(以 points 为单位).换句话说,一个点与设备的分辨率无关.
I understand from this that a point is a physical distance. So if my screen is 20 inches wide (for example) I would have 20 x 72 = 1440 points of horizontal width in points to work with. In other words, a point is independent of the resolution of the device.
事实并非如此...
使用窗口宽度作为测试的简单可可应用程序显示:1)当我的分辨率设置为1680x1050时,它将需要1680个点的宽度来跨越屏幕宽度2)同样,如果我将分辨率更改为2560x1440,则需要2560 points 点的窗口宽度来跨越屏幕宽度
A simple cocoa application using window width as a test shows that:1) when my resolution is set to 1680x1050 it will take a width of 1680 points to span the width of the screen2) similarly, if I change my resolution to 2560x1440 it will take a window width of 2560 points to span the width of the screen
高分辨率指南" Apple文档中的声明(以自相矛盾的方式)还令人困惑:
Also confusing (in a contradictory way) is the statement made in the High Resolution Guidelines Apple Document that:
以上测试似乎表明当我的显示分辨率设置为1680x1050时,我的用户空间为1680x1050.如果每个用户点有4个像素,那么这将指向2倍的有效真实"分辨率(1680x1050)= 3360x2100,这比我的13英寸视网膜Macbook pro 2560x1600的原始分辨率还要高.
The above tests seem to indicate that I have a user space of 1680x1050 when my display resolution is set to 1680x1050. If there are 4 pixels per user point then this would point to an effective "real" resolution of 2 times (1680x1050) = 3360x2100 which is more than the native resolution my 13 inch retina macbook pro of 2560x1600.
推荐答案
点是抽象的虚拟坐标系.目的是您通常设计并编写绘图代码以按点工作,并且将与人的视觉大致保持一致,从而补偿不同的物理显示像素密度以及显示器和用户眼睛之间的通常距离.
Points are an abstract, virtual coordinate system. The intent is that you usually design and write drawing code to work in points and that will be roughly consistent to human vision, compensating for different physical display pixel densities and the usual distance between the display and the user's eyes.
点与物理距离单位(英寸,厘米等)或物理显示像素没有可靠的关系.
Points do not have a reliable relationship to either physical distance units (inches, centimeters, etc.) or physical display pixels.
对于屏幕显示,至少有三个不同的测量值.例如,Retina MacBook Pro的屏幕具有2880x1800物理像素.在默认模式下,它映射到1440x900点,因此每个点都是2x2像素的正方形.这就是为什么这种系统上的窗口具有与非Retina MacBook Pro上相同窗口相同的视觉尺寸的原因,非MacBook Pro的屏幕具有1440x900物理像素映射到1440x900点.窗口以点为单位,因此占据了屏幕空间的相同部分.但是,在Retina显示屏上,有更多的像素可以提供更好的细节.
For screen displays, there are at least three different measurements. For example, the screen of a Retina MacBook Pro has 2880x1800 physical pixels. In the default mode, that's mapped to 1440x900 points, so each point is a 2x2-pixel square. That's why a window on such a system has the same visual size as the same window on a non-Retina MacBook Pro with a screen with 1440x900 physical pixels mapped to 1440x900 points. The window is measured in points and so takes up the same portion of the screen real estate. However, on the Retina display, there are more pixels allowing for finer detail.
但是,可能还有另一层复杂性.您可以将该Retina系统配置为以一些细节为代价在屏幕上显示更多内容.您可以选择1920x1200点的显示模式.在那种模式下,渲染完成到3840x2400像素的后缓冲区.这样可以进行更高细节的渲染,但可以使数学保持简单;点仍然映射到2x2像素的正方形. (此简单的数学方法还避免了在绘制邻接的位图图像时出现接缝问题.)但是3840x2400大于显示硬件中的物理像素数量.因此,当在屏幕上实际绘制到实际2880x1800像素时,该后缓冲区将按比例缩小.这会从后缓冲中丢失更多的[em> some 细节,但结果仍然比物理1920x1200屏幕或将1920x1200渲染比例放大到物理2880x1800屏幕更精细.
However, there is another layer of complexity possible. You can configure that Retina system to display more content on the screen at the cost of some of the detail. You can select a display mode of 1920x1200 points. In that mode, the rendering is done to a backbuffer of 3840x2400 pixels. That allows for rendering at a higher level of detail but keeps the math simple; points are still mapped to 2x2-pixel squares. (This simple math also avoids problems with seams when drawing abutting bitmap images.) But 3840x2400 is greater than the number of physical pixels in the display hardware. So, that backbuffer is scaled down when actually drawn on the screen to the physical 2880x1800 pixels. This loses some of the higher detail from the backbuffer, but the results are still finer-detailed than either a physical 1920x1200 screen or scaling up a 1920x1200 rendering to the physical 2880x1800 screen.
因此,对于此配置:
屏幕尺寸单位:1920x1200
内存中像素的后缓冲:3840x2400
显示硬件中的物理像素:2880x1800
So, for this configuration:
Screen size in points: 1920x1200
Backbuffer in in-memory pixels: 3840x2400
Physical pixels in display hardware: 2880x1800
当然可以进行其他配置:
Other configurations are, of course, possible:
以点为单位的屏幕尺寸:2880x1800
像素的后缓冲:2880x1800
物理像素:2880x1800
一切都会变得很小,但是您将能够在屏幕上容纳很多东西(例如,多行文本).
Screen size in points: 2880x1800
Backbuffer in pixels: 2880x1800
Physical pixels: 2880x1800
Everything will be teeny-tiny but you'll be able to fit a lot of stuff (e.g. many lines of text) on the screen.
以点为单位的屏幕尺寸:1280x800
像素的后缓冲:2560x1600
物理像素:2880x1800
实际上,这将使所有内容(文本,按钮等)显得更大,因为映射到相同物理像素的点变少了.每个点在物理上都会更大.但是请注意,每个点仍然映射到后缓冲区中的2x2像素正方形.和以前一样,硬件将后缓冲区缩放到物理显示.这次,它的缩放比例有所提高,而不是缩小. (这种缩放比例与非Retina LCD显示器在选择像素比物理显示器少的模式时发生的事情是一样的.显然,LCD不能更改其具有的物理像素数,因此分辨率不同通过扩展后缓冲来完成.)
Screen size in points: 1280x800
Backbuffer in pixels: 2560x1600
Physical pixels: 2880x1800
This will actually make everything (text, buttons, etc.) appear larger since there are fewer points mapped to the same physical pixels. Each point will be physically larger. Note, though, that each point still maps to a 2x2-pixel square in the backbuffer. As before, the backbuffer is scaled by the hardware to the physical display. This time it's scaled up slightly rather than down. (This scaling is the same thing as happens on a non-Retina LCD display when you select a mode with fewer pixels than the physical display. Obviously, an LCD can't change the number of physical pixels it has, so the different resolution is accomplished by scaling a backbuffer.)
等等.
这篇关于在可可绘图中与屏幕分辨率交互时了解点和用户空间的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!