Getting actual frame from animated webp using cwebp/libwebp

Viewed 133

I am trying to get individual frames of an animated webp file. However, the frames obtained in this way has different image sizes and some frames have alpha channels:

WebPData rawData = { webpData.data() , webpData.size() };
struct WebPDemuxer* dmuxer = WebPDemux(&rawData);

int frame_idx = 1;
WebPIterator iter;
uint8_t* decode_data;

while (true) {

    WebPDemuxGetFrame(dmuxer, frame_idx, &iter);

    decode_data = WebPDecodeBGRA(iter.fragment.bytes, iter.fragment.size, &width, &height);
    if (decode_data == NULL)
        break;

    //do something with decode_data

    WebPDemuxReleaseIterator(&iter);

    frame_idx++;
}

Is there a way to get the fully rendered frame(using cwebp) instead of the different sized images with alpha channels(like the coalesce option in imagemagick)?

0 Answers
Related