Commit e3f3a757f30adc9ea14422e7322dfee1a09a1abb

Sam Lantinga 2017-08-12T16:02:33

Fixed bug 3158 - SDL display window scrambled over VNC Witek Jachimczyk I'm using SDL to develop a video viewer for MATLAB. The window is scrambled while using thightVNC with its default mode of RGB656. SDL does not correctly recognize the pixel mode. I found a solution for this problem. The solution involves modifying SDL/src/video/SDL_pixels.c Adding the following "if statement" under case 16: of SDL_MasksToPixelFormatEnum resolves the issue: if (Rmask == 0x003F && Gmask == 0x07C0 && Bmask == 0xF800 && Amask == 0x0000) { return SDL_PIXELFORMAT_RGB565; } I hope that this helps someone. I took me a while to figure it out.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
diff --git a/src/video/SDL_pixels.c b/src/video/SDL_pixels.c
index d2e56c5..d552e31 100644
--- a/src/video/SDL_pixels.c
+++ b/src/video/SDL_pixels.c
@@ -403,6 +403,13 @@ SDL_MasksToPixelFormatEnum(int bpp, Uint32 Rmask, Uint32 Gmask, Uint32 Bmask,
             Amask == 0x0000) {
             return SDL_PIXELFORMAT_BGR565;
         }
+        if (Rmask == 0x003F &&
+            Gmask == 0x07C0 &&
+            Bmask == 0xF800 &&
+            Amask == 0x0000) {
+            /* Technically this would be BGR556, but Witek says this works in bug 3158 */
+            return SDL_PIXELFORMAT_RGB565;
+        }
         break;
     case 24:
         switch (Rmask) {