Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/275.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 如何从RGB像素阵列保存图像?_C#_Image - Fatal编程技术网

C# 如何从RGB像素阵列保存图像?

C# 如何从RGB像素阵列保存图像?,c#,image,C#,Image,最近我了解了如何将图像保存为字节(文本文件中的RGB值),现在我想知道如何从RGB值数组创建完全有效的图像。您可以使用@dasblinkenlight提到的方法: int width = 1; // read from file int height = 1; // read from file var bitmap = new Bitmap(width, height, PixelFormat.Canonical); for (int y = 0; y < height; y++)

最近我了解了如何将图像保存为字节(文本文件中的RGB值),现在我想知道如何从RGB值数组创建完全有效的图像。

您可以使用@dasblinkenlight提到的方法:

int width = 1; // read from file
int height = 1; // read from file
var bitmap = new Bitmap(width, height, PixelFormat.Canonical);

for (int y = 0; y < height; y++)
   for (int x = 0; x < width; x++)
   {
      int red = 0; // read from array
      int green = 0; // read from array
      int blue = 0; // read from array
      bitmap.SetPixel(x, y, Color.FromArgb(0, red, green, blue));
   }
int width=1;//从文件中读取
整数高度=1;//从文件中读取
var位图=新位图(宽度、高度、像素格式.Canonical);
对于(int y=0;y
您不能使用,读取文件,然后对每个像素调用
SetPixel
吗?我没有任何文件,我只有一个像素RGB值的2d数组,接下来该怎么办?(编辑:未看到第二条评论,正在尝试)