Example usage for android.graphics Paint setAntiAlias

List of usage examples for android.graphics Paint setAntiAlias

Introduction

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

Prototype

public void setAntiAlias(boolean aa) 

Source Link

Document

Helper for setFlags(), setting or clearing the ANTI_ALIAS_FLAG bit AntiAliasing smooths out the edges of what is being drawn, but is has no impact on the interior of the shape.

Usage

From source file:Main.java

public static Paint getPaint(Paint.Style style, int color) {
    Paint mPaint = new Paint();
    mPaint.setAntiAlias(true);
    mPaint.setStyle(style);/* ww w  .j  a va  2s. c  o m*/
    mPaint.setColor(color);
    mPaint.setTextSize(30);
    return mPaint;
}

From source file:Main.java

public static void drawCircleBorder(Canvas canvas, int radius, int w, int y) {
    Paint paint = new Paint();
    paint.setAntiAlias(true);
    paint.setFilterBitmap(true);//from w  ww .  ja v  a2  s .com
    paint.setDither(true);
    paint.setColor(Color.WHITE);
    paint.setStyle(Paint.Style.STROKE);
    paint.setStrokeWidth(mBorderThickness);
    canvas.drawCircle(w / 2, y / 2, radius, paint);
}

From source file:Main.java

public static void drawKnots(Canvas canvas, List<PointF> knots, int color) {
    Log.d("GammaGraph", "function drawKnots");
    Paint paint = new Paint();
    paint.setAntiAlias(true);
    paint.setColor(color);// www  .j  a va2  s . c om
    paint.setStrokeWidth(7);
    for (PointF knot : knots) {
        canvas.drawPoint(knot.x, knot.y, paint);
    }
}

From source file:Main.java

public static Bitmap toCircleBitmap(Bitmap bitmap) {

    int width = bitmap.getWidth();
    int height = bitmap.getHeight();
    int r = width < height ? width : height;

    Bitmap buffer = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888);
    Canvas canvas = new Canvas(buffer);
    Paint paint = new Paint();
    paint.setAntiAlias(true);
    RectF rect = new RectF(0, 0, r, r);

    canvas.drawCircle(r / 2, r / 2, r / 2, paint);
    paint.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.SRC_IN));
    canvas.drawBitmap(bitmap, null, rect, paint);
    bitmap.recycle();/*from   w  w  w.  j  ava2 s. com*/
    return buffer;
}

From source file:Main.java

public static Bitmap toOvalBitmap(Bitmap bitmap) {
    Bitmap output = Bitmap.createBitmap(bitmap.getHeight(), bitmap.getHeight(), Config.ARGB_8888);
    Canvas canvas = new Canvas(output);
    Paint paint = new Paint();
    paint.setAntiAlias(true);
    Rect rect = new Rect(0, 0, bitmap.getHeight(), bitmap.getHeight());
    RectF rectF = new RectF(rect);

    canvas.drawOval(rectF, paint);/*from  w w  w.  ja v a2s.c o m*/
    paint.setXfermode(new PorterDuffXfermode(Mode.SRC_IN));
    canvas.drawBitmap(bitmap, rect, rectF, paint);
    return output;
}

From source file:Main.java

public static Bitmap getDummyBitmap(int targetWidth, int targetHeight, int color) {
    Bitmap bitmap = Bitmap.createBitmap(targetWidth, targetHeight, Bitmap.Config.ARGB_8888);
    Canvas canvas = new Canvas(bitmap);
    Paint paint = new Paint();
    paint.setAntiAlias(true);
    paint.setColor(color);/*from   ww w  .j a  v  a2s . c om*/
    canvas.drawPaint(paint);
    return bitmap;
}

From source file:Main.java

public static Bitmap makeCircleBitmap(Bitmap original) {
    final int width = original.getWidth();
    final int height = original.getHeight();
    final float radius = Math.min(width, height) / 2;

    Bitmap bitmap = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888);

    Paint paint = new Paint();
    paint.setAntiAlias(true);
    paint.setShader(new BitmapShader(original, Shader.TileMode.CLAMP, Shader.TileMode.CLAMP));

    Canvas canvas = new Canvas(bitmap);
    canvas.drawCircle(radius, radius, radius, paint);

    original.recycle();/*from   www  .  j  ava 2s  .c  om*/
    return bitmap;
}

From source file:Main.java

public static Bitmap highlightSelectedFaceThumbnail(Bitmap originalBitmap) {
    Bitmap bitmap = originalBitmap.copy(Bitmap.Config.ARGB_8888, true);
    Canvas canvas = new Canvas(bitmap);
    Paint paint = new Paint();
    paint.setAntiAlias(true);
    paint.setStyle(Paint.Style.STROKE);
    paint.setColor(Color.parseColor("#3399FF"));
    int stokeWidth = Math.max(originalBitmap.getWidth(), originalBitmap.getHeight()) / 10;
    if (stokeWidth == 0) {
        stokeWidth = 1;//from   ww w .  j a  v a  2s. co m
    }
    bitmap.getWidth();
    paint.setStrokeWidth(stokeWidth);
    canvas.drawRect(0, 0, bitmap.getWidth(), bitmap.getHeight(), paint);

    return bitmap;
}

From source file:Main.java

/**
 * TODO write documentation/*  ww w  .j av  a  2  s.c  o m*/
 *
 * @param sourceBitmap
 * @param color
 * @return
 */
public static Bitmap overlayColor(Bitmap sourceBitmap, int color) {
    Bitmap newBitmap = Bitmap.createBitmap(sourceBitmap, 0, 0, sourceBitmap.getWidth(),
            sourceBitmap.getHeight());
    Bitmap mutableBitmap = newBitmap.copy(Bitmap.Config.ARGB_8888, true);
    Canvas canvas = new Canvas(mutableBitmap);
    Paint paint = new Paint();
    paint.setAntiAlias(true);
    ColorFilter filter = new LightingColorFilter(color, 1);
    paint.setColorFilter(filter);
    canvas.drawBitmap(mutableBitmap, 0, 0, paint);
    return mutableBitmap;
}

From source file:Main.java

/**
 * ATTENTION: DON'T USE THIS METHOD BECAUSE IT HAS BAD PERFORMANCES.
 *
 * @param source The original Bitmap./* w  ww.j a v  a  2s . c  o  m*/
 * @param color  Color to overlay.
 * @return the result image.
 */
@Deprecated
private static Bitmap overlayColor(Bitmap source, int color) {
    Bitmap newBitmap = Bitmap.createBitmap(source, 0, 0, source.getWidth(), source.getHeight());
    Bitmap mutableBitmap = newBitmap.copy(Bitmap.Config.ARGB_8888, true);
    Canvas canvas = new Canvas(mutableBitmap);
    Paint paint = new Paint();
    paint.setAntiAlias(true);
    ColorFilter filter = new LightingColorFilter(color, 1);
    paint.setColorFilter(filter);
    canvas.drawBitmap(mutableBitmap, 0, 0, paint);
    return mutableBitmap;
}