android - 如何压缩图像大小?

标签 android android-camera android-camera-intent image-compression

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

最佳答案

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

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

您可以在此处指定要设置为 ImageView 的位图的宽度和高度。您也可以根据设备的屏幕dpi设置高度和宽度,通过程序读取不同设备的屏幕dpi。

关于android - 如何压缩图像大小?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18545246/

相关文章:

java - ContentValue 不接受 BigDecimal

在 android Kitkat 中找不到 android.support.v4.content.FileProvider 类

android - Unity3d 中的 GCM 推送通知导致 gms.iid.InstanceID classnotfound

java - 我们如何创建 Dagger 2 的依赖关系图?

java - 谁有资料如何使用人脸检测相机 2 API?

java.lang.RuntimeException : Failure delivering result ResultInfo{who=null, request=131074,结果=-1,data=Intent {(有额外内容)}}到 Activity

Android - 拍照时 resultCode 永远不会是 RESULT_OK

android - Android 10 中的相机 Intent 权限

即使进行了所有优化,Android Emulator 也会延迟

Android 应用程序崩溃,无法理解 logcat 以查找原因