位图图像读取不同的32/64位构建

时间:2013-10-16 21:04:45

标签: c# build bitmap bit-manipulation bitmapimage

编辑:第一部分似乎不是问题,见下文(感谢Ted和Jim):

这是p-hash实现的一部分。代码运行良好且一致,但在64和32之间编译时,某些图像的结果略有不同。 (averageValue是uint)

ulong hash = 0;
for (int i = 0; i < 64; i++)
   if (grayscale[i] >= averageValue)
       {
           hash |= (1UL << (int)(63L - i));
       }

在VS2010下编译。有任何改变实施的想法吗?

谢谢!

编辑:问题似乎不是在那部分,而是在阅读图像并凝聚它。

我正在获取我的图像(图像是传递的位图图像):

        // Squeeze the image into an 8x8 canvas
        Bitmap squeezed = new Bitmap(8, 8, PixelFormat.Format32bppRgb);
        Graphics canvas = Graphics.FromImage(squeezed);
        canvas.CompositingQuality = CompositingQuality.HighQuality;
        canvas.InterpolationMode = InterpolationMode.HighQualityBilinear;
        canvas.SmoothingMode = SmoothingMode.HighQuality;
        canvas.DrawImage(image, 0, 0, 8, 8);

然后在嵌套的for循环中

uint pixel = (uint)squeezed.GetPixel(x, y).ToArgb();

但这些价值不同:

4287269514 4290559164 4290559164 4289835184 4285687133 4285421390 4288056455 4290427578 4290559164 4294769916 ....

VS

4287335307 4290559164 4290559164 4289900719 4285752925 4285487183 4288121992 4290493371 4290559164 4294901502 ....

0 个答案:

没有答案
相关问题