0
votes

I use PhotoView library: https://github.com/chrisbanes/PhotoView

This is my initial case; it's the PhotoView component (red square); the background is transparent. I load a standard picture inside.

enter image description here

Now, I want to extract the visible bitmap part to another bitmap:

Bitmap original = mPhotoView.getVisibleRectangleBitmap();
        return Bitmap.createBitmap(original, 0, 0, original.getWidth(), original.getHeight(),
                mPhotoView.getImageMatrix(), true);

but the result is bad, because there are black areas, and I don't know why... I just want extract only the area with the picture and not all PhotoView.

enter image description here

How to extract without background unused?

Thank you very much guys!

1

1 Answers

0
votes

PhotoView extends ImageView so you can just call getDrawable() on the Photoview to get a Drawable.

Once you have the Drawable, if it is always a BitmapDrawable, you can just call getBitmap() on it and you have your bitmap. If you cannot guarantee that, you can start with reading through this question, and find the best way to convert.

This of course would ignore any zooming or transformation that is done to the view. If that is important to retain, then this answer is not relevant. Sorry.