0

我在旋转图像位图时遇到问题。当我旋转图像时,它会失去分辨率。每次用户单击按钮时我都想旋转图像。按钮单击的代码在这里:

matrix.postRotate(90);

bitmap = Bitmap.createBitmap(bitmap_rotate, 0, 0, bitmap_rotate.getwidth(),bitmap_rotate.getHeight(),matrix, true);
d_reflect = new BitmapDrawable(bitmap);

image_view.removeAllViews();
image_view.setBackgroundDrawable(d_reflect);

其中image_view是LinearLayout,我想设置旋转LinearLayout。每次旋转图像时它都会失去分辨率。我的原始位图大小是300x300。我用谷歌搜索了很多解决方案,但没有一个对我有用。任何解决方案将不胜感激。在此先感谢..

4

2 回答 2

1

这是在图像视图中平滑旋转图像而不创建额外位图的代码。

Matrix m = new Matrix();
m.setRotate(degrees);
image_view.setImageMatrix(m);
于 2013-04-12T12:11:36.537 回答
0

创建具有所需宽度和高度的缩放位图:

Bitmap bmp = Bitmap.createScaledBitmap(bitmap_rotate, 300, 300, false);
于 2013-04-12T12:52:33.760 回答