【问题标题】:Fastest way to convert image to ARGB Array将图像转换为 ARGB 数组的最快方法
【发布时间】:2014-06-17 18:20:33
【问题描述】:

我想创建一个应用程序来删除某个文件夹中的重复照片,所以我需要将图像转换为 ARGB 数组 [one diemnsion] 然后比较它们。 将图像转换为 ARGB 数组的最快方法是什么? 或者如何改进这段代码?

 Image img;
 using (FileStream stream = new FileStream(imagefile, FileMode.Open))
            {
                img = Image.FromStream(stream);
            }

 using (Bitmap bmp = new Bitmap(img))
            {
                int[] argb = new int[bmp.Width * bmp.Height];
                for (int x = 0; x < bmp.Width; x++)
                {

                    for (int y = 0; y < bmp.Height; y++)
                    {

                        Color pxl = bmp.GetPixel(x, y);

                        argb[x * y] = pxl.ToArgb();



                    }
                }
              }

【问题讨论】:

  • 您将希望使用 LockBits() 来锁定内存中的整个区域,而不是 GetPixel(),后者的效率相对较低。
  • 怎么做,请给我一个例子
  • Bitmap 类的 MSDN 文档中提供了示例。
  • 如果您要比较文件是否完全重复,可以使用散列函数(参见此处:stackoverflow.com/questions/10520048/…

标签: c# arrays image argb


【解决方案1】:

将图像转换为位图后,所有像素的半透明值为 255...

【讨论】:

    猜你喜欢
    • 2013-06-25
    • 2014-10-21
    • 1970-01-01
    • 2014-06-04
    • 1970-01-01
    • 2012-03-20
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多