Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

JPEG decompression inconsistent across Windows architectures

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?

like image 615
Jono Avatar asked Aug 08 '12 20:08

Jono


2 Answers

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.

like image 88
Feng Yuan Avatar answered Oct 03 '22 01:10

Feng Yuan


Can be related to this.

Try setting useEmbeddedColorManagement parameter to true.

like image 39
gunakkoc Avatar answered Oct 03 '22 01:10

gunakkoc