我有一个功能来检查图像是否只是一种颜色。
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;
但是这个算法对于大图像来说很慢。有谁知道使用像素着色器和 GPU 的方法?