Friday, August 19, 2011

Get pixel data

NSString * path = [[NSBundle mainBundle] pathForResource:@"filename" ofType:@"jpg"];

UIImage * img = [[UIImage alloc]initWithContentsOfFile:path];

CGImageRef image = [img CGImage];

CFDataRef data = CGDataProviderCopyData(CGImageGetDataProvider(image));

const unsigned char * buffer = CFDataGetBytePtr(data);