I'm trying to load all frames in a GIF with Windows Imaging Component. On some GIF files I have an issue. For example, with the attached GIF image (error handling removed, all calls succeed):
// Load all frames
CComPtr<IWICBitmapDecoder> pDecoder = NULL;
wbfact->CreateDecoderFromFilename(
file.c_str(),
NULL, GENERIC_READ,
WICDecodeMetadataCacheOnLoad,
&pDecoder
);
UINT FrameCount = 0;
pDecoder->GetFrameCount(&FrameCount); // 66 in this GIF
for (int i = 0; i < FrameCount; i++)
{
CComPtr<IWICBitmapFrameDecode> s2 = NULL;
pDecoder->GetFrame(i, &s2);
CComPtr<IWICFormatConverter> pConverter2 = NULL;
wbfact->CreateFormatConverter(&pConverter2);
pConverter2->Initialize(
s2,
GUID_WICPixelFormat32bppPBGRA,
WICBitmapDitherTypeNone,
NULL,
0.f,
WICBitmapPaletteTypeMedianCut
);
}
Most times this works. However in this attached gif some frames are not shown (e.g. frame 2) and some frames are only shown with their edges, e.g. frame 26.
It looks like as if some GIFs contain a progressive encoding that is not read by WIC. Many GIFS display correctly. Also, Windows players display the gifs correctly.
What am I doing wrong?
Best,