Android ApiDemos example (78): Graphics-& gt; ScaleToFit

Source: Internet
Author: User

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
 

 


Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.