Android报错:java.lang.IllegalArgumentException: Software rendering doesn't support hardware bitmaps
java.lang.IllegalArgumentException: Software rendering doesn't support hardware bitmaps
需要把hardware属性的Bitmap转为普通的Bitmap:
if (Bitmap.Config.HARDWARE == bmp!!.config) {
Log.d(TAG, "Bitmap.Config.HARDWARE")
convert(bmp)
}
private fun convert(src: Bitmap?): Bitmap {
val w = src?.width
val h = src?.height
val picture = Picture()
val canvas = picture.beginRecording(w!!, h!!)
canvas.drawBitmap(src, 0f, 0f, null)
picture.endRecording()
return Bitmap.createBitmap(picture, w, h, Bitmap.Config.RGB_565)
}