图片变为灰度
Bitmap bitmapSrc = BitmapManager.getBitmapResource(getResources(), R.drawable.bitmap); Bitmap buffer = Bitmap.createBitmap(bitmapSrc.getWidth(), bitmapSrc.getHeight(), Config.ARGB_8888); Canvas canvas = new Canvas(buffer); Paint paint = new Paint(); ColorMatrix colorMatrix = new ColorMatrix(); colorMatrix.setSaturation(0); ColorMatrixColorFilter colorMatrixFilter = new ColorMatrixColorFilter(colorMatrix); paint.setColorFilter(colorMatrixFilter); bufferCanvas.drawBitmap(bitmapSrc, 0, 0, paint); bufferCanvas.save();
android 图片灰度处理的处理
本文介绍了一种在Android中将彩色图片转换为灰度图片的方法。通过使用Bitmap和Canvas类,结合ColorMatrix来调整饱和度实现灰度效果。此过程涉及创建Bitmap实例,设置颜色矩阵并应用到画布上。
1399

被折叠的 条评论
为什么被折叠?



