0

How to add multiple points over an image view. this is what i am trying

    myView = (ImageView) findViewById(R.id.my_view);
        View view = LayoutInflater.from(ZoomTouchActivity.this).inflate(R.layout.layout_custom_view, null);
        CircularImageView imgView = view.findViewById(R.id.site_image);
        TextView siteName = view.findViewById(R.id.site_text);
        imgView.setImageResource(R.drawable.ic_launcher_background);
        siteName.setText("est");
        Bitmap bitmap = getBitmapFromView(view);
        Canvas canvas = new Canvas(bitmap);
        Paint paint = new Paint(Paint.ANTI_ALIAS_FLAG);
        paint.setColor(Color.BLACK);
//        canvas.drawCircle(50, 50, 10, paint);
        canvas.drawBitmap(bitmap, 50, 50, paint);
        myView.setImageBitmap(bitmap);
3

2 Answers 2

0

You can draw on an ImageView by simply putting the image's Bitmap inside a canvas, draw on the canvas and set the drawn canvas to the imageview. You can check this answer for more details. For more details on how to draw, you can check the android documentation here.

0

Try this:

BitmapFactory.Options myOptions;
Canvas canvas;
Bitmap mutableBitmap;
Bitmap workingBitmap;


@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    btn_open= findViewById(R.id.btn_open);
    image2= findViewById(R.id.imageView);
    myOptions = new BitmapFactory.Options();
    bitmap = BitmapFactory.decodeResource(getResources(), 
    R.drawable.image000880,myOptions);
    paint= new Paint();
    paint.setAntiAlias(true);
    paint.setColor(Color.WHITE);

    workingBitmap = Bitmap.createBitmap(bitmap);
    mutableBitmap = workingBitmap.copy(Bitmap.Config.ARGB_8888, true);
    canvas = new Canvas(mutableBitmap);

   private void drawpoint(ImageView imageView,float x,float y, int raduis){
    myOptions.inDither = true;
    myOptions.inScaled = false;
    myOptions.inPreferredConfig = Bitmap.Config.ARGB_8888;// important
    myOptions.inPurgeable = true;
//  ArrayList<Point> list= new ArrayList<>();
    canvas.drawCircle(x,y, raduis, paint);
    imageView = (ImageView)findViewById(R.id.imageView);
    imageView.setAdjustViewBounds(true);
    imageView.setImageBitmap(mutableBitmap);
}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.