The implementation of Android photos, capture and cropping from albums

Source: Internet
Author: User

First of all these functions are through the intent to start the service of the system to achieve, so naturally there is a corresponding action. The relevant actiong are as follows:

Photo--mediastore.action_image_capture ("Android.media.action.IMAGE_CAPTURE")

Album--intent.action_get_content ("Android.intent.action.GET_CONTENT" to be set at the same time, Intent.settype ("image/*");)

Crop--"Com.android.camera.action.CROP" (need to set picture source Intent.setdataandtype (URI, "image/*"); )

The parameters in the table below are the following additional features when sending intent, adding some additional data constraints

Additional options Data type Describe
Crop String Send clipping signal intent.putExtra("crop", "true");
Aspectx Int intent.putExtra( "aspectX" Scale , 1); in the x direction
Aspecty Int intent.putExtra( "aspectY" proportions , 1); in the y direction
Outputx Int intent.putExtra( "outputX" width , 240); of the cropping area
Outputy Int The intent.putExtra( "outputX" height , 320); of the cropping area
Scale Boolean Whether to preserve intent.putExtra( "scale" , true); proportions
Return-data Boolean Whether to keep data back intent.putExtra( "return-data" , true); in bitmap
Data Parcelable The corresponding bitmap data intent.putExtra( "data" , imgaeUri);
Circlecrop Boolean Circular cropping area intent.putExtra( "circleCrop" , true);
Mediastore.extra_output ("OUTPUT") Uri

Point the URI to the corresponding file:///... Intent.putextra (mediastore.extra_output, Imageuri);

OutputFormat String Output format Intent.putextra ("OutputFormat", Bitmap.CompressFormat.JPEG.toString ());
Nofacedetection Boolean Whether to cancel the face recognition function Intent.putextra ("Nofacedetection", true);

Again, because these operations require results to be returned, the Startactivityforresult is used to send the intent, and then the activity is received for processing.

Android photography, getting and cropping from albums

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.