0

I'm loading a picture from a file and then create a new Bitmap. Everything works fine but I want to secure more my app.

I'm using Bitmap Constructor (Stream)

public Bitmap(
    Stream stream
) 

I would like to check if GDI+ does not support the pixel format of the file.

public static Image FromFile(
    string filename,
    bool useEmbeddedColorManagement
)

Image.FromFile throws OutOfMemoryException if GDI+ does not support the pixel format of the file.

But I would like to avoid using Image.FromFile, because I won't allocate memory etc.

So the question is: how can I check if GDI+ does not support the pixel format of the file.

Thank you!

Aleksei Budiak
  • 821
  • 4
  • 15
mskuratowski
  • 3,844
  • 9
  • 51
  • 104

0 Answers0