Call album how to set Trim-B

Source: Internet
Author: User

Create a photo album Controller
Uiimagepickercontroller *pc = [[Uiimagepickercontroller alloc] init];

Photo source
Uiimagepickercontrollersourcetypephotolibrary//Album Gallery
Uiimagepickercontrollersourcetypecamera//Camera (simulator using phase chance crash, real machine can)
Uiimagepickercontrollersourcetypesavedphotosalbum Photo Gallery
Pc.sourcetype = uiimagepickercontrollersourcetypephotolibrary;

Whether to allow editing of pictures
pc.allowsediting = YES;

Pc.delegate = self; Set up a proxy <UINavigationControllerDelegate,UIImagePickerControllerDelegate>//album Controller to comply with two protocols

Present the album Controller.
[Self presentviewcontroller:pc animated:yes completion:nil];

Album agent can be set inside
Proxy method for #pragma mark-album Controller
Select the image to be called after completion
-(void) Imagepickercontroller: (Uiimagepickercontroller *) Picker Didfinishpickingmediawithinfo: (NSDictionary *) info
{
NSLog (@ "%@", info); Get a dictionary

Save the edited picture, there is information in the dictionary
Self.imageView.image = info[@ "Uiimagepickercontrollereditedimage"];

Data turns into image
UIImage imagewithdata:<# (NSData *) #>

Image (. PNG) into data
Uiimagepngrepresentation (< #UIImage *image#>)
. jpg turns into data
Parameter 2. Compression factor, 0-1.0
NSData *dataoriginal = uiimagejpegrepresentation (Self.imageView.image, 1.0);
NSData *dataedited = uiimagejpegrepresentation (self.imageView.image, 0.3);

NSLog (@ "%@", Nshomedirectory ());

Save the original picture to the sandbox
[Dataoriginal writetofile:[nsstring stringwithformat:@ "%@/library/1.jpg", Nshomedirectory ()] Atomically:YES];
The edited pictures are also saved in a convenient comparison (editing will compress, the image after the compression of the external memory smaller, put the General Assembly Blur)
[dataedited writetofile:[nsstring stringwithformat:@ "%@/library/2.jpg", Nshomedirectory ()] Atomically:YES];

Return
[Picker Dismissviewcontrolleranimated:yes Completion:nil];
}

Call album how to set Trim-B

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.