0

I am working on the task to convert raw files from cameras like Canon and Nikon with WIC to tiff format. I found examples on creating an WIC factory object using the filename.

//Create a WIC Decoder
////////////////////////////////////////////////////////////////////////////
IWICImagingFactory *piFactory = NULL;
IWICBitmapDecoder *piDecoder = NULL;

//Create the COM imaging factory.
HRESULT hr = CoCreateInstance(
CLSID_WICImagingFactory,
NULL,
CLSCTX_INPROC_SERVER,
IID_IWICImagingFactory,
(LPVOID*)&piFactory);

//Create the decoder.
if (SUCCEEDED(hr))
{
hr = piFactory->CreateDecoderFromFilename(
L"test_raw.cr2",
NULL,
GENERIC_READ,
WICDecodeMetadataCacheOnDemand, //For JPEG lossless decoding/encoding.
&piDecoder);
}

The file has a ".cr2" extension for Canon. As I know there are at least 2 different codecs for cr2 files. One from Canon and one from Microsoft. I want to make sure that one specific codec is used. How can I do this?

Thanks

DermotA
  • 3
  • 2

1 Answers1

0

To make sure you get a specific codec, you'll need to create it yourself, like this:

IWICBitmapDecoder *decoder;
IWICStream *stream;

factory->CreateStream(&stream);
stream->InitializeFromFilename(L"filename.png", GENERIC_READ);

CoCreateInstance(CLSID_WICPngDecoder, NULL, CLSCTX_INPROC_SERVER, IID_IWICBitmapDecoder, (void**)&decoder);

decoder->Initialize(stream, WICDecodeMetadataCacheOnDemand);

To get information about the codecs you have installed, including the CLSID, use IWICImagingFactory::CreateComponentEnumerator.

You can also specify a vendor when using IWICBitmapFactory to create codecs, but it's not a guarantee you'll get the specific one you want.

Esme Povirk
  • 3,004
  • 16
  • 24