将图像每个点的rgb通道值取均值就得到R&B效果。
下面是详细代码:
//R&B public static Bitmap RandB(Bitmap bitmap) { int mBitmapWidth = 0; int mBitmapHeight = 0; mBitmapWidth = bitmap.getWidth(); mBitmapHeight = bitmap.getHeight(); Bitmap bmpReturn = Bitmap.createBitmap(mBitmapWidth, mBitmapHeight, Bitmap.Config.ARGB_8888); int iPixel = 0; for (int i = 0; i < mBitmapWidth; i++){ for (int j = 0; j < mBitmapHeight; j++){ int curr_color = bitmap.getPixel(i, j); int avg = (Color.red(curr_color) + Color.green(curr_color) + Color.blue(curr_color)) / 3; if (avg >= 100){ iPixel = 255; }else{ iPixel = 0; } int modif_color = Color.argb(255, iPixel, iPixel, iPixel); bmpReturn.setPixel(i, j, modif_color); } } return bmpReturn; }效果如下:
效果图 原图
作者:qq_32353771 发表于2016/12/31 23:04:31 原文链接
阅读:71 评论:0 查看评论