I want to use a UILabel to create an RGBA stream of bytes image representation programmatically (at runtime).
For example, I want to create a UILabel in a specific
CGFloat scale = [[[view window] screen] scale]; CGRect bounds = [view bounds]; CGColorSpaceRef space = CGColorSpaceCreateDeviceRGB(); CGContextRef ctx = CGBitmapContextCreate(NULL, CGRectGetWidth(bounds) * scale, CGRectGetHeight(bounds) * scale, 8, CGRectGetWidth(bounds) * scale * 4, space, kCGImageAlphaPremultipliedLast); CGContextTranslateCTM(ctx, 0.0, CGRectGetHeight(bounds) * scale); CGContextScaleCTM(ctx, scale, -scale); [[view layer] renderInContext:ctx];
Then, use the bytes via CGBitmapContextGetData(myContext). No reason to bother with a UIImage