Example usage for android.graphics Paint Paint

List of usage examples for android.graphics Paint Paint

Introduction

In this page you can find the example usage for android.graphics Paint Paint.

Prototype

public Paint() 

Source Link

Document

Create a new paint with default settings.

Usage

From source file:Main.java

public static Bitmap revertImage(Bitmap bm) {
    Bitmap bitmap = Bitmap.createBitmap(bm.getWidth(), bm.getHeight(), Bitmap.Config.ARGB_8888);
    Canvas canvas = new Canvas(bitmap);
    Paint paint = new Paint();

    float[] matrixs = new float[] { -1, 0, 0, 1, 1, 0, -1, 0, 1, 1, 0, 0, -1, 1, 1, 0, 0, 0, 1, 0 };

    ColorMatrix colorMatrix = new ColorMatrix();
    colorMatrix.set(matrixs);/*w  w  w.  j a va2  s .c  om*/
    paint.setColorFilter(new ColorMatrixColorFilter(colorMatrix));

    canvas.drawBitmap(bm, 0, 0, paint);

    return bitmap;
}

From source file:Main.java

public static Bitmap changeImageColor(Bitmap sourceBitmap, int color) {
    Bitmap resultBitmap = Bitmap.createBitmap(sourceBitmap, 0, 0, sourceBitmap.getWidth() - 1,
            sourceBitmap.getHeight() - 1);
    Paint p = new Paint();
    p.setColor(color);//  w w w . j  a v  a2  s.  com
    ColorFilter filter = new LightingColorFilter(color, 1);

    Canvas canvas = new Canvas(resultBitmap);
    canvas.drawBitmap(resultBitmap, 0, 0, p);
    return resultBitmap;
}

From source file:Main.java

public static Bitmap memoriesImage(Bitmap bm) {
    Bitmap bitmap = Bitmap.createBitmap(bm.getWidth(), bm.getHeight(), Bitmap.Config.ARGB_8888);
    Canvas canvas = new Canvas(bitmap);
    Paint paint = new Paint();

    float[] matrixs = new float[] { 0.393f, 0.769f, 0.189f, 0, 0, 0.349f, 0.686f, 0.168f, 0, 0, 0.272f, 0.534f,
            0.134f, 0, 0, 0, 0, 0, 1, 0 };

    ColorMatrix colorMatrix = new ColorMatrix();
    colorMatrix.set(matrixs);/*from  ww  w.ja  va2 s  .c o  m*/
    paint.setColorFilter(new ColorMatrixColorFilter(colorMatrix));

    canvas.drawBitmap(bm, 0, 0, paint);

    return bitmap;
}

From source file:Main.java

public static Paint getPaintFromColor(int color) {
    final float[] array = new float[20];
    array[18] = 1;/*from  w  w w.  j  a  va 2 s. c om*/
    array[1] = (float) Color.red(color) / 255;
    array[6] = (float) Color.green(color) / 255;
    array[11] = (float) Color.blue(color) / 255;
    final Paint paint = new Paint();
    paint.setColorFilter(new ColorMatrixColorFilter(array));
    return paint;
}

From source file:Main.java

public static Bitmap desaturateImage(Bitmap bm) {
    Bitmap bitmap = Bitmap.createBitmap(bm.getWidth(), bm.getHeight(), Bitmap.Config.ARGB_8888);
    Canvas canvas = new Canvas(bitmap);
    Paint paint = new Paint();

    float[] matrixs = new float[] { 1.5f, 1.5f, 1.5f, 0, -1, 1.5f, 1.5f, 1.5f, 0, -1, 1.5f, 1.5f, 1.5f, 0, -1,
            0, 0, 0, 1, 0 };/*from   w ww  .ja va2  s.c o m*/

    ColorMatrix colorMatrix = new ColorMatrix();
    colorMatrix.set(matrixs);
    paint.setColorFilter(new ColorMatrixColorFilter(colorMatrix));

    canvas.drawBitmap(bm, 0, 0, paint);

    return bitmap;
}

From source file:Main.java

public static Bitmap generateGrayImage(Bitmap bm) {
    Bitmap bitmap = Bitmap.createBitmap(bm.getWidth(), bm.getHeight(), Bitmap.Config.ARGB_8888);
    Canvas canvas = new Canvas(bitmap);
    Paint paint = new Paint();

    float[] matrixs = new float[] { 0.33f, 0.59f, 0.11f, 0, 0, 0.33f, 0.59f, 0.11f, 0, 0, 0.33f, 0.59f, 0.11f,
            0, 0, 0, 0, 0, 1, 0 };/*  w ww.j  av a  2  s  . c  om*/

    ColorMatrix colorMatrix = new ColorMatrix();
    colorMatrix.set(matrixs);
    paint.setColorFilter(new ColorMatrixColorFilter(colorMatrix));

    canvas.drawBitmap(bm, 0, 0, paint);

    return bitmap;
}

From source file:Main.java

public static Bitmap highSaturationImage(Bitmap bm) {
    Bitmap bitmap = Bitmap.createBitmap(bm.getWidth(), bm.getHeight(), Bitmap.Config.ARGB_8888);
    Canvas canvas = new Canvas(bitmap);
    Paint paint = new Paint();

    float[] matrixs = new float[] { 1.438f, -0.122f, -0.016f, 0, -0.03f, -0.062f, 1.378f, -0.016f, 0, 0.05f,
            -0.062f, -0.122f, 1.438f, 0, -0.02f, 0, 0, 0, 1, 0 };

    ColorMatrix colorMatrix = new ColorMatrix();
    colorMatrix.set(matrixs);//from  w  w  w  . j a  v  a  2 s . co  m
    paint.setColorFilter(new ColorMatrixColorFilter(colorMatrix));

    canvas.drawBitmap(bm, 0, 0, paint);

    return bitmap;
}

From source file:Main.java

public static Bitmap handleImageEffect(Bitmap bm, float hue, float saturation, float lum) {
    Bitmap bmp = Bitmap.createBitmap(bm.getWidth(), bm.getHeight(), Bitmap.Config.ARGB_8888);

    Canvas canvas = new Canvas(bmp);
    Paint paint = new Paint();

    ColorMatrix hueMatrix = new ColorMatrix();
    hueMatrix.setRotate(0, hue);//from   www.j a  va2 s .c o  m
    hueMatrix.setRotate(1, hue);
    hueMatrix.setRotate(2, hue);

    ColorMatrix saturationMatrix = new ColorMatrix();
    saturationMatrix.setSaturation(saturation);

    ColorMatrix lumMatrix = new ColorMatrix();
    lumMatrix.setScale(lum, lum, lum, 1);

    ColorMatrix imageMatrix = new ColorMatrix();
    imageMatrix.postConcat(hueMatrix);
    imageMatrix.postConcat(saturationMatrix);
    imageMatrix.postConcat(lumMatrix);

    paint.setColorFilter(new ColorMatrixColorFilter(imageMatrix));
    canvas.drawBitmap(bm, 0, 0, paint);
    return bmp;
}

From source file:Main.java

public static Bitmap handleColorMatrix(Bitmap bm, float[] matrixs) {
    Bitmap bitmap = Bitmap.createBitmap(bm.getWidth(), bm.getHeight(), Bitmap.Config.ARGB_8888);
    Canvas canvas = new Canvas(bitmap);
    Paint paint = new Paint();

    ColorMatrix colorMatrix = new ColorMatrix();
    colorMatrix.set(matrixs);// w w w.  j  a  va  2 s .  c o m
    paint.setColorFilter(new ColorMatrixColorFilter(colorMatrix));

    canvas.drawBitmap(bm, 0, 0, paint);

    return bitmap;
}

From source file:Main.java

public static Bitmap drawEmptyBackground(int size) {
    Bitmap bitmap = Bitmap.createBitmap(size, size, Config.RGB_565);
    Canvas cv = new Canvas(bitmap);

    Paint background = new Paint();
    background.setColor(BACKGROUND_COLOR);
    cv.drawRect(0, 0, size, size, background);
    return bitmap;
}