如何使用矩阵在android中心点旋转位图
我使用矩阵旋转我的图像,它的工作,但我有一些新的图像位图的问题。 尽管我已经设置了数据透视表,但新位图仍有一些空间。我该怎么做旋转图像,但我不想要空间。我使用下面的代码来旋转位图:如何使用矩阵在android中心点旋转位图
位图bitmapOrg = BitmapFactory.decodeResource(getResources(),R.drawable.sticker01); int width = bitmapOrg.getWidth(); int height = bitmapOrg.getHeight();
Matrix matrix = new Matrix(); matrix.postRotate(rotate,width/2,height/2);
位图resizedBitmap = Bitmap.createBitmap(bitmapOrg,0, width,height,matrix,true); BitmapDrawable bmd = new BitmapDrawable(resizedBitmap);
imageView.setBackgroundColor(Color.WHITE); imageView.setImageDrawable(bmd); imageView.setScaleType(ScaleType.FIT_XY);
的ImageView - >宽度&高度= WRAP_CONTENT
旋转0度:
旋转10度: 它周围的真实图像空间..
旋转50度: 它有真实的图像周围的空间(更大的空间)..
更改ImageView的scaleType:
imageView.setScaleType(ScaleType.CENTER);
使用矩阵旋转后与中值
matrix.postScale(规模化,规模化,mid.x,mid.y);
嗨亲爱的你得到你的答案或不 – 2012-11-06 10:18:32