【发布时间】:2012-03-08 16:11:31
【问题描述】:
我使用矩阵来旋转我的图像,它可以工作,但我对新图像位图有一些问题。 即使我设置了枢轴,新位图也有一些空间。我应该怎么做才能旋转图像,但我不想要空间。我使用下面的代码来旋转位图:
位图 bitmapOrg = BitmapFactory.decodeResource(getResources(), R.drawable.sticker01); int 宽度 = bitmapOrg.getWidth(); int height = bitmapOrg.getHeight();
矩阵矩阵 = 新矩阵(); matrix.postRotate(rotate, width/2, height/2);
位图 resizedBitmap = Bitmap.createBitmap(bitmapOrg, 0, 0, 宽度,高度,矩阵,真); BitmapDrawable bmd = new BitmapDrawable(resizedBitmap);
imageView.setBackgroundColor(Color.WHITE); imageView.setImageDrawable(bmd); imageView.setScaleType(ScaleType.FIT_XY);
imageView --> 宽度和高度 = WRAP_CONTENT
旋转0度:
旋转 10 度: 它在真实图像周围有空间..
旋转 50 度: 它在真实图像周围有空间(甚至更大的空间)..
【问题讨论】:
-
嗨,亲爱的,你知道吗
标签: android bitmap matrix android-imageview