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
+6 −5
1 file changed
- M image.c +6 −5
| @@ -470,11 +470,6 @@ static bool img_load_multiframe(img_t *img, const fileinfo_t *file) | |||
| 470 | 470 | m->frames = erealloc(m->frames, m->cap * sizeof(*m->frames)); | |
| 471 | 471 | } | |
| 472 | 472 | ||
| 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 | − | ||
| 478 | 473 | if ((blank = imlib_create_image(img->w, img->h)) == NULL) { | |
| 479 | 474 | error(0, 0, "%s: couldn't create image", file->name); | |
| 480 | 475 | return false; | |
| @@ -482,6 +477,11 @@ static bool img_load_multiframe(img_t *img, const fileinfo_t *file) | |||
| 482 | 477 | imlib_context_set_image(blank); | |
| 483 | 478 | img_area_clear(0, 0, img->w, img->h); | |
| 484 | 479 | ||
| 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 | + | ||
| 485 | 485 | /* | |
| 486 | 486 | * Imlib2 gives back a "raw frame", we need to blend it on top of the | |
| 487 | 487 | * 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) | |||
| 548 | 548 | imlib_context_set_image(blank); | |
| 549 | 549 | imlib_free_image(); | |
| 550 | 550 | img_multiframe_context_set(img); | |
| 551 | + | imlib_context_set_color_modifier(img->cmod); /* restore cmod */ | |
| 551 | 552 | return m->cnt > 0; | |
| 552 | 553 | } | |
| 553 | 554 | #endif /* HAVE_IMLIB2_MULTI_FRAME */ | |