在 Android 中以编程方式确定相机分辨率(即百万像素)
我正在2.2中开发一个Android应用程序,它使用Camera。 现在谁能告诉我“是否有可能以编程方式确定 Android 中的相机分辨率(以百万像素为单位)”
I am developing an Android application in 2.2, which uses Camera.
Now Can anyone tell me that "Is it possible to programmatically determine the Camera Resolution in Megapixels in Android"
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
如果您有相机对象,请尝试:
if you've got the camera object, try:
图像分辨率是什么意思?
分辨率是指图像中的像素数量。分辨率有时通过图像的宽度和高度以及图像中的像素总数来确定。例如,宽 2048 像素、高 1536 像素 (2048X1536) 的图像包含(乘以)3,145,728 像素(或 3.1 兆像素)。您可以将其称为 2048X1536 或 3.1 兆像素图像。随着相机拾取设备中百万像素的增加,您可以生成的最大尺寸图像也会增加。这意味着 5 兆像素相机能够比 3 兆像素相机捕获更大的图像。
示例:1936 x 1552 / 1024000 = 3 兆像素
What does image resolution mean?
Resolution refers to the number of pixels in an image. Resolution is sometimes identified by the width and height of the image as well as the total number of pixels in the image. For example, an image that is 2048 pixels wide and 1536 pixels high (2048X1536) contains (multiply) 3,145,728 pixels (or 3.1 Megapixels). You could call it a 2048X1536 or a 3.1 Megapixel image. As the megapixels in the pickup device in your camera increase so does the possible maximum size image you can produce. This means that a 5 megapixel camera is capable of capturing a larger image than a 3 megapixel camera.
Example: 1936 x 1552 / 1024000 = 3 Mega Pixels
尝试
在 android 清单中添加此权限
Try this
Add this permission in android manifest
您可以通过此方法获取支持的尺寸列表。
getSupportedSizes()
最大尺寸将为您提供相机分辨率(以像素为单位)。
编辑:
以防万一你不知道。
分辨率(像素)= 宽度 X 高度
You can you this to get the list of supported sizes.
getSupportedSizes()
The highest size would give you the camera resoultion in pixels.
EDIT:
Just in case you do not know.
Resolution in pixel = width X height
是的,这种方式对我有用。
这里还要注意一点, getPictureSize() 将返回具有不同高度和宽度的受支持尺寸的列表。要计算设备相机的像素分辨率,请获取最大高度和最大高度。尺寸列表中的宽度。
Yes, that way works to me.
One more note here, getPictureSize() will return a list of supported size with different heights and widths. To calculate the resolution in pixel of device's camera, please get the biggest height & width from the size list.