int findBitmapInRect(MMBitmapRef needle, MMBitmapRef haystack, MMPoint *point, MMRect rect, float tolerance) { UTHashTable badShiftTable; int ret; initBadShiftTable(&badShiftTable, needle); ret = findBitmapInRectAt(needle, haystack, point, rect, tolerance, MMPointZero, &badShiftTable); destroyBadShiftTable(&badShiftTable); return ret; }
size_t countOfBitmapInRect(MMBitmapRef needle, MMBitmapRef haystack, MMRect rect, float tolerance) { size_t count = 0; MMPoint point = MMPointZero; UTHashTable badShiftTable; initBadShiftTable(&badShiftTable, needle); while (findBitmapInRectAt(needle, haystack, &point, rect, tolerance, point, &badShiftTable) == 0) { const size_t scanWidth = (haystack->width - needle->width) + 1; ++count; ITER_NEXT_POINT(point, scanWidth, 0); } destroyBadShiftTable(&badShiftTable); return count; }
MMPointArrayRef findAllBitmapInRect(MMBitmapRef needle, MMBitmapRef haystack, MMRect rect, float tolerance) { MMPointArrayRef pointArray = createMMPointArray(0); MMPoint point = MMPointZero; UTHashTable badShiftTable; initBadShiftTable(&badShiftTable, needle); while (findBitmapInRectAt(needle, haystack, &point, rect, tolerance, point, &badShiftTable) == 0) { const size_t scanWidth = (haystack->width - needle->width) + 1; MMPointArrayAppendPoint(pointArray, point); ITER_NEXT_POINT(point, scanWidth, 0); } destroyBadShiftTable(&badShiftTable); return pointArray; }