diff options
| author | John Lindgren <john@jlindgren.net> | 2022-09-10 13:31:58 -0400 |
|---|---|---|
| committer | Simon Ser <contact@emersion.fr> | 2022-09-10 20:04:31 +0200 |
| commit | 605859cdd494b82fe206fe8d4737cda73cb6d467 (patch) | |
| tree | b609463aeb65eb623d175a9f1f2eeeb643f3b804 /background-image.c | |
| parent | bdeb891378bfcb2dc79de41cfeb6a62807d09b20 (diff) | |
Fix loss of clarity with odd-sized centered image
Diffstat (limited to 'background-image.c')
| -rw-r--r-- | background-image.c | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/background-image.c b/background-image.c index c765bdf..fc2ca0d 100644 --- a/background-image.c +++ b/background-image.c @@ -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); |
