如何压缩图像大小? [英] How to compress image size?

查看:38
本文介绍了如何压缩图像大小?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想使用android相机api以低分辨率捕获图像,但是当我捕获图像时,它将采用设备相机的默认分辨率.所以我想在捕获时以低分辨率或小尺寸捕获图像或如何压缩在android中将大图像变成小尺寸?

I want to capture image in low resolution using android camera api but when I captured image it will take default resolution of device camera.So I want to capture image in low resolution or small size at time of capture or how can I compress big image into small size in android?

推荐答案

您可以使用捕获的图像创建位图,如下所示:

You can create bitmap with captured image as below:

Bitmap bitmap = Bitmap.createScaledBitmap(capturedImage, width, height, true);

在这里您可以指定要设置到 ImageView 的位图的宽度和高度.高度和宽度也可以根据设备的屏幕dpi设置,通过编程读取不同设备的屏幕dpi.

Here you can specify width and height of the bitmap that you want to set to your ImageView. The height and width you can set according to the screen dpi of the device also, by reading the screen dpi of different devices programmatically.

这篇关于如何压缩图像大小?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆