|
-
Sep 8th, 2009, 03:13 AM
#1
Reading SGI files (with .rgb extension)
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:
string imgpath = "Images\\sample1_400x400.rgb";
System.IO.FileStream fs = System.IO.File.OpenRead(imgpath);
Byte[] imgArray = new Byte[fs.Length];
fs.Read(imgArray, 0, imgArray.Length);
System.IO.Stream ms = new System.IO.MemoryStream(imgArray);
System.Drawing.Bitmap bmp = new System.Drawing.Bitmap(ms);//error here
//alternatively, I tried this, but this is also throwing the same error
//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#.
-
Sep 8th, 2009, 04:25 AM
#2
Re: Reading SGI files (with .rgb extension)
All right, I tried the same code for jpg, bmp and png files and they all seem to work seamlessly.
Looked at msdn, GDI+ doesn't seem to support SGI files for now, so it looks like I am quite out of luck.
Can somebody help me with displaying these images? I think I need to read them in binary mode!!!
Also, if someone could point me to a good example on StretchDIBits?
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|