Multiple photo synthesis 1 sheets

Source: Internet
Author: User

Code:

- (void) viewdidload {[Super viewdidload]; //additional setup after loading the view, typically from a nib.Nsarray*imgarray =[ [Nsarray alloc] initwithobjects: [UIImage imagenamed:@"1.jpg"], [UIImage imagenamed:@"2.jpg"], [UIImage imagenamed:@"3.jpg"], [UIImage imagenamed:@"4.jpg"], [UIImage imagenamed:@"5.jpg"], nil]; //the data in Imgpointarray is the x, y coordinates of the picture after the image is composited. Nsarray *imgpointarray =[[Nsarray alloc] Initwithobjects:@"Ten",@"Ten",                              @" -",@" -",                              @" -",@" -",                              @" +",@" +",                              @" -",@" -", nil]; BOOL suc= [Self mergedimageonmainimage:[uiimage imagenamed:@"1.jpg"] Withimagearray:imgarray Andimagepointarray:imgpointarray]; if(suc = =YES) {NSLog (@"Images successfully mearged & Saved to Album"); }    Else{NSLog (@"Images not mearged & Don't Saved to Album"); }}#pragma-mark-functions//multiple pictures to synthesize a picture-(BOOL) Mergedimageonmainimage: (UIImage *) mainimg Withimagearray: (Nsarray *) Imgarray Andimagepointarray: (NSArray *) imgpointarray{Uigraphicsbeginimagecontext (mainimg.size); [Mainimg Drawinrect:cgrectmake (0,0, MainImg.size.width, MainImg.size.height)]; inti =0;  for(UIImage *imginchImgarray) {[img Drawinrect:cgrectmake ([[Imgpointarray objectatindex:i] floatvalue], [[IMGP Ointarray objectatindex:i+1] Floatvalue], img.size.width, img.size.height)]; I+=2; } cgimageref newmergeimg=Cgimagecreatewithimageinrect (Uigraphicsgetimagefromcurrentimagecontext (). Cgimage, CGRectMake (0,0, MainImg.size.width, mainImg.size.height));    Uigraphicsendimagecontext (); if(Newmergeimg = =Nil) {        returnNO; }    Else{uiimagewritetosavedphotosalbum ([UIImage imagewithcgimage:newmergeimg], self, nil, nil); returnYES; }}

Multiple photo synthesis 1 sheets

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.