Codec ░ Combining Images with UIImage & CGContext – (Offscreen drawing)

334Combining Images with UIImage & CGContext – (Offscreen drawing)

In Cocoa NSImage has a lockFocus method, that allows to draw images offscreen and combine them into one.

[img lockFocus];
//...
[img unlockFocus];

On the iPhone, UIImage lacks the lockFocus methods, instead the following:

UIGraphicsBeginImageContext(CGSizeMake(64.0f, 64.0f));
// ...
[img drawAtPoint:CGPointZero];
[view drawRect:CGRectMake(0.0f, 0.0f, 64.0f, 64.0f)];

UIImage *outputImg =
	UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();

347UIImage → pixelData → UIImage Rountrip 338Accessing RGBA Pixel Data 175Curling Images at Twitter 73Concatenating Strings @”string1″ @”string2″ @”stringN” 16UIImage & cache