开发者

Converting a GUID to System.Drawing.Imaging.ImageFormat

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

Console开发者_StackOverflow中文版.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 ?


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.


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?

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜