Android BitmapFactory.decodeResource读取原始图片装载成原始宽高Bitmap,Kotlin
fun getOriginalBitmap(resId: Int): Bitmap {
val options = BitmapFactory.Options()
options.inJustDecodeBounds = true
BitmapFactory.decodeResource(resources, resId, options)
val srcBmpWidth = options.outWidth
val srcBmpHeight = options.outHeight
val d = ContextCompat.getDrawable(applicationContext, R.mipmap.p1)
val bitmap = Bitmap.createBitmap(srcBmpWidth, srcBmpHeight, Bitmap.Config.ARGB_8888)
val canvas = Canvas(bitmap)
d?.setBounds(0, 0, srcBmpWidth, srcBmpHeight)
Android Drawable 转化成 Bitmap-CSDN博客文章浏览阅读1.8k次。/*Java代码 将Drawable转化为Bitmap */ Bitmap drawableToBitmap(Drawable drawable) { int width = drawable.getIntrinsicWidth(); int height = drawable.getIntrinsicHeight(); Bitmap bitmap
https://blog.csdn.net/zhangphil/article/details/43767535