In mac osx (cocoa), It is very easy to make a blank image of a specific size and draw to it off screen:
NSImage* image = [[NSImage alloc] initWithSize:NSMakeSi
CoreGraphics is needed here, as UIImage does not have high level functions like what you explained..
UIGraphicsBeginImageContext(CGSizeMake(64,64));
CGContextRef context = UIGraphicsGetCurrentContext();
// drawing code here (using context)
UIImage *image = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();