2

I'm using IWICImagingFactory::CreateDecoderFromFilename to load images using the Windows Imaging Component (WIC). It returns an IWICBitmapDecoder that I can use to get the actual image data.

Is it also possible to get a human-readable string of the image loaded from WIC? E.g. something like "JPEG", "PNG", "GIF" etc.? I know I can use IWICBitmapDecoder::GetContainerFormat to get the container format but it returns a GUID instead of a human-readable string. So for the GIF format, I'm getting GUID_ContainerFormatGif which is not exactly human-readable...

Andreas
  • 9,245
  • 9
  • 49
  • 97
  • Where have you seen the WIC human readable string? – Anders Dec 27 '22 at 13:23
  • I haven't seen it. That's why I'm asking if it's possible at all. – Andreas Dec 27 '22 at 13:27
  • You might be able to find the file extension. I doubt it will be able to provide "Portable Network Graphics". – Anders Dec 27 '22 at 13:41
  • @HansPassant: But can't WIC be extended using third-party decoders? In that case just comparing the Microsoft built-in GUIDs wouldn't be sufficient. – Andreas Dec 27 '22 at 13:53
  • @SimonMourier: Thanks, I can confirm that this does the trick! You should post this as the answer to the question. – Andreas Dec 27 '22 at 14:32

1 Answers1

3

If you have an IWICBitmapDecoder reference, you can call the IWICBitmapDecoder::GetDecoderInfo method. It will get you an IWICBitmapDecoderInfo reference ("Exposes methods that provide information about a decoder.").

From that reference (which derives from the IWICComponentInfo interface), you can call the IWICComponentInfo::GetFriendlyName method which will get you "GIF Decoder" in the GIF decoder (GUID_ContainerFormatGif) case.

This WicNetExplorer open source (.NET C# P/Invoke interop) tool I wrote can display every WIC Component information:

enter image description here

Simon Mourier
  • 132,049
  • 21
  • 248
  • 298