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
  • 871
  • 5
  • 16
mskuratowski
  • 4,014
  • 15
  • 58
  • 109

0 Answers0