Hi all,

To be frank, this is my homework, but I am stuck at beginner's point.

I have to read SGI Files (I belive it's Suns Raster Image files, they have .rgb extension, but contains no header information), scale it, rotate it and maybe apply anti-aliasing filter to resampled image.

I am just trying to read the image file. I read the file in byte array using FileStream and trying to display it in a image box, but it is throwing error while creating Bitmap class from the byte array. My code looks like this:
csharp Code:
  1. string imgpath = "Images\\sample1_400x400.rgb";
  2. System.IO.FileStream fs = System.IO.File.OpenRead(imgpath);
  3. Byte[] imgArray = new Byte[fs.Length];
  4. fs.Read(imgArray, 0, imgArray.Length);
  5.  
  6. System.IO.Stream ms = new System.IO.MemoryStream(imgArray);
  7. System.Drawing.Bitmap bmp = new System.Drawing.Bitmap(ms);//error here
  8.  
  9. //alternatively, I tried this, but this is also throwing the same error
  10. //System.Drawing.Bitmap bmp1 = new System.Drawing.Bitmap(imgpath);
The error is "Parameter is not valid".

Any suggestions please.

Thank you.

PS: sorry the code is in C#.