Here's a powershell script that produces an SHA256 hash on only the bytes of the image as extracted using LockBits. This should produce a unique hash for each file that is different. Please note, that I didn't include the file iterating code, however it should be a relatively simple task to replace the currently hardcode c:\test.bmp with a foreach directory iterator. The variable $final contains the hex - ascii string of the final hash.
[System.Reflection.Assembly]::LoadWithPartialName("System.Drawing")
[System.Reflection.Assembly]::LoadWithPartialName("System.Drawing.Imaging")
[System.Reflection.Assembly]::LoadWithPartialName("System.Security")
$bmp = [System.Drawing.Bitmap]::FromFile("c:\\test.bmp")
$rect = [System.Drawing.Rectangle]::FromLTRB(0, 0, $bmp.width, $bmp.height)
$lockmode = [System.Drawing.Imaging.ImageLockMode]::ReadOnly
$bmpData = $bmp.LockBits($rect, $lockmode, $bmp.PixelFormat);
$dataPointer = $bmpData.Scan0;
$totalBytes = $bmpData.Stride * $bmp.Height;
$values = New-Object byte[] $totalBytes
[System.Runtime.InteropServices.Marshal]::Copy($dataPointer, $values, 0, $totalBytes);
$bmp.UnlockBits($bmpData);
$sha = new-object System.Security.Cryptography.SHA256Managed
$hash = $sha.ComputeHash($values);
$final = [System.BitConverter]::ToString($hash).Replace("-", "");
Perhaps the equivalent C# code will also aid you in understanding:
private static String ImageDataHash(FileInfo imgFile)
{
using (Bitmap bmp = (Bitmap)Bitmap.FromFile(imgFile.FullName))
{
BitmapData bmpData = bmp.LockBits(new Rectangle(0, 0, bmp.Width, bmp.Height), System.Drawing.Imaging.ImageLockMode.ReadOnly, bmp.PixelFormat);
IntPtr dataPointer = bmpData.Scan0;
int totalBytes = bmpData.Stride * bmp.Height;
byte[] values = new byte[totalBytes];
System.Runtime.InteropServices.Marshal.Copy(dataPointer, values, 0, totalBytes);
bmp.UnlockBits(bmpData);
SHA256 sha = new SHA256Managed();
byte[] hash = sha.ComputeHash(values);
return BitConverter.ToString(hash).Replace("-", "");
}
}