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 );使用上面的代码对图片进行旋转时,图片的大小会变,怎样才能让图片只旋转而大小不变?this.imageView:图片对应的ImageView对象
degree:本次旋转的角度
this.w:原始图片的宽度
this.h:原始图片的高度
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 );使用上面的代码对图片进行旋转时,图片的大小会变,怎样才能让图片只旋转而大小不变?this.imageView:图片对应的ImageView对象
degree:本次旋转的角度
this.w:原始图片的宽度
this.h:原始图片的高度
Bitmap tmpBitmap = Bitmap.createBitmap( this.bitmap, 0, 0, bitmap.getWidth(), bitmap.getHeight(), matrix, true );
旋转图片的时候 用图片本身的宽高设置旋转!!
this.w和this.h就是原始图片的宽跟高
用bitmap.getWidth()
bitmap.getWidth()*Math.cos(degree)+bitmap.getHeight()*Math.sin(degree);
Bitmap tmpBitmap = Bitmap.createBitmap( this.bitmap, 0, 0, this.w, this.h, matrix, true );
//把图片截出来就行了
int x= ?//这个自己手算下吧
int y= ?//这个自己手算下吧
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 );
你得到了新的rebitmap
这时候你宽度 高度都变了当你canvas.drawBitmap();时 用你新得到的图片的宽高 rebitmap。getwidth()/2