简体   繁体   English

Android图像捕获和缩放

[英]Android image capturing and scaling

I am using the Camera activity to capture the JPEG image. 我正在使用Camera活动来捕获JPEG图像。 After image is saved and the controll is returned back to my application activity I would like to to determine the captured JPEG image dimensions without loading the whole image into memory via Bitmap object - can it be easily done somehow? 保存图像并将控件返回到我的应用程序活动后,我想确定捕获的JPEG图像尺寸,而不是通过Bitmap对象将整个图像加载到内存中 - 它能以某种方式轻松完成吗?

Is there any class, which reads the JPEG header and give me such information? 是否有任何类,它读取JPEG标题并给我这样的信息? I would like to avoid OOM conditions - but might be it is not a problem to load the whole image into memory - is it? 我想避免OOM条件 - 但是将整个图像加载到内存中可能不是问题 - 是吗?

After knowing the dimensions I would like to use BitmapFactory to scale the image. 知道尺寸后,我想使用BitmapFactory来缩放图像。

Thanks a lot 非常感谢

Kind Regards, 亲切的问候,

STeN 斯登

Perhaps a work-around (see 2nd approach) by setting the quality? 也许通过设定质量来解决 (见第2种方法)?

bmp.compress(CompressFormat.JPEG, 75, pfos); bmp.compress(CompressFormat.JPEG,75,pfos);

You would have to do a trial run to see what size the quality gets you though... 你必须进行试运行才能看到质量达到什么尺寸......

*The first approach creates a log file to get the width and height but not sure if you wanted the extra step of looking at a log file. *第一种方法创建一个日志文件来获取宽度和高度,但不确定是否需要额外的步骤来查看日志文件。

您可以使用ExifInterface类来读取图像的宽度和高度。

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

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