我想创建一个删除某个文件夹中重复照片的应用程序,所以我需要将图像转换为 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();
}
}
}