Results 1 to 2 of 2

Thread: Reading SGI files (with .rgb extension)

  1. #1

    Thread Starter
    Smitten by reality Harsh Gupta's Avatar
    Join Date
    Feb 2005
    Posts
    2,938

    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:
    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#.
    Show Appreciation. Rate Posts.

  2. #2

    Thread Starter
    Smitten by reality Harsh Gupta's Avatar
    Join Date
    Feb 2005
    Posts
    2,938

    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?
    Show Appreciation. Rate Posts.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width