views:

184

answers:

3

I store information about images in a database - also their ImageFormat (jpeg, png etc).

Console.WriteLine(System.Drawing.Imaging.ImageFormat.Jpeg.Guid);  

Outputs: b96b3cae-0728-11d3-9d7b-0000f81ef32e

I want to store this in the database as a GUID - and read from the database and get the associated ImageFormat.

How do I cast the GUID b96b3cae-0728-11d3-9d7b-0000f81ef32e to System.Drawing.Imaging.ImageFormat.Jpeg.Guid ?

+1  A: 

1) store GUID in a database instead of JPEG

2) use constructor:

ImageFormat(
    Guid guid
)
igor
A: 

Doesn't ImageFormat's constructor let you get the ImageFormat by its Guid?

Mr.Cat
+1  A: 

You provide a System.Guid to the System.Drawing.Imaging.ImageFormat's constructor, and you can read it back using it's Guid property.

A System.Guid has several constructors, including a string constructor.

M.A. Hanin