From ab1c282bd6a29d283b62b60a217cd2d502b1c956 Mon Sep 17 00:00:00 2001 From: H.G.Muller Date: Fri, 22 Apr 2016 09:33:23 +0200 Subject: [PATCH] Fix rounding when sizing 1x1 textures When 1x1 textures were sized to the actual square size, this could lead to bitmaps that were 1 pixel too small, presumably because of rounding. We now add 0.99 pixel to the desired size of the texture image before calculating the scaling factor (in floating arithmetic) that has to be passed to the cairo scaling routine, and this seems to solve the problem. --- draw.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diff --git a/draw.c b/draw.c index 1d17314..3b4ddec 100644 --- a/draw.c +++ b/draw.c @@ -295,7 +295,7 @@ CreatePNGBoard (char *s, int kind) if(f == 0 || r == 0) f = BOARD_WIDTH, r = BOARD_HEIGHT; // 0x0 means 'fits any', so make it fit textureW[kind] = (w*BOARD_WIDTH)/f; // sync cutting locations with square pattern textureH[kind] = (h*BOARD_HEIGHT)/r; - n[kind] = r*squareSize/h; // scale to make it fit exactly vertically + n[kind] = (r*squareSize + 0.99)/h; // scale to make it fit exactly vertically modV[kind] = r; modH[kind] = f; } else if((p = strstr(s, "xq")) && (p == s || p[-1] == '/')) { // assume full-board image for Xiangqi -- 1.7.0.4