Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

what is the difference between `Matrix.setRotate` and `Matrix.postRotate`

I'm trying to rotate a given bitmap using android Matrix object.

I want to send it to rotated to my server and I'm using Android API8.

Should i use Matrix.setRotate or Matrix.postRotate ?

What is the difference between the two?

like image 237
Elad Benda Avatar asked May 18 '14 07:05

Elad Benda


2 Answers

From the API Reference, setRotate sets a particular absolute rotation (around either (0,0) or some other user-supplied point), while postRotate adds to the rotation of the matrix it is called on.

The question of which one should I use is best answered by trying each and seeing which one gives you the result that you want.

like image 168
merlin2011 Avatar answered Nov 17 '22 04:11

merlin2011


setRotate will replace the matrix operations already performed with the rotation specified. postRotate will use the current matrix values and transform them using the rotation specified.

If you want to translate, then rotate you would setTranslate, then postRotate. If you simply want to rotate and are starting with a new Matrix then you technically can setRotate or postRotate, since your matrix will initially be the identity.

I've included the API reference to the Matrix object. I didn't consider it a universally accessible explanation though.

like image 27
Greg Bogumil Avatar answered Nov 17 '22 04:11

Greg Bogumil