From: H.G.Muller Date: Fri, 22 Apr 2016 07:33:23 +0000 (+0200) Subject: Fix rounding when sizing 1x1 textures X-Git-Url: http://winboard.nl/cgi-bin?p=xboard.git;a=commitdiff_plain;h=b782bd1af9ba9d45eb6a3f33f546d441b68479a0;hp=a7395b43aa2a987286f027b7a729136b773ad6e1 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. --- 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