【发布时间】:2012-04-20 09:17:03
【问题描述】:
这个问题可能看起来是重复的,但它有一种特定的时刻,可能与其他类似的问题不同......
所以...我有两张图片。两者都是在同一个屏幕上捕获的。在我的代码中,将两个(screenCaptureFirst 和 screenCaptureSecond)大图像裁剪成小的裁剪图像(每个裁剪图像都有 32x32 尺寸)。然后我将它们推入两个数组。现在我必须比较两个数组的每个元素。
- (void) differenceDetector{
int index=0;
for (int currentGridY=0; currentGridY<newCapturedImage.size.height; currentGridY+=gridSize) {
for (int currentGridX=0; currentGridX<newCapturedImage.size.width; currentGridX+=gridSize) {
CGRect rect=CGRectMake(currentGridX, currentGridY, gridSize, gridSize);
UIImage *croppedNewImage=[self croppedImage:rect anImage:newCapturedImage];
[arrayOfNewImageGrids addObject:croppedNewImage];
UIImage *croppedOldImage=[self croppedImage:rect anImage:oldCapturedImage];
[arrayOfOldImageGrids addObject:croppedOldImage];
if ([[arrayOfNewImageGrids objectAtIndex:index]isEqual:[arrayOfOldImageGrids objectAtIndex:index]]) {
NSLog(@"Index=%d",index);
}
NSLog(@"newGridArray=%@",[arrayOfNewImageGrids objectAtIndex:index]);
NSLog(@"oldGridArray=%@",[arrayOfOldImageGrids objectAtIndex:index]);
index++;
}
}
问题是,如果比较的结果为 FALSE,尽管在数组中是同一大图像的裁剪图像。
在此先感谢....
【问题讨论】:
标签: objective-c arrays comparison compare elements