Android ImageView添加灰色濾鏡

// 顏色矩陣
private float[] colorArray = { 1, 0, 0, 0, 0,  //R決定紅色
                               0, 1, 0, 0, 0,  //G決定綠色
                               0, 0, 1, 0, 0,  //B決定藍色
                               0, 0, 0, 1, 0 };//A決定了透明度,若是有第五列決定偏移量

ColorMatrix matrix = new ColorMatrix();    
matrix.setSaturation(0);// 彩色0——>1加強
//matrix.set(colorArray); //設置顏色矩陣

ColorMatrixColorFilter filter = new ColorMatrixColorFilter(matrix);
imageview.setColorFilter(filter);

有圖有真相,上圖java

原網址:http://stackoverflow.com/a/14084398/1388881code

相關文章
相關標籤/搜索