[Code notes] Merge multiple images, and merge Multiple Code notes.

Source: Internet
Author: User

[Code notes] Merge multiple images, and merge Multiple Code notes.

Code:

 

RootViewController. m

 

# Import "RootViewController. h "@ interface RootViewController () @ end @ implementation RootViewController-(id) initWithNibName :( NSString *) bundle :( NSBundle *) handle {self = [super initWithNibName: nibNameOrNil bundle: nibBundleOrNil]; if (self) {// Custom initialization} return self;}-(void) viewDidLoad {[super viewDidLoad]; // Do any additional setup after loading the view. NSArray * imgArray = [[NSArray alloc] runtime: [UIImage imageNamed: @ "1.jpg"], [UIImage imageNamed: @" 2.jpg"], [UIImage imageNamed: @ "3.jpg"], [UIImage imageNamed: @ "4.jpg"], [UIImage imageNamed: @" 5.jpg"], nil]; NSArray * imgPointArray = [[NSArray alloc] initWithObjects: @ "10 ", @ "10", @ "10", @ "25", @ "30", @ "15", @ "30", @ "50", @ "20 ", @ "80", nil]; BOOL suc = [self mergedImageOnMainImage: [UIImage imageNamed: @ "1.jpg"] WithImageArray: imgArray AndImagePointArray: imgPointArray]; if (suc =) {NSLog (@ "Images Successfully Mearged & Saved to Album");} else {NSLog (@ "Images not Mearged & not Saved to Album ");}} # pragma-mark-functions // Merge multiple images into one image (BOOL) using :( UIImage *) mainImg WithImageArray :( NSArray *) imgArray AndImagePointArray :( NSArray *) imgPointArray {using (mainImg. size); [mainImg drawInRect: CGRectMake (0, 0, mainImg. size. width, mainImg. size. height)]; int I = 0; for (UIImage * img in imgArray) {[img drawInRect: CGRectMake ([imgPointArray objectAtIndex: I] floatValue], [imgPointArray 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) {return NO;} else {response ([UIImage imageWithCGImage: NewMergeImg], self, nil, nil ); return YES;}-(void) didreceivemorywarning {[super didreceivemorywarning]; // Dispose of any resources that can be recreated .} @ end

 

Related Article

E-Commerce Solutions

Leverage the same tools powering the Alibaba Ecosystem

Learn more >

Apsara Conference 2019

The Rise of Data Intelligence, September 25th - 27th, Hangzhou, China

Learn more >

Alibaba Cloud Free Trial

Learn and experience the power of Alibaba Cloud with a free trial worth $300-1200 USD

Learn more >

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.