JPEG解压缩在Windows体系结构中不一致

时间:2022-02-18 21:18:40

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.

我正在使用不同版本的Windows的一堆计算机上测试JPEG解压缩。所有这些计算机都安装了.NET 4,我正在编译.NET 2和“任何CPU”平台目标。以下代码在不同系统上生成不同的输出。

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.

所有Win7 64位和WinXP 32位机器都产生一个结果。所有Win7 32位机器都产生了另一个结果。

Any ideas why the output would be different?

任何想法为什么输出会有所不同?

5 个解决方案

#1


1  

It's implemented by gdiplus.dll. Check which versions are actually loaded on different system, and bitness.

它由gdiplus.dll实现。检查不同系统上实际加载的版本和位数。

There may be floating-point issue, MMX instructions allowed on one machine, not the other.

可能存在浮点问题,一台机器上允许MMX指令,而另一台机器上则不允许。

#2


1  

Can be related to this.

可以与此相关。

Try setting useEmbeddedColorManagement parameter to true.

尝试将useEmbeddedColorManagement参数设置为true。

#3


0  

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.

我几乎不敢提出这个建议,但是如果你找到或实现自己的jpeg解码器呢?去旧学校并依赖基础设施除了给你一个字节流以外什么都不做。

It would be a major pain to do, but could eliminate the inconsistencies you're seeing.

这将是一个很大的痛苦,但可以消除你所看到的不一致。

#4


0  

Install the latest version of GDI+ on all machines and try again.

在所有计算机上安装最新版本的GDI +,然后重试。

Also, if you decide to implement yourself, I've found this sample useful in the past.

此外,如果您决定自己实施,我发现此示例在过去很有用。

#5


0  

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++.

我认为最好的解决方案是使用你自己的JPEG解码器,我找到了源代码:Mini Jpeg Decoder但它是用C ++编写的,我把它部署到Win32 dll文件,你可以在这里找到它。我正在努力在.net框架中使用它超过10个小时,但我没有成功!因为我对c ++没有任何线索。

#1


1  

It's implemented by gdiplus.dll. Check which versions are actually loaded on different system, and bitness.

它由gdiplus.dll实现。检查不同系统上实际加载的版本和位数。

There may be floating-point issue, MMX instructions allowed on one machine, not the other.

可能存在浮点问题,一台机器上允许MMX指令,而另一台机器上则不允许。

#2


1  

Can be related to this.

可以与此相关。

Try setting useEmbeddedColorManagement parameter to true.

尝试将useEmbeddedColorManagement参数设置为true。

#3


0  

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.

我几乎不敢提出这个建议,但是如果你找到或实现自己的jpeg解码器呢?去旧学校并依赖基础设施除了给你一个字节流以外什么都不做。

It would be a major pain to do, but could eliminate the inconsistencies you're seeing.

这将是一个很大的痛苦,但可以消除你所看到的不一致。

#4


0  

Install the latest version of GDI+ on all machines and try again.

在所有计算机上安装最新版本的GDI +,然后重试。

Also, if you decide to implement yourself, I've found this sample useful in the past.

此外,如果您决定自己实施,我发现此示例在过去很有用。

#5


0  

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++.

我认为最好的解决方案是使用你自己的JPEG解码器,我找到了源代码:Mini Jpeg Decoder但它是用C ++编写的,我把它部署到Win32 dll文件,你可以在这里找到它。我正在努力在.net框架中使用它超过10个小时,但我没有成功!因为我对c ++没有任何线索。