首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 移动开发 > Android >

android替图片去色,返回灰度图片

2012-09-09 
android为图片去色,返回灰度图片就是大家喜闻乐见的图片去色,返回黑白的图片,具体的方法就是为bitmap添加c

android为图片去色,返回灰度图片

就是大家喜闻乐见的图片去色,返回黑白的图片,具体的方法就是为bitmap添加colorFilter,废话不多说了,上代码:

 public static Bitmap getGreyImage(Bitmap old) {               int width, height;               height = old.getHeight();               width = old.getWidth();                   Bitmap new= Bitmap.createBitmap(width, height, Bitmap.Config.RGB_565);               Canvas c = new Canvas(old);               Paint paint = new Paint();               ColorMatrix cm = new ColorMatrix();               cm.setSaturation(0);               ColorMatrixColorFilter f = new ColorMatrixColorFilter(cm);               paint.setColorFilter(f);               c.drawBitmap(new, 0, 0, paint);               return new;           }   

?

热点排行