Reputation: 779
I'm writing a custom image crop.
I have an image view and a rectangle to choose area for cropping on it.
After cropping I need to know a top-left point of rectangle, that present cropping area.
But when i try to get it, Rect gives me a X, Y and width coordinates of the screen, not image. How can I get a real coordinates of the image?
Upvotes: 0
Views: 1030
Reputation: 4941
I guess you could apply a simple proportionnality rule using the actual size in pixels of the device screen (assuming the image is displayed in full screen). You can easily get the screen size using this very complete answer: https://stackoverflow.com/a/1016941/1417179
From there, if your image dimensions is wh and the screen dimensions wshs, you can get the coordinates in image space using image_coordinates = screen_coordinates*w/ws.
You may have to cheat a little if the image displayed is not of the same aspect ratio than the screen, but the idea remains the same.
Hope this helps!
Upvotes: 1