java - Bitmap drawn in a rectangle, now rotate 90 and scale it to the same rectangle -
i have bitmap drawn in rectangle. want rotate bitmap 90 degree , draw oriented bitmap in same rectangle bound, may need scale it.
above oriented image not scaled fit rectangle bound of original rectangle (see first image, normal one) , remove lower part of image. below code snippet. suggestion ?
sourceimagerect.left = 0; sourceimagerect.top = 0; sourceimagerect.right = bmp.getwidth(); sourceimagerect.bottom = bmp.getheight(); destimagerect.top = desttop; destimagerect.left = destleft; destimagerect.right = destleft + destwidth; destimagerect.bottom = desttop + destheight; canvas.save(canvas.matrix_save_flag); canvas.rotate(90, (destleft + (destwidth / 2)), (desttop + (destheight / 2))); canvas.drawbitmap(bmp, sourceimagerect, destimagerect, null); canvas.restore();
last image exact required output need.
i writed tool java class named imagescaleutil.java
several days ago. helping can useful information on it.
you can use it, this:
```java
bitmap targetbitmap = imagescaleutil.getscalebitmap(bitmap sourcebitmap, int reqwidth, int reqheight);
```
Comments
Post a Comment