/**
* 亮度处理
*
* @param bitmap 原图
* @param lumValue 新的亮度值
* @return 改变了亮度值之后的图片
*/
public static Bitmap lum(Bitmap bitmap, int lumValue) {
// 计算出符合要求的亮度值
float newlumValue = lumValue * 1.0F / 127;
// 创建一个颜色矩阵
ColorMatrix lumColorMatrix = new ColorMatrix();
// 设置亮度值
lumColorMatrix.setScale(newlumValue, newlumValue, newlumValue, 1);
// 创建一个画笔并设置其颜色过滤器
Paint paint = new Paint();
paint.setColorFilter(new ColorMatrixColorFilter(lumColorMatrix));
// 创建一个新的图片并创建画布
Bitmap newBitmap = Bitmap.createBitmap(bitmap.getWidth(),
bitmap.getHeight(), Config.ARGB_8888);
Canvas canvas = new Canvas(newBitmap);
// 将原图使用给定的画笔画到画布上
canvas.drawBitmap(bitmap, 0, 0, paint);
return newBitmap;
}
XBitmapUtils.java 文件源码
java
阅读 44
收藏 0
点赞 0
评论 0
项目:XFrame
作者:
评论列表
文章目录