Tuesday, July 26, 2011

Android - Matrix Pre, Post and Set methods

Matrix provide pre, post and set method for matrix transformation.

Pre and post are generally used to concatenate the existing Matrix value.

Set is used to overwrite the current matrix value with the existing ones.

But, please use Set method with care. It seems that Set methods will overwrite all the value in the 3x3 matrix. So, if you perform a postScale, then a setTranslate, the value set by postScale will be gone.

So, if you really want to set a translate with respect to x=0 and y=0, you can try the following

The following is trying to concat a scale, then perform a translation with respect to (0,0)

Matrix m = new Matrix();
//do a scale and post concat
m.postScale(2.0f, 2.0f);
//get the existing 3x3 matrix values
float mVal[] new float[9];
// erase the current value before concat new value
m.postTranslate(-mVal[Matrix.MTRANS_X], 0);
m.postTranslate(100.0f, 0);


  1. I am new to android.So any help is really a life saver for me.As you gave tip about set operation and shared the sample code.Thanks I was looking for same.
    electronic signatures

  2. ldap online training| ldap training| call us+919000444287 ...
    LDAP Online Training, LDAP training, LDAP course contents, LDAP , call us: +919000444287,dharani@21cssindia.com.


Oracle - Reclaim disk space

Oracle does not release disk space even if you had delete the data or tablespace. If you have enterprise manager, you should use it to  rec...