繁体   English   中英

旋转图像而不会丢失分辨率

[英]Rotate Image without losing resolution

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

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,我想设置rotate LinearLayout。每次旋转图像时它都会失去分辨率。我的原始位图大小是300x300。我已经在Google上搜索了很多东西来找到解决方案,但没有一个对我有用。 任何解决方案将不胜感激。

这是用于在imageview内平滑旋转图像而无需创建额外位图的代码。

Matrix m = new Matrix();
m.setRotate(degrees);
image_view.setImageMatrix(m);

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

Bitmap bmp = Bitmap.createScaledBitmap(bitmap_rotate, 300, 300, false);

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM