I know the rgb value of every pixel, and how can I create the picture by these values in C#? I've seen some examples like this:
public Bitmap GetDataPicture(int w, int h, byte[] data)
{
Bitmap pic = new Bitmap(this.width, this.height, System.Drawing.Imaging.PixelFormat.Format32bppArgb);
Color c;
for (int i = 0; i < data.length; i++)
{
c = Color.FromArgb(data[i]);
pic.SetPixel(i%w, i/w, c);
}
return pic;
}
But it does not works. I have a two-dimensional array like this:
1 3 1 2 4 1 3 ...
2 3 4 2 4 1 3 ...
4 3 1 2 4 1 3 ...
...
Each number correspond to a rgb value, for example, 1 => {244,166,89} 2=>{54,68,125}.