Skip to content

Commit 9238fd8

Browse files
berrangeMichael Tokarev
authored andcommitted
ui/vnc: fix tight palette pixel encoding for 8/16-bpp formats
When sending a tight rectangle with the palette filter, if the client format was 8/16bpp, the colours on big endian hosts are not set as we're sending the wrong bytes. We must first cast the 32-bit colour to a 16/8-bit value, and then send the result. Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org> Signed-off-by: Daniel P. Berrangé <berrange@redhat.com> (cherry picked from commit 63d3209) Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
1 parent 531cbd8 commit 9238fd8

1 file changed

Lines changed: 12 additions & 4 deletions

File tree

ui/vnc-enc-tight.c

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1001,16 +1001,24 @@ static int send_mono_rect(VncState *vs, int x, int y,
10011001
break;
10021002
}
10031003
case 2:
1004-
vnc_write(vs, &bg, 2);
1005-
vnc_write(vs, &fg, 2);
1004+
{
1005+
uint16_t bg16 = bg;
1006+
uint16_t fg16 = fg;
1007+
vnc_write(vs, &bg16, 2);
1008+
vnc_write(vs, &fg16, 2);
10061009
tight_encode_mono_rect16(vs->tight->tight.buffer, w, h, bg, fg);
10071010
break;
1011+
}
10081012
default:
1009-
vnc_write_u8(vs, bg);
1010-
vnc_write_u8(vs, fg);
1013+
{
1014+
uint8_t bg8 = bg;
1015+
uint8_t fg8 = fg;
1016+
vnc_write_u8(vs, bg8);
1017+
vnc_write_u8(vs, fg8);
10111018
tight_encode_mono_rect8(vs->tight->tight.buffer, w, h, bg, fg);
10121019
break;
10131020
}
1021+
}
10141022
vs->tight->tight.offset = bytes;
10151023

10161024
bytes = tight_compress_data(vs, stream, bytes, level, Z_DEFAULT_STRATEGY);

0 commit comments

Comments
 (0)