Created
September 14, 2010 20:51
-
-
Save threeve/579753 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@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