解决圆角bitmap保存时背景为黑色

时间:2022-04-17 16:47:21
1.
cropBitmap.copy(Bitmap.Config.ARGB_8888, true);
cropBitmap.compress(Bitmap.CompressFormat.PNG, 100, bos);//格式要为png
2.
private Bitmap getBitmap(Bitmap bitmap){
Bitmap newBitmap = Bitmap.createBitmap(bitmap.getWidth(), bitmap.getHeight(), Bitmap.Config.ARGB_8888);
Canvas canvas = new Canvas(newBitmap);
canvas.drawColor(Color.TRANSPARENT);
Paint paint = new Paint();
canvas.drawBitmap(bitmap, 0, 0, paint);
return newBitmap;
}


bug

A/Bitmap: Error, cannot access an invalid/free'd bitmap here!
A/libc: Fatal signal 6 (SIGABRT), code -6 in tid 12532 (isdom.chengguan)
Bitmap: Called getHeight() on a recycle()'d bitmap! This is undefined behavior!
bitmap.recycle();的问题
https://blog.csdn.net/sted_zxz/article/details/78262671