When im passing Bmp as stream, function always return,
D4-1D-8C-D9-8F-00-B2-04-E9-80-09-98-EC-F8-42-7E
but file saving on disk correctly. When I load bpm from disk, function return correct MD5. Also passing "new Bitmap(int x, int y);" with different value return same MD5.
Why its happening?
public static string GetMD5Hash()
{
Bitmap Bmp = new Bitmap(23, 46); //
using (Graphics gfx = Graphics.FromImage(Bmp))
using (SolidBrush brush = new SolidBrush(Color.FromArgb(32, 44, 2)))
{
gfx.FillRectangle(brush, 0, 0, 23, 46);
}
using (var md5 = MD5.Create())
{
using (MemoryStream memoryStream = new MemoryStream())
{
Bmp.Save(memoryStream, System.Drawing.Imaging.ImageFormat.Bmp);
\//EDITED: Bmp.Save(@"C:\Test\pizdanadysku.bmp"); // Here saving file on disk, im getting diffrent solid color
return BitConverter.ToString(md5.ComputeHash(memoryStream)); //Always return D4-1D-8C-D9-8F-00-B2-04-E9-80-09-98-EC-F8-42-7E - I noticed that is MD5 of empty 1x1px Bmp file
}
}
}
Can somebody explain this strange behaviour?