Friday, January 1, 2010

[android-developers] How can I rotate an Image in different angles?

HI!

I have a png-picture in
ImageView rotatedimage = new ImageView ()

Is there a better way to rotate it in changing directions than the
following way? There I have to create a new picture for every new
rotating angle and add it to the layout:

Bitmap bitmap = BitmapFactory.decodeResource(getResources
(),R.drawable.frosch);
Matrix rotationMatrix = new Matrix();
rotationMatrix.setRotate(grad);

Bitmap rotatedbitmap = Bitmap.createBitmap(frogbitmap, 0, 0,
rotatedbitmap.getWidth(), rotatedbitmap.getHeight(), rotationMatrix,
true);

BitmapDrawable bmd = new BitmapDrawable(rotatedbitmap);

rotatedimage.setImageDrawable(bmd);

mtrx.postRotate(10);
rotatedimage.setImageMatrix(mtrx);


Greetings, Martin

--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscribe@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home


Real Estate