title: Hashing an image (series of rgb bytes)
body: <p>i'm developing an application that involves <em>screen capture and hashing</em> with C/C++. The image i'm capturing is about <strong>250x250</strong> in dimensions and i'm using the winapi <strong><a href="http://msdn.microsoft.com/en-us/library/windows/desktop/bb759853%28v=vs.85%29.aspx" rel="nofollow">HashData</a></strong> function for hashing. </p>
  
  <p><em>My goal is to compare 2 hashes (etc. 2 images of 250x250) and instantly tell if they're equal.</em></p>
  
  <p>My code:</p>
  
  <pre><code>           const int PIXEL_SIZE = (sc_part.height * sc_part.width)*3;
             BYTE* pixels = new BYTE[PIXEL_SIZE];
             for(UINT y=0,b=0;y&lt;sc_part.height;y++) {
                for(UINT x=0;x&lt;sc_part.width;x++) {
                   COLORREF rgb = sc_part.pixels[(y*sc_part.width)+x];
                   pixels[b++] = GetRValue(rgb);
                   pixels[b++] = GetGValue(rgb);
                   pixels[b++] = GetBValue(rgb);
                }
             }
             const int MAX_HASH_LEN = 64;
             BYTE Hash[MAX_HASH_LEN] = {0};
             HashData(pixels,PIXEL_SIZE,Hash,MAX_HASH_LEN);
  
             ... i have now my variable-size hash, above example uses 64 bytes
  
             delete[] pixels;
  </code></pre>
  
  <p>I've tested different hash sizes and their ~time for completion, which was roughly about:</p>
  
  <pre><code>           32 bytes  = ~30ms
             64 bytes  = ~47ms
             128 bytes = ~65ms
             256 bytes = ~125ms
  </code></pre>
  
  <p>My question is: </p>
  
  <p><strong>How long should the hash code be for a 250x250 image to prevent any duplicates, like never?</strong> </p>
  
  <p>I don't like a hash code of <em>256</em> characters, since it will cause my app to run slowly (since the captures are very frequent). Is there a <code>"safe"</code> hash size per dimensions of image for comparing?</p>
  
  <p>thanx</p>