
您也可以尝试使用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);欢迎分享,转载请注明来源:内存溢出
微信扫一扫
支付宝扫一扫
评论列表(0条)