Android programming realizes the function of calling system library and cutting pictures

This paper describes the function of calling system library and cutting pictures by Android programming. Share with you for your reference, as follows:

In Android development, calling system gallery and cutting photos is a common demand. Compared with realizing this function by yourself, calling the system directly has many advantages, such as no need to consider screen adaptation, no need to worry about performance problems, and so on. Therefore, for general requirements, it is recommended to directly call the functions of the system, which is simple and efficient!

First, the rendering:

1、 Only call the system Gallery (no clipping) and return the pictures selected by the user. (only single selection is supported. If you need to select more than one, you need to implement it yourself. You can refer to Android programming to realize the source code of imitation QQ photo selector (displayed by photo album classification and added by multiple selection.)

1. Jump to the system gallery page:

2. Receive the information returned by the system Gallery (that is, the photo selected by the user) in onactivityresult.

2、 Jump to the system Gallery, select photos and cut them.

1. Jump to the system Gallery:

Data to be transferred before jump:

(1) Crop: pass a true to tell the system that clipping is required. (2) Aspectx and aspecty: the aspect ratio of the clipping box. (3) Output: a URI built by the file path cachefile needs to be passed. After selecting a photo on the gallery page, the user will automatically enter the clipping page. After clipping, the picture will be saved in the cachefile.

After clipping, the onactivityresult method will also be called back (the resultcode is result_ok), and the picture will be saved in the cachefile. Therefore, you can directly use this file, for example, set it as the resource of ImageView.

More readers interested in Android related content can view the special topics of this site: summary of Android graphics and image processing skills, introduction and advanced tutorial of Android development, summary of Android debugging skills and common problem solving methods, summary of Android basic component usage, summary of Android view skills, summary of Android layout skills, and Android control usage summary

I hope this article will help you in Android programming.

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
分享
二维码
< <上一篇
下一篇>>