比方说,我如何获取现有的位图
Bitmap bm = BitmapFactory.decodeResource(getResources(), R.drawable.somebitmap);
并编写一个返回位图的黑暗版本的方法?
private Bitmap darkenBitMap(Bitmap bm) { }
到目前为止,我一直在尝试使用Paint和Canvas但没有结果.
我终于明白了.希望它可以帮助别人.
private Bitmap darkenBitMap(Bitmap bm) { Canvas canvas = new Canvas(bm); Paint p = new Paint(Color.RED); //ColorFilter filter = new LightingColorFilter(0xFFFFFFFF , 0x00222222); // lighten ColorFilter filter = new LightingColorFilter(0xFF7F7F7F, 0x00000000); // darken p.setColorFilter(filter); canvas.drawBitmap(bm, new Matrix(), p); return bm; }