图片黑白化
2023-01-24 09:16:15 最后更新
//本源码由2669354498提供制作
mian.iyu
sbp("%iApp/Userimg/icon_iapp.png",bitmap)
call(back, "mjava", "photo_outcolor.toGrayScale", bitmap)
us(1,"background",back)
photo_outcolor.mjava
import android.app.*;
import android.graphics.*;
import android.os.*;
import android.widget.*;
//本源码由2669354498提供制作。
public static Bitmap toGrayScale(Bitmap bmpOriginal) {
  int width, height;
  height = bmpOriginal.getHeight();
  width = bmpOriginal.getWidth();
  Bitmap bmpGrayScale = Bitmap.createBitmap(width, height, Bitmap.Config.RGB_565);
  Canvas c = new Canvas(bmpGrayScale);
  Paint paint = new Paint();
  ColorMatrix cm = new ColorMatrix();
  cm.setSaturation(0);
  ColorMatrixColorFilter f = new ColorMatrixColorFilter(cm);
  paint.setColorFilter(f);
  c.drawBitmap(bmpOriginal, 0, 0, paint);
  return bmpGrayScale;
}