create Round Image with selection - Android android.graphics

Android examples for android.graphics:Image Load Save

Description

create Round Image with selection

Demo Code

import android.graphics.Bitmap;
import android.graphics.Canvas;
import android.graphics.Paint;

public class Main {

  public static Bitmap createRoundImageSelected(int colour, int selectionColour, int bitmapW, int bitmapH) {
    Bitmap circleBitmap = Bitmap.createBitmap(bitmapW, bitmapH, Bitmap.Config.ARGB_8888);
    Canvas c = new Canvas(circleBitmap);

    Paint p = new Paint();
    p.setAntiAlias(true);/*from  w ww .j  a v a  2s.co m*/
    p.setStrokeWidth(5);
    p.setColor(colour);
    c.drawCircle(circleBitmap.getWidth() - bitmapW / 2, circleBitmap.getHeight() - bitmapH / 2, bitmapW / 2, p);

    p.setColor(selectionColour);
    c.drawCircle(circleBitmap.getWidth() - bitmapW / 2, circleBitmap.getHeight() - bitmapH / 2, bitmapW / 2 - 5, p);

    return circleBitmap;
  }

}

Related Tutorials