Android Programming/JAVA : rotating a Square about its centre.

lixiang9779

Member
Joined
Jul 19, 2009
Messages
483
Reaction score
0
Hi , new to programming in android/ java, i am wondering is it possible to rotate a square about its centre.
Or even rotate a Bitmap about its centre.




c.drawRect(left, top, right, bottom, paint);



I tried googling but the solutions are rather alien to me, can anyone explain the concept of rotation?

Thanks!
 
Joined
Nov 27, 2012
Messages
224
Reaction score
0
Hi , new to programming in android/ java, i am wondering is it possible to rotate a square about its centre.
Or even rotate a Bitmap about its centre.




c.drawRect(left, top, right, bottom, paint);



I tried googling but the solutions are rather alien to me, can anyone explain the concept of rotation?

Thanks!
Dear lixiang9779,

Google has plenty of answers.
java - Rotate a saved bitmap in android - Stack Overflow

Basically, you would need to translate the Bitmap into a matrix, which you will then provide the angle of rotation.

More good years ahead,
Thank you
 

lixiang9779

Member
Joined
Jul 19, 2009
Messages
483
Reaction score
0
Didnt really thought of using a bitmap.

i was thinking of a canvas drawn rectangle using canvas.drawRect method.

But, cool at least i know it rotates, will try that in the next weekend!:s13:
 

davidktw

Arch-Supremacy Member
Joined
Apr 15, 2010
Messages
13,546
Reaction score
1,299
Dear lixiang9779,

Google has plenty of answers.
java - Rotate a saved bitmap in android - Stack Overflow

Basically, you would need to translate the Bitmap into a matrix, which you will then provide the angle of rotation.

More good years ahead,
Thank you

Generally, if the objective is to draw anything rotated, one doesn't need to save the bitmap rotated first. Just apply affine transformation on the Graphics Context first and draw the rectangle. Transformation will be applied on the fly during rasterisation.
 
Important Forum Advisory Note
This forum is moderated by volunteer moderators who will react only to members' feedback on posts. Moderators are not employees or representatives of HWZ Forums. Forum members and moderators are responsible for their own posts. Please refer to our Community Guidelines and Standards and Terms and Conditions for more information.
Top