Draw a circle on a bitmap

I wrote an application that captures an image and stores it on an SD card. Then I can load this image into an image to display it. I would like to draw a circle on a bitmap before displaying it. the code below displays a bitmap but no circle, any ideas why the circle doesn't exist?

thank.

BitmapFactory.Options bfo = new BitmapFactory.Options();
        bfo.inSampleSize = 5;
        Bitmap bm = BitmapFactory.decodeByteArray(imageArray, 0, imageArray.length, bfo);
        Log.e(TAG, bm.toString());
        //imageview.setImageBitmap(bm);


        Bitmap bmOverlay = Bitmap.createBitmap(bm.getWidth(), bm.getHeight(), bm.getConfig());
        canvas = new Canvas(bmOverlay);
        Paint paint = new Paint();
        paint.setColor(Color.RED);
        canvas.drawBitmap(bm, new Matrix(), null);
        canvas.drawCircle(750, 14, 11, paint);
        imageview.setImageBitmap(bmOverlay);
+4
source share
1 answer

You can check bm.getWidth. If you use a sample size of 5, then your image will be 5 times smaller than the original, causing your circle to disappear on the right side of the image.

You can try:

paint.setStrokeWidth(10);
canvas.drawCircle(50, 50, 25);

, .

+5

All Articles