Question

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 ?

Was it helpful?

Solution

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.

OTHER TIPS

1) store GUID in a database instead of JPEG

2) use constructor:

ImageFormat(
    Guid guid
)

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

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top