I was wondering if it's possible to draw a circle on an existing imageView ?
I want to create a circle on my image, here's my code :
public void drawCircle(ImageView image, int x, int y)
{
BitmapDrawable drawable = (BitmapDrawable) image.getDrawable();
Bitmap bitmap = drawable.getBitmap();
Canvas canvas = new Canvas(bitmap);
Paint paint = new Paint();
paint.setColor(Color.RED);
paint.setStyle(Paint.Style.STROKE);
float radius = 20;
canvas.drawCircle(x, y, radius, paint);
image.setImageBitmap(bitmap);
}
But unfortunately, i've got the following error :
java.lang.NullPointerException: Attempt to invoke virtual method 'android.graphics.Bitmap android.graphics.drawable.BitmapDrawable.getBitmap()' on a null object reference
Can u tell me what's wrong with my code ?
Thanks !