图像处理C#

Nun*_*oto 3 c# image pixel-shader

我有一个功能来检查图像是否只是一种颜色.

bool r = true;
Color checkColor = image.GetPixel(0, 0);

for (int x = 0; x < image.Width; x++)
  {
   for (int y = 0; y < image.Height; y++)
     {
      if (image.GetPixel(x, y) != checkColor) { r = false; }
     }
   }
// image color
clrOut = checkColor;
return r;
Run Code Online (Sandbox Code Playgroud)

但是这种算法对大图像来说很慢.有没有人知道使用像素着色器和GPU做到这一点的方法?

Kri*_*son 6

您不需要像素着色器和GPU来加快速度.使用LockBits.Bob Powell有一个很好的教程,可以完全按照自己的意愿行事.