gpt4 book ai didi

android - canvas.drawBitmap-软件渲染不支持硬件位图

转载 作者:行者123 更新时间:2023-12-02 12:58:33 26 4
gpt4 key购买 nike

简单的乐趣

fun getCircleBitmap(bitmap: Bitmap, recycle: Boolean): Bitmap {
val paint = Paint()
paint.isAntiAlias = true
paint.color = Color.WHITE
paint.xfermode = PorterDuffXfermode(PorterDuff.Mode.SRC_IN)

val rect = Rect(0, 0, bitmap.width, bitmap.height)
val rectF = RectF(rect)

val output = Bitmap.createBitmap(bitmap.width, bitmap.height, Bitmap.Config.ARGB_8888)

val canvas = Canvas(output)
canvas.drawARGB(0, 0, 0, 0)
canvas.drawOval(rectF, paint)
canvas.drawBitmap(bitmap, rect, rect, paint)

if (recycle) {
bitmap.recycle()
}

return output
}

Taget API29。仿真器API28。Kotlin1.3.40。
大约一个月前,这种乐趣奏效了。但是现在出现在“canvas.drawBitmap”错误“软件渲染不支持硬件位图”。尝试android:hardwareAccelerated =“false”-相同的错误。为什么?

最佳答案

所以,我的解决方案:

fun getCircleBitmapDrawable(bitmap: Bitmap): RoundedBitmapDrawable {
val round = RoundedBitmapDrawableFactory.create(context.resources, bitmap)
round.isCircular = true
round.setAntiAlias(true)

return round
}

关于android - canvas.drawBitmap-软件渲染不支持硬件位图,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56723107/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com