1

I want to get the portion of an image that is visible on the screen in an image view. Like if there is an image zoomed in on the image view, then the zoomed in portion visible on the screen should be cropped out and stored.

I can not use libraries or camera intents for the task

. All has to be done on the same page. Consider i have the image in bitmap/imageview/resource file.

  • [This Answer](https://stackoverflow.com/a/18073632/3627279) is exactly what you searching for. Let me know if your issue is resolved. – Joe Sep 25 '18 at 17:43
  • @Joe for cropping the setlevel() is good but how to use it to get the visible image in imageview? – Pulkit Vashistha Sep 25 '18 at 18:50
  • Oh sorry, I did not understand the question at the first sight, how about this answer: https://stackoverflow.com/a/8545583/3627279 Drawing imageview on canvas should be a good solution. – Joe Sep 25 '18 at 19:16
  • @Joe Thanx a lot joe, the second solution totally worked for me! Thanx man. – Pulkit Vashistha Sep 26 '18 at 12:34
  • You're very welcome bro – Joe Sep 26 '18 at 15:50

1 Answers1

0

Use these lines for the problem

Bitmap result = Bitmap.createBitmap(yourImageView.getWidth(), 
yourImageView.getHeight(), Bitmap.Config.RGB_565);
Canvas c = new Canvas(result);
yourImageView.draw(c);

These 4 lines of code will give you what you exactly see on screen in the Bitmap result.