安卓:使用不同的像素密度图像的目的是什么?目的、密度、像素、图像

2023-09-06 15:59:08 作者:矜暮

我知道使用不同的DPI图像是Android的一个相当普遍的做法。但我实在不明白它的目的,为什么我们不能只用一个超巨大的图像,然后在程序扩展呢?我知道我们可能需要做额外的计算,如果我们在不同的DPI没有图像,但除此之外,是有其他原因?

I know using images with different DPI is a fairly common practice in Android. But I don't really see the purpose of it, why can't we just use a ultra huge image and then scale it in the program? I know we probably need to do extra calculation if we don't images in different DPI, but besides that, is there's any other reason?

推荐答案

Tim和公元有你正确的推理。下面是,如果你想看到的东西重新调整,或者在正确的大小绘制之间的比较的直观的例子。效果总是更明显,如果有非常小的细节。

Tim and a.d. have the correct reasoning for you. Here's a visual example if you'd like to see a comparison between something rescaled or drawn at the correct size. Effects are always more noticeable if there are very small details.

首先是一个大的200×200(我们称之为xhdpi),第二个是简单地重新取样适用于mdpi(75x75)相同的图像。三是重新设计,以同样的规格,但在75x75开始。正如你所看到的,在第二个文本显著模糊,并有沿的地方重新调整形状边缘的一些文物。

The first is a large 200x200 (we'll call it xhdpi), and the second is simply the same image resampled for mdpi (75x75). The third is redesigned to the same specs but starting at 75x75. As you can see, the text on the second is significantly blurred, and there are some artifacts along the edges of the shapes where rescaled.

 
精彩推荐