I am trying to do an iteration on pixels to change the RGBA values of a UIImage without using OpenGL. I tried testing out iteration performance using the below code but was very displeased. It seemed like I could only get a few thousand iterations per second. And for a UIImage with several hundred thousand pixels, this would take way TOO LONG...Anybody have any suggestions on how to improve performance or how long operations like these should normally take?
-(UIImage*)modifyPixels:(UIImage*)originalImage
{
NSData* pixelData = (NSData*)CGDataProviderCopyData(CGImageGetDataProvider(originalImage.CGImage));
void* pixelBytes = [pixelData bytes];
// Take away the red pixel, assuming 32-bit RGBA
for(int i = 0; i < [pixelData length]; i += 4) {
NSLog(@" %ith iteration (%i / %i / %i / %i)", i, pixelData[i], pixelData[i+1], pixelData[i+2], pixelData[i+3]);
}
//NSData* newPixelData = [NSData dataWithBytes:pixelBytes length:[pixelData length]];
//UIImage* newImage = [UIImage imageWithData:newPixelData];
return originalImage;
}