int searchForArea( SDL_Surface *base, SDL_Surface *searchedArea, Tpoint *leftTop) { if ( base->w < searchedArea->w || base->h < searchedArea->h || searchedArea->w * searchedArea->h == 0 ) {//dimensions of searched area are out of range return -1; } //number of iteration of random checking int randomCount = log10(searchedArea->w * searchedArea->h); Uint8 r1, g1, b1, r2, g2, b2; for (int h = 0; h + searchedArea->h <= base->h; h++) { for (int w = 0; w + searchedArea->w <= base->w ; w++) { do { SDL_GetRGB( getPixel(base, w + searchedArea, h), image1->format, &r1, &g1, &b1); SDL_GetRGB(getPixel(image2, x, y), image1->format, &r2, &g2, &b2); } while(); } } leftTop->X = w; leftTop->Y = h; } //searchForArea()