use of android.graphics.ColorMatrix in project Lazy by l123456789jy.
the class ImageProcessor method lum.
/**
* 亮度处理
* @param lumValue 新的亮度值
* @return 改变了亮度值之后的图片
*/
public Bitmap lum(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;
}
use of android.graphics.ColorMatrix in project Lazy by l123456789jy.
the class BitmapUtil method hue.
/**
* 色相处理
*
* @param bitmap 原图
* @param hueValue 新的色相值
* @return 改变了色相值之后的图片
*/
public static Bitmap hue(Bitmap bitmap, int hueValue) {
// 计算出符合要求的色相值
float newHueValue = (hueValue - 127) * 1.0F / 127 * 180;
// 创建一个颜色矩阵
ColorMatrix hueColorMatrix = new ColorMatrix();
// 控制让红色区在色轮上旋转的角度
hueColorMatrix.setRotate(0, newHueValue);
// 控制让绿红色区在色轮上旋转的角度
hueColorMatrix.setRotate(1, newHueValue);
// 控制让蓝色区在色轮上旋转的角度
hueColorMatrix.setRotate(2, newHueValue);
// 创建一个画笔并设置其颜色过滤器
Paint paint = new Paint();
paint.setColorFilter(new ColorMatrixColorFilter(hueColorMatrix));
// 创建一个新的图片并创建画布
Bitmap newBitmap = Bitmap.createBitmap(bitmap.getWidth(), bitmap.getHeight(), Config.ARGB_8888);
Canvas canvas = new Canvas(newBitmap);
// 将原图使用给定的画笔画到画布上
canvas.drawBitmap(bitmap, 0, 0, paint);
return newBitmap;
}
use of android.graphics.ColorMatrix in project glitch-hq-android by tinyspeck.
the class BitmapUtil method GetGrayscale.
public static Bitmap GetGrayscale(ImageView iv, Bitmap bm, boolean big) {
int width, height;
height = bm.getHeight();
width = bm.getWidth();
Bitmap bmGrayscale = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888);
Bitmap bmCheckMark = BitmapFactory.decodeResource(iv.getResources(), big ? R.drawable.checkmark : R.drawable.checkmark_small);
Canvas c = new Canvas(bmGrayscale);
// for bitmap
Paint paint = new Paint();
ColorMatrix cm = new ColorMatrix();
cm.setSaturation(0);
ColorMatrixColorFilter f = new ColorMatrixColorFilter(cm);
paint.setColorFilter(f);
// for check mark
Paint colorPaint = new Paint();
// for circle around bitmap
Paint cPaint = new Paint();
cPaint.setStyle(Paint.Style.STROKE);
cPaint.setAntiAlias(true);
cPaint.setAlpha(78);
cPaint.setColor(0xffc0c0c0);
Path clip = new Path();
clip.addCircle(width / 2, height / 2, (float) (width / 2 + 1.0), Path.Direction.CW);
c.clipPath(clip);
c.drawARGB(78, 233, 240, 240);
c.drawBitmap(bm, 0, 0, paint);
c.drawCircle(width / 2, height / 2, width / 2, cPaint);
if (big) {
c.drawBitmap(bmCheckMark, 100, 65, colorPaint);
} else {
c.drawBitmap(bmCheckMark, 35, 30, colorPaint);
}
return bmGrayscale;
}
use of android.graphics.ColorMatrix in project ADWLauncher2 by boombuler.
the class Utilities method initStatics.
private static void initStatics(Context context) {
final Resources resources = context.getResources();
final DisplayMetrics metrics = resources.getDisplayMetrics();
final float density = metrics.density;
sIconWidth = sIconHeight = (int) resources.getDimension(android.R.dimen.app_icon_size);
sIconTextureWidth = sIconTextureHeight = sIconWidth + 2;
sBlurPaint.setMaskFilter(new BlurMaskFilter(5 * density, BlurMaskFilter.Blur.NORMAL));
sGlowColorPressedPaint.setColor(0xffffc300);
//TODO: sGlowColorPressedPaint.setMaskFilter(TableMaskFilter.CreateClipTable(0, 30));
sGlowColorFocusedPaint.setColor(0xffff8e00);
//TODO: sGlowColorFocusedPaint.setMaskFilter(TableMaskFilter.CreateClipTable(0, 30));
ColorMatrix cm = new ColorMatrix();
cm.setSaturation(0.2f);
sDisabledPaint.setColorFilter(new ColorMatrixColorFilter(cm));
sDisabledPaint.setAlpha(0x88);
}
use of android.graphics.ColorMatrix in project AndroidIndicators by MoshDev.
the class GreyscaleIconicTabsEffect method applyTabEffect.
@Override
public void applyTabEffect(ImageView imageView, float value, Status status) {
ColorMatrix matrix = new ColorMatrix();
matrix.setSaturation(value);
ColorMatrixColorFilter filter = new ColorMatrixColorFilter(matrix);
imageView.setColorFilter(filter);
}
Aggregations