In many application we set the scaleType of large image to "CENTER" or the scaleType is set to "MATRIX" and the bitmap is translated and scaled. Therefore parts of the image are not visible. Now in order to get the visible part you just need to enable the drawing cache and grab it from the view.
// set image in source ImageView and set is scaleType to CENTER
sourceImageView.setImageBitmap(bitmap);
sourceImageView.setScaleType(ImageView.ScaleType.CENTER);
sourceImageView.setDrawingCacheEnabled(true);
// get cropped image in cropped ImageView
croppedImageView.setImageBitmap(sourceImageView.getDrawingCache());
You can also use to above code by getting or crop the zoomed bitmap when you zoom your Image contained in an ImageView.
1 Comment(s)