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

相关推荐
TeleostNaCl1 小时前
如何安装 Google 通用的驱动以便使用 ADB 和 Fastboot 调试(Bootloader)设备
android·经验分享·adb·android studio·android-studio·android runtime
fatiaozhang95272 小时前
中国移动浪潮云电脑CD1000-系统全分区备份包-可瑞芯微工具刷机-可救砖
android·网络·电脑·电视盒子·刷机固件·机顶盒刷机
低调小一3 小时前
Swift 语法学习指南 - 与 Kotlin 对比
微信·kotlin·swift
2501_915918413 小时前
iOS 开发全流程实战 基于 uni-app 的 iOS 应用开发、打包、测试与上架流程详解
android·ios·小程序·https·uni-app·iphone·webview
lichong9513 小时前
【混合开发】vue+Android、iPhone、鸿蒙、win、macOS、Linux之dist打包发布在Android工程asserts里
android·vue.js·iphone
Android出海3 小时前
Android 15重磅升级:16KB内存页机制详解与适配指南
android·人工智能·新媒体运营·产品运营·内容运营
一只修仙的猿3 小时前
毕业三年后,我离职了
android·面试
编程乐学4 小时前
安卓非原创--基于Android Studio 实现的新闻App
android·ide·android studio·移动端开发·安卓大作业·新闻app
雅雅姐5 小时前
Android14 init.rc中on boot阶段操作4
android
fatiaozhang95275 小时前
中国移动中兴云电脑W132D-RK3528-2+32G-刷机固件包(非原机制作)
android·xml·电脑·电视盒子·刷机固件·机顶盒刷机