Krolyxon
Commit d0ec871

Branches

Refs →

nsxivd0ec871

fix: calling imlib2 with color modifier being NULL (#440)

the multiframe loaders sets the color modifier to NULL but doesn't
restore it before returning. this results in a imlib2 developer warning
if you try to change brightness/contrast on a multiframe image (which
doesn't have alpha).

ensure that the color modifier is restored before returning under all
paths.

Reported-by: Madhu
Author
NRK
Date
2023-05-18 15:06 +0000
Parent
4b67816
Commit
d0ec8716d7d4d0cfb0067290cac51b59b7fd4e42

+6 −5

1 file changed

  1. M image.c +6 −5
M image.c View
@@ -470,11 +470,6 @@ static bool img_load_multiframe(img_t *img, const fileinfo_t *file)
470470 m->frames = erealloc(m->frames, m->cap * sizeof(*m->frames));
471471 }
472472
473− imlib_context_set_dither(0);
474− imlib_context_set_anti_alias(0);
475− imlib_context_set_color_modifier(NULL);
476− imlib_context_set_operation(IMLIB_OP_COPY);
477−
478473 if ((blank = imlib_create_image(img->w, img->h)) == NULL) {
479474 error(0, 0, "%s: couldn't create image", file->name);
480475 return false;
@@ -482,6 +477,11 @@ static bool img_load_multiframe(img_t *img, const fileinfo_t *file)
482477 imlib_context_set_image(blank);
483478 img_area_clear(0, 0, img->w, img->h);
484479
480+ imlib_context_set_dither(0);
481+ imlib_context_set_anti_alias(0);
482+ imlib_context_set_color_modifier(NULL);
483+ imlib_context_set_operation(IMLIB_OP_COPY);
484+
485485 /*
486486 * Imlib2 gives back a "raw frame", we need to blend it on top of the
487487 * previous frame ourselves if necessary to get the fully decoded frame.
@@ -548,6 +548,7 @@ static bool img_load_multiframe(img_t *img, const fileinfo_t *file)
548548 imlib_context_set_image(blank);
549549 imlib_free_image();
550550 img_multiframe_context_set(img);
551+ imlib_context_set_color_modifier(img->cmod); /* restore cmod */
551552 return m->cnt > 0;
552553 }
553554 #endif /* HAVE_IMLIB2_MULTI_FRAME */