Skip to content

Commit

Permalink
animated webp support - adding proposed changes for alpha handling
Browse files Browse the repository at this point in the history
  • Loading branch information
bakkeby committed Aug 26, 2021
1 parent 79af5f7 commit 29f5e60
Showing 1 changed file with 3 additions and 6 deletions.
9 changes: 3 additions & 6 deletions image.c
Original file line number Diff line number Diff line change
Expand Up @@ -438,7 +438,7 @@ bool img_load_webp(img_t* img, const fileinfo_t* file)
flags = WebPDemuxGetI(demux, WEBP_FF_FORMAT_FLAGS);
img->w = WebPDemuxGetI(demux, WEBP_FF_CANVAS_WIDTH);
img->h = WebPDemuxGetI(demux, WEBP_FF_CANVAS_HEIGHT);
img->alpha = (flags & ALPHA_FLAG) > 0;
img->alpha = ALPHA_LAYER;
img->multi.cap = info.frame_count;
img->multi.sel = 0;
img->multi.frames = emalloc(info.frame_count * sizeof(img_frame_t));
Expand All @@ -453,11 +453,7 @@ bool img_load_webp(img_t* img, const fileinfo_t* file)
imlib_image_set_format("webp");
// Get an iterator of this frame - used for frame info (duration, etc.)
WebPDemuxGetFrame(demux, img->multi.cnt+1, &iter);
// TODO: iter refers to the sub-frame, not the total frame. im is the
// total frame, entirely reconstructed. How can we see if the total
// frame has transparency?
if (iter.has_alpha)
imlib_image_set_has_alpha(1);
imlib_image_set_has_alpha((flags & ALPHA_FLAG) > 0);
// Store info for this frame
img->multi.frames[img->multi.cnt].im = im;
delay = iter.duration > 0 ? iter.duration : DEF_WEBP_DELAY;
Expand Down Expand Up @@ -562,6 +558,7 @@ Imlib_Image load_webp_firstframe_im(const fileinfo_t *file)
imlib_context_set_image(im);
imlib_image_set_format("webp");
imlib_image_set_has_alpha(1);
imlib_context_set_blend(1);

WebPAnimDecoderDelete(dec);
free((uint8_t*)data.bytes);
Expand Down

0 comments on commit 29f5e60

Please sign in to comment.