I am testing JPEG decompression on a bunch of computers with different versions of Windows. All of these computers have .NET 4 installed and I am compiling against .NET 2 and the "Any CPU" platform target. The following code produces different output on different systems.
Bitmap bmp = (Bitmap)Image.FromFile("test.jpg");
long datasum = 0;
for (int y = 0; y < bmp.Height; y++)
for (int x = 0; x < bmp.Width; x++)
datasum = datasum + bmp.GetPixel(x, y).R + bmp.GetPixel(x, y).G + bmp.GetPixel(x, y).B;
Console.WriteLine(datasum);
All the Win7 64-bit and WinXP 32-bit machines produce one result. And all the Win7 32-bit machines produce another result.
Any ideas why the output would be different?
It's implemented by gdiplus.dll. Check which versions are actually loaded on different system, and bitness.
There may be floating-point issue, MMX instructions allowed on one machine, not the other.
Can be related to this.
Try setting useEmbeddedColorManagement parameter to true.
I'm almost afraid to suggest this, but what if you find or implement your own jpeg decoder? Go old school & rely on the infrastructure to do nothing more than give you a stream of bytes.
It would be a major pain to do, but could eliminate the inconsistencies you're seeing.
Install the latest version of GDI+ on all machines and try again.
Also, if you decide to implement yourself, I've found this sample useful in the past.
this is not your answer , I just passed half of the way .
I think the best solution is using your own JPEG decoder, I found source code for that : Mini Jpeg Decoder but it's in C++ , I deploy that to Win32 dll file , you can find it here . it's over 10 hours that I'm working to use that in .net framework , but I wasn't success! because I haven't got any clue about c++.