I wanted to easily compose UIImage on top of another background image, so I wrote a category method for UIImage adapted from mix two uiimages based on alpha / transparency of the top image :
- (UIImage *) blendedImageOn:(UIImage *) backgroundImage {
NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init];
UIGraphicsBeginImageContext(backgroundImage.size);
CGRect rect = CGRectMake(0, 0, backgroundImage.size.width, backgroundImage.size.height);
[backgroundImage drawInRect:rect];
[self drawInRect:rect];
UIImage* blendedImage = [UIGraphicsGetImageFromCurrentImageContext() retain];
UIGraphicsEndImageContext();
[pool release];
return [blendedImage autorelease];
}
Unfortunately, my application using the above method downloads about 20 images and mixes them with background and glossy images (maybe about 40 calls), is dropped to the device.
"" , malloc, drawInRect: . drawInRect: CGContextDrawImage, . AutoReleasePool , ; .
, , , , . - , ? - ?
-
1: . , 20 , :
UIImage *blendedImage = [newImage blendedImageOn:backgroundImage];
, , , , UIImages , . , .
-
2: , blendedImageOn: , .
-
3: UIImage, - . , UIImage, , , , .
, ( , !): 20 ?