bitmap - Android: image rotation not desire to resize -


i have code rotate imageview, , good. problem size of image change in rotate process , desire not happen.

the xml code of image

<imageview         android:id="@+id/imgballesta"         android:layout_width="100dp"         android:layout_height="100dp"         android:layout_alignparentleft="true"         android:layout_centervertical="true"         android:src="@drawable/imgballesta"         android:contentdescription="@string/imagestring"          /> 

the code creates bitmap, put code in declaration of class

bitmap bmap = bitmapfactory.decoderesource(getresources(), r.drawable.imgobjectimage); 

and code rotate image, code inluded , ontouchevent

matrix mat = new matrix(); matrix.postrotate((float) (angle*180/math.pi), image.getwidth(),image.getheight()); bitmap bmaprotate = bitmap.createbitmap(bmap, 0, 0, bmap.getwidth(), bmap.getheight(), matrix, true); image.setimagebitmap(bmaprotate); 

thanks help, , read question

try method rotate picture :

public static bitmap rotate(bitmap src, float degree) {     // create new matrix     matrix matrix = new matrix();     // setup rotation degree     matrix.postrotate(degree);      // return new bitmap rotated using matrix     return bitmap.createbitmap(src, 0, 0, src.getwidth(), src.getheight(), matrix, true); } 

good luck!!


Comments

Popular posts from this blog

SPSS keyboard combination alters encoding -

Add new record to the table by click on the button in Microsoft Access -

javascript - jQuery .height() return 0 when visible but non-0 when hidden -