Elad Benda
Elad Benda

Reputation: 36664

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?

Upvotes: 9

Views: 10252

Answers (2)

Greg Bogumil
Greg Bogumil

Reputation: 1923

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.

Upvotes: 10

merlin2011
merlin2011

Reputation: 75585

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.

Upvotes: 9

Related Questions