Fixed bug 3158 - SDL display window scrambled over VNC
authorSam Lantinga <slouken@libsdl.org>
Sat, 12 Aug 2017 16:02:33 -0700
changeset 11250c9b15b9a04e3
parent 11249 00c7bb05a67c
child 11251 4de70b7f43af
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.
src/video/SDL_pixels.c
     1.1 --- a/src/video/SDL_pixels.c	Sat Aug 12 15:55:54 2017 -0700
     1.2 +++ b/src/video/SDL_pixels.c	Sat Aug 12 16:02:33 2017 -0700
     1.3 @@ -403,6 +403,13 @@
     1.4              Amask == 0x0000) {
     1.5              return SDL_PIXELFORMAT_BGR565;
     1.6          }
     1.7 +        if (Rmask == 0x003F &&
     1.8 +            Gmask == 0x07C0 &&
     1.9 +            Bmask == 0xF800 &&
    1.10 +            Amask == 0x0000) {
    1.11 +            /* Technically this would be BGR556, but Witek says this works in bug 3158 */
    1.12 +            return SDL_PIXELFORMAT_RGB565;
    1.13 +        }
    1.14          break;
    1.15      case 24:
    1.16          switch (Rmask) {