Android: How to mimic canvas.concat(Matrix)? -


i concatenating matrices canvas, later able perform canvas.getclipbounds() find current clip of canvas. however, canvas.getclipbounds() returns rect (as opposed rectf), imprecision of believe causing me issues.

so, intend maintain own rectf , transform canvas gets transformed, in end should similar value returned canvas.getclipbounds(), in float precision.

however, not understand how canvas.concat(matrix) effects canvas' clip, because attempts mimic concatenation going poorly. below code i'm trying, values comments. expect 1 of temp rectfs have similar value m_canvas.getclipbounds.tostring() after concatenation, i'm not close. suggestions?

 protected void processconcatmatrix(matrix m)      {         //m.tostring() == matrix{[1103.398, -134.48357, 23.99026][174.76108, 849.0959, -159.39447][0.0, 0.0, 1.0]}         //m_canvas.getmatrix().tostring() == matrix{[1.0, 0.0, 0.0][0.0, -1.0, 706.0][0.0, 0.0, 1.0]}         //m_canvas.getclipbounds.tostring() == rect(0, 0 - 1024, 706)         m_canvas.concat(m);          //m_canvas.getclipbounds().tostring() = rect(0, 0 - 1, 1);         //m_canvas.getmatrix().tostring == matrix{[1103.398, -134.48357, 23.99026][-174.76108, -849.0959, 865.3945][0.0, 0.0, 1.0]}          rectf temp = new rectf(0, 0 - 1024, 706);         matrix m1 = new matrix(m);         m1.maprect(temp);         //temp.tostring() == rectf(-94921.41, -159.39447, 1129903.5, 778257.6)          //not sure if should use parameter matrix, or canvas matrix after concatentation.  let's try both           rectf temp2 = new rectf(0, 0 - 1024, 706);         matrix m2 = new matrix(m_canvas.getmatrix());         m2.maprect(temp2);         //temp2.tostring() == rectf(-94921.41, -777551.6, 1129903.5, 865.3945)          //maybe i'm supposed invert matrices???          rectf temp3 = new rectf(0, 0 - 1024, 706);         matrix m3 = new matrix(m);         m3.invert(m3);         m3.maprect(temp3);         //temp3.tostring() == rectf(0.0, 0.0, 1024.0, 706.0)          //not sure if should use parameter matrix, or canvas matrix after concatentation.  let's try both          rectf temp4 = new rectf(0, 0 - 1024, 706);         matrix m4 = new matrix(m_canvas.getmatrix());         m4.invert(m4);         m4.maprect(temp4);         //temp4.tostring == rectf(0.0, 0.0, 1024.0, 706.0)           //ok, none of these values resembled rect(0, 0 - 1, 1).  doing wrong...   } 

you need matrix variable keep track of concats canvas if want mimic canvas.concatmatrix(matrix);.

    m_canvas.concat(m);     m_matrix.preconcat(m); // did forget this?      rectf temp = new rectf(0, 0, 1024, 706);     matrix m1 = new matrix(m_matrix);     m1.maprect(temp);     //temp.tostring() == rectf(-94921.41, -777551.6, 1129903.5, 865.3945)      rectf temp2 = new rectf(0, 0, 1024, 706);     matrix m2 = new matrix(m_canvas.getmatrix());     m2.maprect(temp2);     //temp2.tostring() == rectf(-94921.41, -777551.6, 1129903.5, 865.3945) // same temp 

Comments

Popular posts from this blog

c# - Send Image in Json : 400 Bad request -

jquery - Fancybox - apply a function to several elements -

An easy way to program an Android keyboard layout app -