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

相关推荐
IAM四十二9 天前
Google 端侧 AI 框架 LiteRT 初探
android·深度学习·tensorflow
CYRUS_STUDIO9 天前
手把手教你用 Chrome 断点调试 Frida 脚本,JS 调试不再是黑盒
android·app·逆向
Just丶Single9 天前
安卓NDK初识
android
编程乐学9 天前
网络资源模板--基于Android Studio 实现的咖啡点餐App
android·android studio·大作业·奶茶点餐·安卓移动开发·咖啡点餐
二流小码农9 天前
鸿蒙开发:基于node脚本实现组件化运行
android·ios·harmonyos
Wgllss10 天前
Kotlin+协程+FLow+Channel+Compose 实现一个直播多个弹幕效果
android·架构·android jetpack
续天续地10 天前
开箱即用的Kotlin Multiplatform 跨平台开发模板:覆盖网络/存储/UI/DI/CI工具链
ios·kotlin
顾林海10 天前
Android WebView内存释放全解析:从泄漏检测到彻底释放的实战指南
android·面试·性能优化
用户20187928316710 天前
🍕 披萨工厂奇遇记:Android APK打包之旅
android
程序猿陌名!10 天前
Android开发 原生设置-apps-里面隐藏应用信息
android