How to extract a region from an android Bitmap
I am stuck with the following problem:
I have an android Bitmap and a set of 4 coordinates, representing a rectangle. However, the rectangle may be rotated. For example I may have the coordinates 0/50, 50/0, 100/50, 50/100. Therefore I cannot simply use the Canvas drawBitmap(Bitmap bitmap, Rect src, RectF dst, Paint paint) function because I cannot specify such coordinates in a rect Object. What would be the bes开发者_C百科t way to extract such a rectangle?
Can you calculate what angle your rectangle is tilted? In that case you can rotate the canvas:
canvas.rotate(angle, px, py);
where px and py are the coordinates for the center of the rectangle.
And then do the drawBitmap(Bitmap bitmap, Rect src, RectF dst, Paint paint).
精彩评论