2015-04-06 52 views

回答

1

我不知道,這將使這個開箱即用的任何功能。 但是你可以編寫自己的功能。所有你需要做的就是逐個獲取像素的顏色,並確定它們是否是正確的。

爲了得到這個,你可以使用下面的代碼。

CGImageRef image = [myUIImage CGImage]; 
NSUInteger width = CGImageGetWidth(image); 
NSUInteger height = CGImageGetHeight(image); 
CGColorSpaceRef colorSpace = CGColorSpaceCreateDeviceRGB(); 
unsigned char *rawData = malloc(height * width * 4); 
NSUInteger bytesPerPixel = 4; 
NSUInteger bytesPerRow = bytesPerPixel * width; 
NSUInteger bitsPerComponent = 8; 
CGContextRef context = CGBitmapContextCreate(rawData, width, height, bitsPerComponent, bytesPerRow, colorSpace, kCGImageAlphaPremultipliedLast | kCGBitmapByteOrder32Big); 
CGColorSpaceRelease(colorSpace); 

CGContextDrawImage(context, CGRectMake(0, 0, width, height)); 
CGContextRelease(context); 

// Now your rawData contains the image data in the RGBA8888 pixel format. 
int byteIndex = (bytesPerRow * yy) + xx * bytesPerPixel; 
red = rawData[byteIndex]; 
green = rawData[byteIndex + 1]; 
blue = rawData[byteIndex + 2]; 
alpha = rawData[byteIndex + 3]; 

這最初發布此question.