Android程序开发之动态设置ImageView的亮度


废话不多说了,直接给大家贴代码了。 

//改变图片的亮度方法 0--原样 >0---调亮 <0---调暗
  private void changeLight(ImageView imageView, int brightness) {
    ColorMatrix cMatrix = new ColorMatrix();
    cMatrix.set(new float[] { 1, 0, 0, 0, brightness, 0, 1, 0, 0,
        brightness,// 改变亮度
        0, 0, 1, 0, brightness, 0, 0, 0, 1, 0 });
    imageView.setColorFilter(new ColorMatrixColorFilter(cMatrix));
  } 

好了,代码比较简单,希望对大家有所帮助。


« 
» 
快速导航

Copyright © 2016 phpStudy | 豫ICP备2021030365号-3