locked
Importing .raw images to create bitmap RRS feed

  • Question

  • Is it possible to import greyscale 16 bit raw image formats into the bitmap class? I am trying to do this but I get an invalid parameter error. I am very sure my paths are correct.

    If this is not possible what format should I be using? I do not want to change my bit depth because it is a heightmap.

    • Moved by CoolDadTx Monday, September 19, 2016 2:07 PM Winforms related
    Monday, September 19, 2016 5:20 AM

Answers

  • Hi jyumai,

    So far,  most GDI+ only support  256 level gray scale,   so  using the PixelFormat.Format16bppGrayScale  in System.Drawing  to  disaplay an  image would be cause  exceptions, Format16bppGrayScale  can't be displayed directly and Graphics can't be used with them. If you only want to display a raw image ,I suggest you convert to RGB image and display it.

    I hope this can be helpful.
    Li Wang


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Wednesday, September 21, 2016 10:02 AM

All replies

  • Hi,

    see:

    http://stackoverflow.com/questions/26721809/generate-16-bit-grayscale-bitmapdata-and-save-to-file

    http://stackoverflow.com/questions/19704021/gdi-generic-error-saving-bitmap-created-from-memory-using-lockbits/19706842#19706842

    and, maybe the answer here will help:

    https://social.msdn.microsoft.com/Forums/vstudio/en-US/10252c05-c4b6-49dc-b2a3-4c1396e2c3ab/writing-a-16bit-grayscale-image?forum=csharpgeneral

    The other option is to use WPF.

    http://stackoverflow.com/questions/9588367/creating-16-bit-grayscale-images-in-wpf

    Regards,

      Thorsten


    Monday, September 19, 2016 5:35 AM
  • Hello,

     There are few important things to remember when dealing with RAW images.

     1. Is there a header, which describe the file internal structure.

     2. Is Color Encoding or PixelFormat used, such as ARGB, RGB, ARRGGBB.

     3. Is the image interlaced or non-interlaced.

     You will most like have to test the file against possible know structures. This

    does not promise a clean/clear image. Which leads to problems of the file

    being usable or not.

     You should review the links provided by Thorsten Gudera as they are valuable information.

     Thanks :)

    Tuesday, September 20, 2016 9:48 PM
  • Hi jyumai,

    So far,  most GDI+ only support  256 level gray scale,   so  using the PixelFormat.Format16bppGrayScale  in System.Drawing  to  disaplay an  image would be cause  exceptions, Format16bppGrayScale  can't be displayed directly and Graphics can't be used with them. If you only want to display a raw image ,I suggest you convert to RGB image and display it.

    I hope this can be helpful.
    Li Wang


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Wednesday, September 21, 2016 10:02 AM