4

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 ?

Kjensen
  • 12,447
  • 36
  • 109
  • 171

3 Answers3

3

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
  • 8,044
  • 33
  • 51
1

1) store GUID in a database instead of JPEG

2) use constructor:

ImageFormat(
    Guid guid
)
garik
  • 5,669
  • 5
  • 30
  • 42
0

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

Alexey B.
  • 1,106
  • 8
  • 17