UIImage

UIGraphicsBeginImageContext(myView.bounds.size); [myView.layer renderInContext:UIGraphicsGetCurrentContext]; UIImage *viewImage = UIGraphicsGetImageFromCurrentImageContext; UIGraphicsEndImageContext; UIGraphicsBeginImageContext(self.bounds.size); [self.layer renderInContext:UIGraphicsGetCurrentContext]; UIImage *viewImage = UIGraphicsGetImageFromCurrentImageContext; UIGraphicsEndImageContext; @interface UIImage (TPAdditions) - (id)initWithContentsOfResolutionIndependentFile:(NSString *)path; + (UIImage*)imageWithContentsOfResolutionIndependentFile:(NSString *)path; @end
 * http://iphonedevelopment.blogspot.com/2008/10/getting-contents-of-uiview-as-uiimage.html
 * http://pastie.org/244916
 * http://snipt.net/nicolascormier/uiview-to-uiimage/
 * http://www.iphonedevsdk.com/forum/iphone-sdk-development/2592-how-copy-image-uiview-another-uiview.html
 * http://www.trembl.org/codec/355/
 * http://atastypixel.com/blog/uiimage-resolution-independence-and-the-iphone-4s-retina-display/

@implementation UIImage (TPAdditions) - (id)initWithContentsOfResolutionIndependentFile:(NSString *)path { if ( [UIScreen instancesRespondToSelector:@selector(scale)] && UIScreen mainScreen] scale] == 2.0 ) {       NSString *path2x = [[path stringByDeletingLastPathComponent]                             stringByAppendingPathComponent:[NSString stringWithFormat:@"%@@2x.%@",                                                             [[path lastPathComponent] stringByDeletingPathExtension],                                                             [path pathExtension];        if ( [[NSFileManager defaultManager] fileExistsAtPath:path2x] ) {            return ;        }    }    return ; } + (UIImage*)imageWithContentsOfResolutionIndependentFile:(NSString *)path {    return ; } @end  - (UIImage*) maskImage:(UIImage *)image withMask:(UIImage *)maskImage {	CGImageRef maskRef = maskImage.CGImage; 	CGImageRef mask = CGImageMaskCreate(CGImageGetWidth(maskRef),		CGImageGetHeight(maskRef),		CGImageGetBitsPerComponent(maskRef),		CGImageGetBitsPerPixel(maskRef),		CGImageGetBytesPerRow(maskRef),		CGImageGetDataProvider(maskRef), NULL, false);	CGImageRef masked = CGImageCreateWithMask([image CGImage], mask);	return ; }  CGImageRef CopyImageAndAddAlphaChannel(CGImageRef sourceImage) {	CGImageRef retVal = NULL;	size_t width = CGImageGetWidth(sourceImage);	size_t height = CGImageGetHeight(sourceImage);	CGColorSpaceRef colorSpace = CGColorSpaceCreateDeviceRGB;	CGContextRef offscreenContext = CGBitmapContextCreate(NULL, width, height, 						8, 0, colorSpace, kCGImageAlphaPremultipliedFirst);	if (offscreenContext != NULL) {		CGContextDrawImage(offscreenContext, CGRectMake(0, 0, width, height), sourceImage);		retVal = CGBitmapContextCreateImage(offscreenContext);		CGContextRelease(offscreenContext);	}	CGColorSpaceRelease(colorSpace);	return retVal; }
 * http://atastypixel.com/blog/achieve-smaller-app-downloads-by-replacing-large-pngs-with-jpeg-mask/
 * http://iPhoneDeveloperTips.com/cocoa/how-to-mask-an-image.html
 * http://pastie.org/418627

- (UIImage*)maskImage:(UIImage *)image withMask:(UIImage *)maskImage { CGImageRef maskRef = maskImage.CGImage; CGImageRef mask = CGImageMaskCreate(CGImageGetWidth(maskRef),						CGImageGetHeight(maskRef),						CGImageGetBitsPerComponent(maskRef),						CGImageGetBitsPerPixel(maskRef),						CGImageGetBytesPerRow(maskRef),						CGImageGetDataProvider(maskRef), NULL, false); CGImageRef sourceImage = [image CGImage]; CGImageRef imageWithAlpha = sourceImage; //add alpha channel for images that don't have one (ie GIF, JPEG, etc...) //this however has a computational cost if (CGImageGetAlphaInfo(sourceImage) == kCGImageAlphaNone) { imageWithAlpha = CopyImageAndAddAlphaChannel(sourceImage); }	CGImageRef masked = CGImageCreateWithMask(imageWithAlpha, mask); CGImageRelease(mask); //release imageWithAlpha if it was created by CopyImageAndAddAlphaChannel if (sourceImage != imageWithAlpha) { CGImageRelease(imageWithAlpha); }	UIImage* retImage = ; CGImageRelease(masked); return retImage; } UIImageView * roundedView = ; // Get the Layer of any view CALayer * l = [roundedView layer]; [l setMasksToBounds:YES]; [l setCornerRadius:10.0];
 * http://stackoverflow.com/questions/205431/rounded-corners-on-uiimage

// You can even add a border [l setBorderWidth:4.0]; [l setBorderColor:UIColor blueColor] CGColor;
 * http://www.weask.us/entry/obtain-uicolor-uiimage-iphone
 * http://www.weask.us/entry/uiimage-rounded-corners