Skip to content

Instantly share code, notes, and snippets.

@threeve
Created September 14, 2010 20:51
Show Gist options
  • Save threeve/579753 to your computer and use it in GitHub Desktop.
Save threeve/579753 to your computer and use it in GitHub Desktop.
@implementation MyViewController
- (void)viewDidLoad
{
[super viewDidLoad];
static const NSUInteger const width = 32;
static const NSUInteger const height = 32;
uint32_t pixels[width * height];
for (int p = 0; p < 1024; ++p)
{
pixels[p] = 0xffff0000;
}
CGContextRef ctx = CGBitmapContextCreate(pixels, width, height, 8, width * sizeof(uint32_t), CGColorSpaceCreateDeviceRGB(), kCGImageAlphaPremultipliedLast);
CGImageRef image = CGBitmapContextCreateImage(ctx);
UIImage *img = [UIImage imageWithCGImage:image];
UIImageView *imgView = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, 32, 32)];
imgView.image = img;
[self.view addSubview:imgView];
}
@end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment