How to get the Raw pixel data from CGImage
iphone, objective-c
Solution
You can get the rawdata by calling
CFDataRef rawData = CGDataProviderCopyData(CGImageGetDataProvider(aCGImageRef));
You can step through pixels like this:
UInt8 * buf = (UInt8 *) CFDataGetBytePtr(rawData);
CFIndex length = CFDataGetLength(rawData);
for(unsigned long i=0; i<length; i+=4)
{
int r = buf[i];
int g = buf[i+1];
int b = buf[i+2];
}
CFRelease(rawData);
Problem
How to get the Pixel Data of UIimage after scaling and moving,I wan to get the CGImage Pixel Data and then get the UIImage from CGImage Pixel Data.How can we do this?.