简体   繁体   English

如何在不知道 DPI 的情况下获得以英寸为单位的图像尺寸?

[英]How to get image dimension in inches without knowing the DPI?

I am new in android studio... I was searching as to how i can convert the dimensions of an image.我是 android 工作室的新手……我正在寻找如何转换图像的尺寸。 I found out that you need to get the DPI.我发现您需要获取 DPI。 My question is will it be possible to convert the unit of the image, to inches, without knowing the DPI??我的问题是是否可以在不知道 DPI 的情况下将图像单位转换为英寸? I tried using.getheight() and.getwidth() and it does give me the resolution, my problem is I need to convert this to inches.我尝试使用.getheight() 和.getwidth(),它确实给了我分辨率,我的问题是我需要将它转换为英寸。 Also, I saw this "dp" in imageview... I'm wondering wheter this has an equivalent value in inches that I can use to convert my image using ratio and proportion.另外,我在 imageview 中看到了这个“dp”......我想知道这是否有一个以英寸为单位的等效值,我可以用它来使用比率和比例转换我的图像。 Also found out bitmap.getdensity().还发现了 bitmap.getdensity()。 Does that get the actual dpi of the image??那会得到图像的实际dpi吗?

How to get image dimension in inches without knowing the DPI?如何在不知道 DPI 的情况下获得以英寸为单位的图像尺寸?

The question doesn't make much sense.这个问题没有多大意义。

In general, a digital image has no inherent size in inches, or an inherent DPI (dots per inch).通常,数字图像没有固有的英寸大小或固有的 DPI(每英寸点数)。 It has a size in pixels (or dots).它的大小以像素(或点)为单位。

The DPI is actually a property of the device you are displaying the image on. DPI 实际上是您在其上显示图像的设备的属性。 For an image that is displayed, you multiply the DPI of the device by the number of pixels in the height or width of the image to give you the height / width of the image on the screen .对于显示的图像,您将设备的 DPI 乘以图像的高度或宽度中的像素数,得到屏幕上图像的高度/宽度。 (If the image has been scaled, the scaling factor needs to be taken into account too.) (如果图像已经被缩放,也需要考虑缩放因子。)


In the case of images produced by digital cameras, the metadata of the image may include a "resolution height DPI" and "resolution width DPI".在数码相机产生的图像的情况下,图像的元数据可以包括“分辨率高度DPI”和“分辨率宽度DPI”。 I couldn't find a explanation of what these are supposed to mean, but I surmise that they are either我找不到这些应该是什么意思的解释,但我推测它们要么是

  • the physical resolution of the capture device (eg CCD), or捕获设备(例如 CCD)的物理分辨率,或
  • a value chosen by the creator of the image to give you their preferred image size.图像创建者选择的值,为您提供他们首选的图像大小。

Neither of these is of much relevance when you are displaying an image.当您显示图像时,这些都无关紧要。 (IMO) (海事组织)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM