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

Reviewed-on: https://codeberg.org/nsxiv/nsxiv/pulls/440
Reviewed-by: eylles <eylles@noreply.codeberg.org>
This commit is contained in:
NRK 2023-05-18 15:06:44 +00:00
parent 4b67816eae
commit d0ec8716d7
1 changed files with 6 additions and 5 deletions

11
image.c
View File

@ -470,11 +470,6 @@ static bool img_load_multiframe(img_t *img, const fileinfo_t *file)
m->frames = erealloc(m->frames, m->cap * sizeof(*m->frames));
}
imlib_context_set_dither(0);
imlib_context_set_anti_alias(0);
imlib_context_set_color_modifier(NULL);
imlib_context_set_operation(IMLIB_OP_COPY);
if ((blank = imlib_create_image(img->w, img->h)) == NULL) {
error(0, 0, "%s: couldn't create image", file->name);
return false;
@ -482,6 +477,11 @@ static bool img_load_multiframe(img_t *img, const fileinfo_t *file)
imlib_context_set_image(blank);
img_area_clear(0, 0, img->w, img->h);
imlib_context_set_dither(0);
imlib_context_set_anti_alias(0);
imlib_context_set_color_modifier(NULL);
imlib_context_set_operation(IMLIB_OP_COPY);
/*
* Imlib2 gives back a "raw frame", we need to blend it on top of the
* 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)
imlib_context_set_image(blank);
imlib_free_image();
img_multiframe_context_set(img);
imlib_context_set_color_modifier(img->cmod); /* restore cmod */
return m->cnt > 0;
}
#endif /* HAVE_IMLIB2_MULTI_FRAME */