I read about simple method to cropping bitmaps – it works fine, when crop is not so frequent:
Bitmap.createBitmap(src, x, y, width, height);
But in my app I’m drawing bitmaps on the canvas and I want it to not getting of bounds

User can move and zoom bitmap. Now I’m using the method that I described above in onTouchEvent, but:
-
It’s not smooth enough (however it works)
-
It recreates a new bitmap at each “move” event. I think it’s extremely ineffective. There is no memory consumption, since I recycle previous bitmaps, but it’s still looks bad.
My question is: is there any way to crop bitmap more efficiently, while drawing on canvas?
I’ve decided that it’s much better to use own
ImageViewfor eachBitmapinstead of drawing them together on one view.In this case OS will crop everything that getting out of bounds for you and there is no need to crop bitmaps by yourself. It’s significantly increases the performance.