this.degree + = degree;
Matrix matrix = new Matrix ();
matrix.setRotate (this.degree);
Bitmap tmpBitmap = Bitmap.createBitmap (this.bitmap, 0, 0, this.w, this.h, matrix, true);
BitmapDrawable bitmapDrawable = new BitmapDrawable (tmpBitmap);
this.imageView.setImageDrawable (bitmapDrawable);
When using the above code rotate the picture, the picture size changes, and how to make pictures just rotating the same size?
this.imageView: pictures corresponding ImageView object
degree: The angle of rotation
this.w: the width of the original picture
the height of the original picture: this.h
<-! Main posts under Banner (D4) -><-! Posts under the main text (D5) ->
Reply:
Bitmap tmpBitmap = Bitmap.createBitmap (this.bitmap, 0, 0, bitmap.getWidth (), bitmap.getHeight (), matrix, true);
Rotate the picture when using the width and height of the image itself set the rotation! !
Reply:
this.w and this.h is the original image width with high
Reply:
+1
Reply:
Size or will change
Reply:
this.w, this.h how the value of,
With bitmap.getWidth ()
Reply:
Yes
Reply:
In addition to the vertical / horizontal rotation (90, 180, ...), after returning with Matrix pictures always turn becomes large, the center unchanged
For rectangular picture: tmpBitmap.getWidth () ==
bitmap.getWidth () * Math.cos (degree) + bitmap.getHeight () * Math.sin (degree);
Reply:
I am using a circular picture, there is no way that it does not change the size?
Reply:
There will not be rounded picture ... because the background is transparent so looked round, in fact, the figure is a square, so h == w
Bitmap tmpBitmap = Bitmap.createBitmap (this.bitmap, 0, 0, this.w, this.h, matrix, true);
/ / The picture cut out on the line
int x =? / / The count of his hands under the bar
int y =? / / The count of his hands under the bar
int width = bitmap.getWidth ();
int height = bitmap.getHeight ();
Bitmap tmpSliceBitmap = Bitmap.createBitmap (tmpBitmap, x, y, width, height)
BitmapDrawable bitmapDrawable = new BitmapDrawable (tmpSliceBitmap);
this.imageView.setImageDrawable (bitmapDrawable);
Reply:
x, y how counted, can give ideas, I tried several algorithms will not work
Reply:
I have encountered this problem, you kind of logic is wrong, you can not rotate Bitmap, you have to try to rotate canvas, this does not waste memory, do not intercept Pictures
Reply:
Also encountered this problem how to solve?
Reply:
More recently, to study this problem, I use the canvas rotation, but the picture is not in the center column rotation. . .
Reply:
The landlord can do so
You get a new rebitmap
This time you have changed
Width Height
When you canvas.drawBitmap (); time to get a picture with your new width and height rebitmap. getwidth () / 2
No comments:
Post a Comment