From: H.G.Muller Date: Wed, 2 Mar 2016 10:14:36 +0000 (+0100) Subject: Fix black border around saved diagrams (WB) X-Git-Url: http://winboard.nl/cgi-bin?p=xboard.git;a=commitdiff_plain;h=f07645e8072722cff2ba3f2ce3a762fc22765dfc Fix black border around saved diagrams (WB) The 'Save as Diagram' function of WinBoard produced bitmaps with a black border, because the buffer bitmap used for drawing the board (which was flushed to file to create the diagram) had a size larger than the board, including somemargins of the main window. Now we copy it to a board-sized bitmap first, and flush that. --- diff --git a/winboard/winboard.c b/winboard/winboard.c index ca901bf..424daa5 100644 --- a/winboard/winboard.c +++ b/winboard/winboard.c @@ -4106,7 +4106,12 @@ HDCDrawPosition(HDC hdc, BOOLEAN repaint, Board board) if(saveDiagFlag) { BITMAP b; int i, j=0, m, w, wb, fac=0; char *pData; BITMAPINFOHEADER bih; int color[16], nrColors=0; + HBITMAP src = bufferBitmap, obmp; HDC tmp = CreateCompatibleDC(hdc); + bufferBitmap = CreateCompatibleBitmap(hdc, boardRect.right-boardRect.left, Rect.bottom-Rect.top-2*OUTER_MARGIN); + obmp = SelectObject(tmp, bufferBitmap); + BitBlt(tmp, 0, 0, boardRect.right - boardRect.left, Rect.bottom - Rect.top - 2*OUTER_MARGIN, + tmphdc, boardRect.left, OUTER_MARGIN, SRCCOPY); GetObject(bufferBitmap, sizeof(b), &b); if(pData = malloc(b.bmWidthBytes*b.bmHeight + 10000)) { bih.biSize = sizeof(BITMAPINFOHEADER); @@ -4174,6 +4179,9 @@ HDCDrawPosition(HDC hdc, BOOLEAN repaint, Board board) fputc(pData[i], diagFile); free(pData); } + DeleteObject(bufferBitmap); bufferBitmap = src; + SelectObject(tmp, obmp); + DeleteDC(tmp); } SelectObject(tmphdc, oldBitmap);