Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

To quote the documentation for the System.Drawing.Imaging namespace

The Encoder class enables users to extend GDI+ to support any image format.

Yet I can find no documentation, examples or anything else that explains how I'd go about implementing my own custom file format -- most searches return lots of information on passing EncoderParameters, but nothing on implementing our own Encoders?

Ideally, I'd love to be able to implement this in C#, but I am prepared to dust off my ATL if needs be :)

Has anyone come across any documentation or are able to provide any pointers on how to approach this?

Update:
I should probably mention the things I've tried so far, to no avail:

  • Looking for the GUIDs returned in the ImageCodecInfo class to see if it was a normal COM interface (but it doesn't appear to be), the intention being to look at the implemented interfaces, or see if it's just a registry entry.
  • Stepped into Image.FromFile method to find it's just a wrapper for gdiplus.dll
  • Lots of Google searches, which seem to provide lots of cases of using the existing ones with specifying your own ImageEncoderParamerters; and a few cases of people implementing their own codecs by other means.
  • Even asked in news://microsoft.public.win32.programmer.gdi
See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
596 views
Welcome To Ask or Share your Answers For Others

1 Answer

Okay, here's some info I managed to dig up. It seems that the recommended (by Microsoft) way to do what you want is to develop a WIC-enabled codec for your format. The Windows Imaging Component (WIC) API comes built into Vista, but is also available for XP and Win Server 2003, either within .NET 3 or as a separate download.

However, there also seems to exist another way to extend GDI+ codec list, but those waters are a lot murkier. If you open gdiplus.dll in a hex editor, you'll find a reference to the following registry key:

SoftwareMicrosoftImagingCodecs

Googling for that key will send you to an MSDN article that talks about registering your own image codecs on Windows CE and Windows Mobile platforms. The funny thing is that the gdiplus.dll on XP has the said registry key hardcoded in it. I haven't checked whether it uses it, though and I haven't tried developing my own codec, either for WIC or for GDI+.

I hope this info helps at least get you started.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...