我希望在Objective-C中完成此操作,我不能使用任何webservices / frameworks。
我现在使用以下代码,仅当两个图像相同时才会显示YES
。
- (BOOL)isEqualToByBytes:(UIImage *)oneImage with:(UIImage *)otherImage {
NSData *imagePixelsData = (NSData *)CFBridgingRelease(CGDataProviderCopyData(CGImageGetDataProvider(oneImage.CGImage)));
NSData *otherImagePixelsData = (NSData *)CFBridgingRelease(CGDataProviderCopyData(CGImageGetDataProvider(otherImage.CGImage)));
BOOL comparison = [imagePixelsData isEqualToData:otherImagePixelsData];
CGDataProviderRelease((CGDataProviderRef)imagePixelsData);
CGDataProviderRelease((CGDataProviderRef)otherImagePixelsData);
return comparison;
}