Search code examples
windowswinapiwic

Can the Windows Imaging Component return a human-readable format name?


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...


Solution

  • 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