Fix loss of clarity with odd-sized centered image

This commit is contained in:
John Lindgren 2022-09-10 13:31:58 -04:00 committed by Simon Ser
parent bdeb891378
commit 605859cdd4

View File

@ -100,9 +100,14 @@ void render_background_image(cairo_t *cairo, cairo_surface_t *image,
break;
}
case BACKGROUND_MODE_CENTER:
/*
* Align the unscaled image to integer pixel boundaries
* in order to prevent loss of clarity (this only matters
* for odd-sized images).
*/
cairo_set_source_surface(cairo, image,
(double)buffer_width / 2 - width / 2,
(double)buffer_height / 2 - height / 2);
(int)((double)buffer_width / 2 - width / 2),
(int)((double)buffer_height / 2 - height / 2));
break;
case BACKGROUND_MODE_TILE: {
cairo_pattern_t *pattern = cairo_pattern_create_for_surface(image);