美文网首页
图片变灰色处理

图片变灰色处理

作者: Nj_第一批老去的90后 | 来源:发表于2017-05-22 14:42 被阅读166次
    
    /**
    * 图片变灰处理(多次处理,色彩会反复)
    *
    * @param bitmap
    * @return
    */
    public static final Bitmap createBitmap(Bitmap bitmap) {
        int width = bitmap.getWidth();
        int height = bitmap.getHeight();
    
        Bitmap faceIconGreyBitmap = Bitmap
                .createBitmap(width, height, Bitmap.Config.ARGB_8888);
    
        Canvas canvas = new Canvas(faceIconGreyBitmap);
        Paint paint = new Paint();
        ColorMatrix colorMatrix = new ColorMatrix();
        colorMatrix.setSaturation(0);
        ColorMatrixColorFilter colorMatrixFilter = new ColorMatrixColorFilter(
                colorMatrix);
        paint.setColorFilter(colorMatrixFilter);
        canvas.drawBitmap(bitmap, 0, 0, paint);
        return faceIconGreyBitmap;
    }
    

    相关文章

      网友评论

          本文标题:图片变灰色处理

          本文链接:https://www.haomeiwen.com/subject/jlobxxtx.html