0

I'm asking this question after much reading. I've always heard that dpi is for printers, but when it comes to screen now, they are also talking about dpi. Are they referring to ppi?

Now, what is really resolution, for me its the the number of pixels each dimension can display, e.g. 800x600 means 800 pixesl on width and 600 pixels on the height, but at some places I'm seeing that they are referring to resolution as dpi.

I'm trying to understand this concept well because its very important in Android, like in this article,

For example, say an icon is intended to be 0.5x0.5 in when rendered on a screen. Next, the image must be created at the largest density supported, or as a scalable vector graphic. Best practice is to support the maximum density, which currently is xxhdpi at 480 dpi. At 480 dpi, a 0.5x0.5 in image converts to 240x240 px.

So it is referring dpi as ppi actually if I understand?

So far what I've understood is that different pixels may render different number of pixels. This is why we don't use pixels as measurement unit. Instead we use dp, where a dp is one pixel on 160 dpi device (again the confusion about dpi & ppi)

Can someone clear this big confusion or direct me to an article that may clear it

4

2 回答 2

2

伴侣,分辨率为 800 X 600 意味着屏幕有 480,000 个像素点将用于渲染屏幕(这通常与显示器的尺寸相混淆)。DPI 或 PPI 表示每英寸的点数/点数,这是屏幕密度的度量。

因此,仅给出分辨率,除非密度参数也可用,否则无法确定显示的实际长度。因此,800 X 600 分辨率具有 480,000 个像素点,并且此设备的密度为 480 dpi。

所以屏幕的宽度

=沿其宽度/密度的像素点数

= 800/480

= 1.67 英寸

相似地,

高度 = 600/480 =1.25 英寸

如果 800X600 分辨率设备的密度为 160 dpi,则其尺寸将发生巨大变化。以下计算在 160 dpi 上计算 800X600 的高度/宽度。将这两个值与 480 dpi 以上的计算进行比较。

屏幕宽度=沿其宽度的像素点数/密度

= 800/160

= 5.0 英寸

相似地,

高度 = 600/160 =3.75 英寸

这就是缩放图像以最适合屏幕的原因在框架化的 android 环境中是一个如此复杂的问题。但是,我喜欢 android!

希望这可以帮助!任何有东西要添加/删除的人。修改这个答案是最受欢迎的。

于 2014-04-25T06:15:34.037 回答
1
  1. dpi(每英寸点数)== ppi(每英寸像素数)
  2. 您还在谈论DisplayMetrics.density,它为您提供了dp测量单位的乘数。
  3. 还有DisplayMetrics.scaledDensity一个也考虑了用户选择的文本大小。

简而言之,dpunit 旨在为您提供有关屏幕上对象大小的一些安全性。160dp 应该在任何屏幕上代表一英寸。为了实现这一点,您必须将维度乘以DisplayMetrics.densityor DisplayMetrics.scaledDensity

也就是说,如果你在代码中这样做。对于Layouts,您只需输入 aView的尺寸dp并让 Android 框架为您处理。

于 2014-04-25T06:17:16.977 回答