Android获取原始图片Bitmap的宽高大小尺寸,Kotlin

Android获取原始图片Bitmap的宽高大小尺寸,Kotlin

Kotlin 复制代码
                    val options = BitmapFactory.Options()
                    options.inJustDecodeBounds = true

                    val decodeBmp = BitmapFactory.decodeResource(resources, R.mipmap.p1, options)
                    //此时,decode出来的decodeBmp宽高并不是原始图的宽高。
                    //options里面的宽高才是原始图片的宽高
                    val bmpWidth = options.outWidth
                    val bmpHeight = options.outHeight
                    Log.d(TAG, "原始图片宽高 ${bmpWidth} ${bmpHeight}")

下面的代码是告诉Android,只解析宽高尺寸,不decode原始图片文件:

Kotlin 复制代码
                    val options = BitmapFactory.Options()
                    options.inJustDecodeBounds = true

然后从options里面读原始图片的宽高尺寸。

Android大图片之缩略图,以及对原图按照指定宽高裁剪成缩略图-CSDN博客文章浏览阅读5.3k次。《Android大图片之变换缩略图,以及对原始大图片按照指定宽、高裁剪成缩略图》在Android的ImageView加载图像资源过程中,出于性能和内存开销的需要,有时候需要把一个原始的超大图片按照一定比例等比例缩放成较小的缩略图,或者需要把原始的超大图片,裁剪成指定宽高值的较小图片,针对这种开发需求,可以使用Android SDK自身提供的工具类:ThumbnailUtils完成。https://blog.csdn.net/zhangphil/article/details/47857495Android ByteBuffer Bitmap byte[] convert,Kotlin_bitmap bytebuffer-CSDN博客文章浏览阅读593次。Java代码 将Drawable转化为Bitmap */ Bitmap drawableToBitmap(Drawable drawable) { int width = drawable.getIntrinsicWidth();/*Java代码 将Drawable转化为Bitmap */ Bitmap drawableToBitmap(Drawable drawable) { int width = drawable.getIntrinsicWidth();_bitmap bytebufferhttps://blog.csdn.net/zhangphil/article/details/132699647Android Drawable 转化成 Bitmap-CSDN博客文章浏览阅读1.8k次。/*Java代码 将Drawable转化为Bitmap */ Bitmap drawableToBitmap(Drawable drawable) { int width = drawable.getIntrinsicWidth(); int height = drawable.getIntrinsicHeight(); Bitmap bitmaphttps://blog.csdn.net/zhangphil/article/details/43767535

相关推荐
CIb0la3 小时前
安卓16系统升级后(Google pixel 8/8pro 9/9pro xl 10/10pro xl)救砖及Root方法
android·运维·生活
Ya-Jun4 小时前
项目实战Now in Android:项目模块说明
android·架构·kotlin
@Aurora.4 小时前
【MySQL】基础
android
ooooooctober5 小时前
PHP代码审计框架性思维的建立
android·开发语言·php
q***82915 小时前
图文详述:MySQL的下载、安装、配置、使用
android·mysql·adb
沐怡旸6 小时前
【底层机制】Ashmem匿名共享内存:原理与应用深度解析
android·面试
用户2018792831677 小时前
Activity结束动画与System.exit(0)的黑屏之谜
android
Proud lion8 小时前
Apipost 脚本高频场景最佳实践:搞定接口签名验证、登录令牌刷新、动态参数生成等
android
介一安全8 小时前
【Frida Android】实战篇5:SSL Pinning 证书绑定绕过 Hook 教程(二)
android·网络安全·逆向·安全性测试·frida
2501_937193148 小时前
PLB-TV 影视!无广告 + 4K 高清
android·源码·源代码管理·机顶盒