Firsly sorry to those in charge if you think I am reposting. My last thread changed topics basically, so maybe should get a more descriptive name.

Secondly, I have written the following method to look for one bitmap inside another larger bitmap. The bitmaps are both 24 bit so I am converting the pixel data into 4 bytes and comparing the first three for each pixel.

I think I am pretty close, but it always returns false even if the smaller image does exist inside the other. Can anyone spot the error of my ways?

ThanksCode:bool comparePixelData(fstream &dFileLarge, Image &dInfoLarge, fstream &dFileSmall, Image &dInfoSmall) { unsigned int pixelLarge[dInfoLarge.imageWidth][dInfoLarge.imageHeight]; unsigned int pixelSmall[dInfoSmall.imageWidth][dInfoSmall.imageHeight]; unsigned char bytesLargeImage[4], bytesSmallImage[4]; bool badPixel; // Iterate through every row for (int fullRow = 0; fullRow < dInfoLarge.imageWidth; fullRow++) { // Iterate through every pixel in the row for (int fullColumn = 0; fullColumn < dInfoLarge.imageHeight; fullColumn++) { bytesLargeImage[0] = (pixelLarge[fullRow][fullColumn] >> 24) & 0xFF; bytesLargeImage[1] = (pixelLarge[fullRow][fullColumn] >> 16) & 0xFF; bytesLargeImage[2] = (pixelLarge[fullRow][fullColumn] >> 8) & 0xFF; bytesLargeImage[3] = pixelLarge[fullRow][fullColumn] & 0xFF; bytesSmallImage[0] = (pixelSmall[0][0] >> 24) & 0xFF; bytesSmallImage[1] = (pixelSmall[0][0] >> 16) & 0xFF; bytesSmallImage[2] = (pixelSmall[0][0] >> 8) & 0xFF; bytesSmallImage[3] = pixelSmall[0][0] & 0xFF; // If the current pixel on the full image is the // same as the top left pixel on the small image... if ((bytesLargeImage[0] == bytesSmallImage[0]) && (bytesLargeImage[1] == bytesSmallImage[1]) && (bytesLargeImage[2] == bytesSmallImage[2])) { // So far, we haven't found a mismatched pixel badPixel = false; // Iterate through every row in the small image for (int smallRow = 0; smallRow < dInfoSmall.imageWidth; smallRow++) { // Iterate through every pixel in the row for (int smallColumn = 0; smallColumn < dInfoSmall.imageHeight; smallColumn++) { bytesLargeImage[0] = (pixelLarge[fullRow + smallRow][fullColumn + smallColumn] >> 24) & 0xFF; bytesLargeImage[1] = (pixelLarge[fullRow + smallRow][fullColumn + smallColumn] >> 16) & 0xFF; bytesLargeImage[2] = (pixelLarge[fullRow + smallRow][fullColumn + smallColumn] >> 8) & 0xFF; bytesLargeImage[3] = pixelLarge[fullRow + smallRow][fullColumn + smallColumn] & 0xFF; bytesSmallImage[0] = (pixelSmall[smallRow][smallColumn] >> 24) & 0xFF; bytesSmallImage[1] = (pixelSmall[smallRow][smallColumn] >> 16) & 0xFF; bytesSmallImage[2] = (pixelSmall[smallRow][smallColumn] >> 8) & 0xFF; bytesSmallImage[3] = pixelSmall[smallRow][smallColumn] & 0xFF; // If the pixel on the full image isn't the same as on the small image... if ((bytesLargeImage[0] != bytesSmallImage[0]) | (bytesLargeImage[1] != bytesSmallImage[1]) | (bytesLargeImage[2] != bytesSmallImage[2])) { // There is a mismatched pixel so set bad pixel to true badPixel = true; // Break out of inner loop break; } } // If we found a bad pixel, break out of outer loop if (badPixel == true) { break; } } // If we passed through all pixels in small image, return location if (badPixel == false) { return true; } } } } // If we looped until here, not match was found return false; }