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:
parent
4b67816eae
commit
d0ec8716d7
11
image.c
11
image.c
|
@ -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));
|
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) {
|
if ((blank = imlib_create_image(img->w, img->h)) == NULL) {
|
||||||
error(0, 0, "%s: couldn't create image", file->name);
|
error(0, 0, "%s: couldn't create image", file->name);
|
||||||
return false;
|
return false;
|
||||||
|
@ -482,6 +477,11 @@ static bool img_load_multiframe(img_t *img, const fileinfo_t *file)
|
||||||
imlib_context_set_image(blank);
|
imlib_context_set_image(blank);
|
||||||
img_area_clear(0, 0, img->w, img->h);
|
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
|
* 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.
|
* 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_context_set_image(blank);
|
||||||
imlib_free_image();
|
imlib_free_image();
|
||||||
img_multiframe_context_set(img);
|
img_multiframe_context_set(img);
|
||||||
|
imlib_context_set_color_modifier(img->cmod); /* restore cmod */
|
||||||
return m->cnt > 0;
|
return m->cnt > 0;
|
||||||
}
|
}
|
||||||
#endif /* HAVE_IMLIB2_MULTI_FRAME */
|
#endif /* HAVE_IMLIB2_MULTI_FRAME */
|
||||||
|
|
Loading…
Reference in New Issue