0

As you can see when i use canvas.drawpath() in my application i dont get the results that one user would want to.

See where my finger is and where it draws!

enter image description here

    //Bitmap is the picture
    imageview.setImageBitmap(bitmap);
    Canvas canvas = new Canvas(bitmap);
    Paint paint = new Paint();
    paint.setColor(Color.Black);
    paint.setStrokeWidth(50);
    paint.setStyle(Paint.Style.STROKE);
    path = new Path();
    imageview.setOnTouchListener(this);

And here onTouchListener

public boolean onTouch(View v, MotionEvent event) {
            int action = event.getAction();
            switch (action) {
            case MotionEvent.ACTION_DOWN:
                path.moveTo(event.getX(), event.getY());
                path.lineTo(event.getX(), event.getY());
                canvas.drawPath(path, paint);
                imageview.invalidate();
                break;
            case MotionEvent.ACTION_MOVE:
                  path.lineTo(event.getX(), event.getY());
                  canvas.drawPath(path, paint);
                  imageview.invalidate();
                    break;
            case MotionEvent.ACTION_UP:
                  path.lineTo(event.getX(), event.getY());
                   canvas.drawPath(path, paint);
                    imageview.invalidate();

              break;
            case MotionEvent.ACTION_CANCEL:
              break;
            default:
              break;
            }
            return true;
          }
Device
  • 993
  • 3
  • 11
  • 26

1 Answers1

0

Actually my problem was that i could not get the real x and y position.

To achieve this is simple and you can do it alone without mr pskink help

            Matrix official= new Matrix();
            image.getImageMatrix().invert(official);
            float[] REALXY= new float[] {documentation.getX(), documentation.getY()};
            official.mapPoints(REALXY);
            float GETREALX;
             GETREALX=REALXY[0];
             float GETREALY;
             GETREALY= REALXY[1];
Device
  • 993
  • 3
  • 11
  • 26