Code example for ColorMatrix

Methods: setScale

0
	 */ 
	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(), Bitmap.Config.ARGB_8888);
		Canvas canvas = new Canvas(newBitmap);
		//将原图使用给定的画笔画到画布上 
		canvas.drawBitmap(bitmap, 0, 0, paint);
		return newBitmap;
	} 
	 
	/** 
	 * 色相处理