且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何压缩图像大小?

更新时间:2023-02-13 22:27:55

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

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.