Search in sources :

Example 11 with ColorMatrix

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;
}
Also used : ColorMatrixColorFilter(android.graphics.ColorMatrixColorFilter) Bitmap(android.graphics.Bitmap) Canvas(android.graphics.Canvas) ColorMatrix(android.graphics.ColorMatrix) Paint(android.graphics.Paint)

Example 12 with ColorMatrix

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;
}
Also used : ColorMatrixColorFilter(android.graphics.ColorMatrixColorFilter) Bitmap(android.graphics.Bitmap) Canvas(android.graphics.Canvas) ColorMatrix(android.graphics.ColorMatrix) Paint(android.graphics.Paint)

Example 13 with ColorMatrix

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;
}
Also used : ColorMatrixColorFilter(android.graphics.ColorMatrixColorFilter) Path(android.graphics.Path) Bitmap(android.graphics.Bitmap) Canvas(android.graphics.Canvas) ColorMatrix(android.graphics.ColorMatrix) Paint(android.graphics.Paint) Paint(android.graphics.Paint)

Example 14 with ColorMatrix

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);
}
Also used : ColorMatrixColorFilter(android.graphics.ColorMatrixColorFilter) ColorMatrix(android.graphics.ColorMatrix) BlurMaskFilter(android.graphics.BlurMaskFilter) Resources(android.content.res.Resources) DisplayMetrics(android.util.DisplayMetrics)

Example 15 with ColorMatrix

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);
}
Also used : ColorMatrixColorFilter(android.graphics.ColorMatrixColorFilter) ColorMatrix(android.graphics.ColorMatrix)

Aggregations

ColorMatrix (android.graphics.ColorMatrix)46 ColorMatrixColorFilter (android.graphics.ColorMatrixColorFilter)46 Paint (android.graphics.Paint)29 Canvas (android.graphics.Canvas)28 Bitmap (android.graphics.Bitmap)27 Resources (android.content.res.Resources)4 BlurMaskFilter (android.graphics.BlurMaskFilter)4 Rect (android.graphics.Rect)4 BitmapDrawable (android.graphics.drawable.BitmapDrawable)4 DisplayMetrics (android.util.DisplayMetrics)4 ImageView (android.widget.ImageView)4 Drawable (android.graphics.drawable.Drawable)3 Matrix (android.graphics.Matrix)2 Path (android.graphics.Path)2 View (android.view.View)2 AccelerateDecelerateInterpolator (android.view.animation.AccelerateDecelerateInterpolator)2 ShadowView (carbon.shadow.ShadowView)2 ShortcutPickHelper (com.android.settingslib.cm.ShortcutPickHelper)2 ValueAnimator (com.nineoldandroids.animation.ValueAnimator)2 Test (org.junit.Test)2