Android 中如何获取照片的宽度和高度?
我想根据照片的路径获取照片(图像)的宽度和高度。有没有办法在不将照片加载到内存的情况下做到这一点?
I want to get the width and height of a photo (Image) given the path of the photo. Is there a way to do that without loading the photo to the memory?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
是的,只需按以下方式使用 BitmapFactory 即可:
此后选项的 outHeight 和 outWidth 字段将包含位图大小。您可以根据您访问文件的方式使用decodeStream或其他函数,只是不要忘记提供BitmapFactory.Options。
Yes, just use BitmapFactory for this in following way:
After this fields outHeight and outWidth of options will contain bitmap size. You can use decodeStream or other function, based on way you access the file, just don't forget to provide BitmapFactory.Options.
尝试此操作:
在使用下面的代码获取高度和宽度后
try this
after this use below code to get height and width: