Reputation: 1179
I have created a rectangle to select a part of a picture. An example: Picture size: 800x600 pixel Rectangle size: 100x100 pixel Rectangle position: left: 40px, right: 140px, top: 120px, bottom: 220px
How can I create the image which is inside the rectangle? The image size should be 100x100 pixel. Are there methods or do I have to create a new image by reading out the pixels of the old image?
Upvotes: 1
Views: 1355
Reputation: 14348
There is a useful factory method that extracts smaller bitmap from bigger one:
Bitmap part = Bitmap.createBitmap(source, x, y, width, height, null, true);
In your case,
Bitmap part = Bitmap.createBitmap(source, left, top, right-left, bottom-top, null, true);
should work.
Upvotes: 1