简体   繁体   中英

Rotate Image without losing resolution

I am having problem while rotating an Image Bitmap.When I rotate Image it lose its resolution.I want to rotate image everytime when user click on Button.Code on button's click is here:

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);

Where image_view is LinearLayout and I want to set rotate LinearLayout.It lose its resolution everytime I rotate image.My original bitmap size is 300x300.I have googled a lot to find solution but none of them worked for me. Any solution will be appreciated.Thanks in advance..

Here is the code for rotating an image smoothly inside an imageview without creating an extra Bitmap.

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

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

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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