Android comes with picture clipping

Source: Internet
Author: User

Method:

    Private voidCutphoto (Uri uri) {Intent Intent=NewIntent ("Com.android.camera.action.CROP"); Intent.setdataandtype (URI,"Image/*"); Intent.putextra ("Crop",true); //the scale of the cropping box, 1:1Intent.putextra ("Aspectx", 1); Intent.putextra ("Aspecty", 1); //Size of output picture after croppingIntent.putextra ("Outputx", 250); Intent.putextra ("Outputy", 250); Intent.putextra ("OutputFormat", "JPEG");//Picture FormatIntent.putextra ("Nofacedetection",true);//Remove Face recognitionIntent.putextra ("Return-data",true);    Startactivityforresult (Intent, Request_cut_photo); }

Receive method:

@Overrideprotected voidOnactivityresult (intRequestcode,intResultCode, Intent data) {        Super. Onactivityresult (Requestcode, ResultCode, data); if(ResultCode = =RESULT_OK)Switch(requestcode) { CaseRequest_cut_photo:if(NULL!=data) {Bitmap Bitmap= Data.getparcelableextra ("Data");                    Upload (bitmap); }                     Break; }    }

Large Black Edge problem:

Intent Intent =NewIntent (Intent.action_get_content,NULL). SetType ("Image/*"). PutExtra ("Crop", "true"). PutExtra ("Aspectx", width). PutExtra ("Aspecty", height). PutExtra ("Outputx", width). PutExtra ("Outputy", height). PutExtra ("Scale",true)//Black Edge. PutExtra ("scaleupifneeded",true)//Black Edge. PutExtra (Mediastore.extra_output, Uri.fromfile (f)). PutExtra ("OutputFormat", Bitmap.CompressFormat.JPEG.toString ());

Android comes with picture clipping

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.