, 그것을
public 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;
}
을 시도, 당신은 당신의 코드를 그레이 스케일 이미지를 얻을 수 없다
Bitmap immutableBitmap = BitmapFactory.decodeResource(getResources(),
R.drawable.my_drawable);
Bitmap mutableBitmap = immutableBitmap.copy(Bitmap.Config.ARGB_8888, true);
//you have two bitmaps in memory, so clean up the mess a bit
immutableBitmap.recycle(); immutableBitmap=null;
Drawable d = new BitmapDrawable(mutableBitmap);
//mutate it
d.setColorFilter(new LightingColorFilter(color, lightenColor));
imageView.setImageDrawable(d);
"작동하지 않음", "작동하지 않음", "작동하지 않음".... ** 무엇이 작동하지 않습니까? 오류가 있습니까? 색상으로 표시됩니까? 또는 무엇을? –