How To Draw A Red Circle On A Jpeg Image On Android
I am trying to draw circle on an JPEG image which load into my application. When user touch a position, the circle should be drawn on that spot. How can I achieve that?
Solution 1:
see this link
image.setOnTouchListener(new OnTouchListener() {
public boolean onTouch(View arg0, MotionEvent arg1) {
System.out.println("Touch recieved at "+arg1.getX() + " " + arg1.getY());
touchX = (arg1.getX());
touchY = (arg1.getY());
System.out.println("Touch recieved at "+touchX + " " + touchY);
image.setImageBitmap(createImage());
return true;
}
});
public Bitmap createImage(){
Bitmap image = bmp.copy(Bitmap.Config.RGB_565, true);
Canvas canvas = new Canvas(image);
Paint paint = new Paint();
paint.setStyle(Paint.Style.STROKE);
paint.setColor(Color.GREEN);
touchX=touchX- image.getWidth() / 2;
touchY=touchY- image.getHeight() / 2;
canvas.drawCircle(touchX, touchY, radius, paint);
System.out.println("Drew a circle at "+touchX+" " + touchY+" with a radius of "+radius+".");
return image;
}
Post a Comment for "How To Draw A Red Circle On A Jpeg Image On Android"