Code example for ColorMatrix

Methods: setScale

0
     * 主要对于ColorMatrix,需要将其包装成ColorMatrixColorFilter对象,再传给Paint对象 
     *  
     * 同样的,ColorMatrix提供给我们相应的方法,setSaturation()就可以设置一个饱和度 
     */ 
    private Bitmap ajustImage(){
        ColorMatrix cMatrix = new ColorMatrix();
//      int brightIndex = -25; 
//      int doubleColor = 2; 
//      cMatrix.set(new float[]{ 
//              doubleColor,0,0,0,brightIndex, //这里将1改为2则我们让Red的值为原来的两倍 
//              0,doubleColor,0,0,brightIndex,//改变最后一列的值,我们可以不改变RGB同道颜色的基础上,改变亮度 
//              0,0,doubleColor,0,brightIndex, 
//              0,0,0,doubleColor,0 
//      }); 
        //cMatrix.setSaturation(2.0f);//设置饱和度 
        cMatrix.setScale(2.0f, 2.0f, 2.0f, 2.0f);//设置颜色同道色彩缩放
        Paint paint = new Paint();
        paint.setColorFilter(new ColorMatrixColorFilter(cMatrix));
        return this.getDstImage(null, paint);
    } 
     
Experience pair programming with AI  Get Codota for Java