From 450b66d3585fec8384216444904d42a173e05c31 Mon Sep 17 00:00:00 2001 From: Peter Hater <7element@mail.bg> Date: Tue, 16 May 2017 17:32:19 +0000 Subject: [PATCH 1/1] [MSTSC] Fix image corruption in 24bpp mode CORE-13224 svn path=/trunk/; revision=74560 --- reactos/base/applications/mstsc/uimain.c | 2 +- reactos/base/applications/mstsc/win32.c | 18 +++++++++++++++++- 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/reactos/base/applications/mstsc/uimain.c b/reactos/base/applications/mstsc/uimain.c index 5c7249a03d9..0345914a162 100644 --- a/reactos/base/applications/mstsc/uimain.c +++ b/reactos/base/applications/mstsc/uimain.c @@ -199,7 +199,7 @@ ui_create_cursor(unsigned int x, unsigned int y, { bs_set_pixel_on(am, j, 31 - i, 32, 1, 1); } - if (bs_is_pixel_on((char *)xormask, j, i, 32, 24)) + if (bs_is_pixel_on((char *)xormask, j, i, 32, xor_bpp)) { bs_set_pixel_on(xm, j, 31 - i, 32, 1, 1); } diff --git a/reactos/base/applications/mstsc/win32.c b/reactos/base/applications/mstsc/win32.c index 0177e087306..91cb4a8c116 100644 --- a/reactos/base/applications/mstsc/win32.c +++ b/reactos/base/applications/mstsc/win32.c @@ -886,6 +886,7 @@ mi_paint_rect(char * data, int width, int height, int x, int y, int cx, int cy) int red; int green; int blue; + int index; ZeroMemory(&bi, sizeof(bi)); bi.bmiHeader.biSize = sizeof(bi.bmiHeader); @@ -942,7 +943,22 @@ mi_paint_rect(char * data, int width, int height, int x, int y, int cx, int cy) } } } - else if (g_server_depth == 24 || g_server_depth == 32) + else if (g_server_depth == 24) + { + for (i = cy - 1; i >= 0; i--) + { + for (j = cx - 1; j >= 0; j--) + { + index = (i * cx + j) * 3; + red = ((unsigned char*)data)[index + 2]; + green = ((unsigned char*)data)[index + 1]; + blue = ((unsigned char*)data)[index]; + MAKE_COLOUR32(colour, red, green, blue); + ((unsigned int*)bits)[i * cx + j] = colour; + } + } + } + else if (g_server_depth == 32) { memcpy(bits, data, cx*cy*4); } -- 2.17.1