如何更改位图的不透明度?

如何更改位图的不透明度?,第1张

如何更改位图的不透明度

您也可以尝试使用BitmapDrawable代替

Bitmap
。如果这对您有用,则取决于您使用位图的方式…

编辑

正如评论者所问的那样,他如何使用alpha存储位图,下面是一些代码:

// lets create a new empty bitmapBitmap newBitmap = Bitmap.createBitmap(originalBitmap.getWidth(), originalBitmap.getHeight(), Bitmap.Config.ARGB_8888);// create a canvas where we can draw onCanvas canvas = new Canvas(newBitmap);// create a paint instance with alphaPaint alphaPaint = new Paint();alphaPaint.setAlpha(42);// now lets draw using alphaPaint instancecanvas.drawBitmap(originalBitmap, 0, 0, alphaPaint);// now lets store the bitmap to a file - the canvas has drawn on the newBitmap, so we can just store that one// please add stream handling with try/catch blocksFileOutputStream fos = new FileOutputStream(new File("/awesome/path/to/bitmap.png"));newBitmap.compress(Bitmap.CompressFormat.PNG, 100, fos);


欢迎分享,转载请注明来源:内存溢出

原文地址:https://54852.com/zaji/5010778.html

(0)
打赏 微信扫一扫微信扫一扫 支付宝扫一扫支付宝扫一扫
上一篇 2022-11-14
下一篇2022-11-14

发表评论

登录后才能评论

评论列表(0条)

    保存