请检查此代码并帮助我,,,
CGImageRef cRef = CGImageRetain(im.CGImage);
NSData* pixelData = (NSData*) CGDataProviderCopyData(CGImageGetDataProvider(cRef));
// return pointer to data
unsigned char* pixelBytes = (unsigned char *)[pixelData bytes];
// step through char data
for(int k = 0; k < [pixelData length]; k += 4) {
// change accordingly
pixelBytes[k] = pixelBytes[k];
pixelBytes[k+1] = pixelBytes[k+1];
pixelBytes[k+2] = pixelBytes[k+2];
pixelBytes[k+3] = 255;
}
NSData* newPixelData = [NSData dataWithBytes:pixelBytes length:[pixelData length]];
CFDataRef imgData = (CFDataRef)pixelData;
CGDataProviderRef imgDataProvider = CGDataProviderCreateWithCFData(imgData);
CGImageRef throughCGImage = CGImageCreateWithPNGDataProvider(imgDataProvider, NULL, YES, kCGRenderingIntentDefault);
UIImage* newImage = [UIImage imageWithCGImage:throughCGImage];
NSLog(@"newImage: %@", newImage);
一些数据即将到来,但它没有被添加到 UIImageView..它显示为空白。