Android calls the solution of image size scaling after native image clipping

In Android development, if the image is cropped after taking pictures, if it is cropped by calling the system, it is as follows:

In this way, the picture will be cropped, but there will be a problem. When the shape of the picture selected in the cropping box is different from that of the entered Cropx and xropy, for example, the incoming parameter value is a rectangle of W > H, and the selection box selects a rectangle of W < h, this will cause the cropped picture result to be compressed and deformed.

In order to solve the problem of compression deformation, my idea is as follows:

1. Crop the picture first without setting the default size of the cropped picture.

2. Zoom the cropped picture. Scaling is the scaling of the angle matrix

The code is as follows:

one

two

2 code, set whether the picture is enlarged horizontally or vertically by judging the W and H ratio of the clipping box. The enlarged effect can basically meet the demand.

The above is the whole content of this article. I hope it will be helpful to your study, and I hope you can support programming tips.

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>