In the example of Android ApiDemos example resolution (74): Graphics-> PolyToPoly describes the coordinates before and after known transformations, and then obtains the transformation Matrix based on Matrix. setPolyToPoly.
In addition, Matrix also supports two rectangles before and after transformation, and the corresponding transformation Matrix is obtained through setRectToRect. Let's take a look at the definition of setRectToRect:
Public boolean setRectToRect (RectF src, RectF dst, Matrix. ScaleToFit stf)
Rectangle before src Coordinate Transformation
Rectangle after dst Coordinate Transformation
Stf rectangular scaling Option
Because the parameters before and after the coordinate transformation can be any rectangle, in this case, the aspect ratio of the rectangle before and after the transformation is not necessarily the same, the specified Matrix. ScaleToFit option is provided to determine the scaling option. Matrix. ScaleToFit defines four options:
CENTER: Keep the aspect ratio of the rectangle before the coordinate transformation, and fill the transformed rectangle to the maximum extent. At least one side overlaps the target rectangle.
END: Keep the aspect ratio of the rectangle before the coordinate transformation, and fill the transformed rectangle to the maximum extent. At least one side overlaps the target rectangle. END provides the right bottom alignment.
FILL: the aspect ratio of the rectangle may be changed to ensure that the transformation is consistent with the length and width of the target matrix.
START: Keep the aspect ratio of the rectangle before the coordinate transformation, and fill the transformed rectangle to the maximum extent. At least one side overlaps the target rectangle. START provides upper left alignment.
ScaleToFit draws two ovans (one vertical and one horizontal), and the two circles use the transformation results of four different ScaleToFit options:
Author: mapdigit