Enhancing ImageView brightness programmatically

前端 未结 5 1952
不知归路
不知归路 2021-01-03 10:56

I have an android app in which I am increasing brightness of image with the code below. But this is very slow so does anyone knows a fast way to enhance image brightness of

5条回答
  •  别那么骄傲
    2021-01-03 11:08

    I have got a work around for this issue i made the image brighter and then shown it in an imageview. The code i used is given below:

    foto.setColorFilter(brightIt(100));//foto is my ImageView
    //and below is the brightIt func
    public static ColorMatrixColorFilter brightIt(int fb) {
    ColorMatrix cmB = new ColorMatrix();
    cmB.set(new float[] { 
        1, 0, 0, 0, fb,
        0, 1, 0, 0, fb,
        0, 0, 1, 0, fb,
        0, 0, 0, 1, 0   });
    
    ColorMatrix colorMatrix = new ColorMatrix();
    colorMatrix.set(cmB);
    //Canvas c = new Canvas(b2);
    //Paint paint = new Paint();
    ColorMatrixColorFilter f = new ColorMatrixColorFilter(colorMatrix);
    //paint.setColorFilter(f);   
    return f;
    }
    

提交回复
热议问题