From a677518cb50ad7529dd1ae28eb0d80fb61d1986e Mon Sep 17 00:00:00 2001 From: Harley Acheson Date: Sat, 17 Feb 2024 20:29:41 +0100 Subject: [PATCH] Fix #118351: Pixel Shift with Win32 Clipboard DibV5 Image Transfer My misreading of the Microsoft BITMAPV5HEADER specification causes a shift of three pixels when transferring between applications using this format. This does not occur when moving within or between Blender instances. This PR just removes the incorrect 12-byte offset. Note that many applications prefer PNG transfers over DibV5 so testing this might be non-obvious. Pull Request: https://projects.blender.org/blender/blender/pulls/118417 --- intern/ghost/intern/GHOST_SystemWin32.cc | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/intern/ghost/intern/GHOST_SystemWin32.cc b/intern/ghost/intern/GHOST_SystemWin32.cc index 226a144585a..33708e92058 100644 --- a/intern/ghost/intern/GHOST_SystemWin32.cc +++ b/intern/ghost/intern/GHOST_SystemWin32.cc @@ -2388,9 +2388,6 @@ static uint *getClipboardImageDibV5(int *r_width, int *r_height) int offset = bitmapV5Header->bV5Size + bitmapV5Header->bV5ClrUsed * sizeof(RGBQUAD); - if (bitmapV5Header->bV5Compression == BI_BITFIELDS) { - offset += 12; - } BYTE *buffer = (BYTE *)bitmapV5Header + offset; int bitcount = bitmapV5Header->bV5BitCount; int width = bitmapV5Header->bV5Width; @@ -2539,8 +2536,7 @@ static bool putClipboardImageDibV5(uint *rgba, int width, int height) DWORD size_pixels = width * height * 4; - /* Pixel data is 12 bytes after the header. */ - HGLOBAL hMem = GlobalAlloc(GHND, sizeof(BITMAPV5HEADER) + 12 + size_pixels); + HGLOBAL hMem = GlobalAlloc(GHND, sizeof(BITMAPV5HEADER) + size_pixels); if (!hMem) { return false; } @@ -2566,7 +2562,7 @@ static bool putClipboardImageDibV5(uint *rgba, int width, int height) hdr->bV5Intent = LCS_GM_IMAGES; hdr->bV5ClrUsed = 0; - memcpy((char *)hdr + sizeof(BITMAPV5HEADER) + 12, rgba, size_pixels); + memcpy((char *)hdr + sizeof(BITMAPV5HEADER), rgba, size_pixels); GlobalUnlock(hMem);