I would definitely recommend using tools to determine which message takes the most time so you can really break it. In addition, I wrote several methods that I think should do the same with much less code, but you should write everything down the way you do to really save the settings. Here they are all the same:
-(CGContextRef)mergeImage:(UIImage *)img1 withImage:(UIImage *)img2 { CGSize size = [ImageToolbox getScreenSize]; CGRect rect = CGRectMake(0, 0, size.width, size.height); UIGraphicsBeginImageContextWithOptions(size, YES, 1.0); CGContextRef context = UIGraphicsGetCurrentContext(); CGContextSetRenderingIntent(context, kCGRenderingIntentSaturation); [img1 drawInRect:rect]; [img2 drawInRect:rect]; UIGraphicsEndImageContext(); return context; }
Or, if you want to get a combined image right away:
- (UIImage *)mergeImage:(UIImage *)img1 withImage:(UIImage *)img2 { CGSize size = [ImageToolbox getScreenSize]; CGRect rect = CGRectMake(0, 0, size.width, size.height); UIGraphicsBeginImageContextWithOptions(size, YES, 1.0); CGContextRef context = UIGraphicsGetCurrentContext(); CGContextSetRenderingIntent(context, kCGRenderingIntentSaturation); [img1 drawInRect:rect]; [img2 drawInRect:rect]; UIImage *image = UIGraphicsGetImageFromCurrentImageContext(); UIGraphicsEndImageContext(); return image; }
I have no idea whether they will be faster or not, but I really donβt know how to speed up what you have very easily if you did not have a profile profile.
In any case, I hope this helps.
source share