The matrix is an Android SDK that provides a matrices class that represents a 3 X 3 matrix
MatrixIt is possible to make 4 basic transformations of the image
- Translate Translation Transformation
- Rotate Rotation transformation
- Scale scaling transformation
- Skew Error-cutting transformation
MatrixThe methods in the class are mainly related to the four transformations, but the calculation process is encapsulated and the object is Bitmap notCanvas
The use of matrix for Translate (panning), scale (scaling), Rotate (rotation) operations, is to manipulate the values of the elements in this matrix to achieve the desired effect.
1. Why is the Matrix 3 X 3?
In fact, the 2 x 2 matrix is sufficient to represent a combination of 3 x 3 in the form of a convenient calculation.
2. What is the role of matrix?
- Mtrans_x and mtrans_y simultaneously control the Translate
- Mscale_x and mscale_y control the scale at the same time
- Mscale_x, mskew_x, mscale_y, Mskew_y also control the Rotate
- From the name, we can see in passing that mskew_x, mskew_y simultaneously control the Skew
3. Example:
@Overrideprotected voidApplytransformation (floatInterpolatedtime, Transformation t) {Matrix Matrix=T.getmatrix (); Matrix.prescale (Interpolatedtime, interpolatedtime);//ZoomMatrix.prerotate (Interpolatedtime * the);//Rotate//The following translate combination is to move the zoom and rotation base point to the center of the entire view, or the system defaults to the upper-left corner of the view as the base pointMatrix.pretranslate (-mwidth/2,-mheight/2); Matrix.posttranslate (Mwidth/2, Mheight/2);}
The fact that these lines of code is represented by a matrix is equivalent to the following:
Reference: http://www.jianshu.com/p/11e062284491
http://geek.csdn.net/news/detail/89873
Matrix in Android