I have a file containing raw RGB bytes for an image. The image is 512x288 and has 3 color channels, so red, green, and blue. The images are always 3 channels, and are always 512x288, meaning there are always going to be 512*288*3 bytes (442,368).
I need a way to load this up into a C Sharp program and display it or save it out as a PNG. Is something like this possible? I could have sworn that Bitmap() could automatically convert from raw bytes to an image, but it says a parameter is not valid. Here's the very simple starting code I'm using:
When I open a "valid" image, like a png or jpg, it works fine. But when I try to open one of my rgb files it gives me the error.
I need a way to load this up into a C Sharp program and display it or save it out as a PNG. Is something like this possible? I could have sworn that Bitmap() could automatically convert from raw bytes to an image, but it says a parameter is not valid. Here's the very simple starting code I'm using:
Code:
private void getImg(string filename)
{
FileStream fs = finfo.OpenRead();
BinaryReader br = new BinaryReader(fs);
byte[] imgBytes = br.ReadBytes((int)br.BaseStream.Length);
memImg = new MemoryStream(imgBytes);
img = new Bitmap(memImg);
displayImg();
}
private void displayImg()
{
pictureBox1.Image = img;
}
Comment