Hello everyone. I have a problem with my checksum and logic. I wrote a program that downloads and read bitmaps and try to generate a checksum for each one. The checksum is used as the name to save the bitmap as so that I don't save the same bitmap every time. The problem is that the RGB values of the images change ever so slighlty every time (Un-noticed by my eyes). Because of this, I decided to use the alpha values to generate unique values inorder to not save the same images over and over. Thing is, with this method.. Two images with the same amount of alpha values will have the same checksum and that's bad for me.
My checksum is as follows:
DWORD CheckSum(const void* Data, size_t Width, size_t Height, uint32_t BitsPerPixel)
{
DWORD CheckSum = 0;
const unsigned char* BuffPos = static_cast<const unsigned char*>(Data);
Height = (Height < 0 ? -Height : Height);
for (size_t I = 12; I < Height; I++) //Has to start at 12.
{
for (size_t J = 0; J < Width; J++)
{
BuffPos+=3;
CheckSum += (BitsPerPixel > 24 ? *(BuffPos++) : 0);
}
if (BitsPerPixel == 24)
BuffPos += Width % 4;
}
return CheckSum;
}
Is there anyway I can still generate unique checksums but at the same time keep it static per image so that I don't end up saving and downloading the same image more than once? I was thinking that I'd have to find the position of each alpha pixel in the image and add those but I cannot figure out how to find the position of them.