--- sourceforge.net/trunk/rdesktop/bitmap.c 2001/06/20 13:54:48 28 +++ sourceforge.net/trunk/rdesktop/bitmap.c 2002/09/26 14:26:46 207 @@ -1,7 +1,7 @@ /* rdesktop: A Remote Desktop Protocol client. Bitmap decompression routines - Copyright (C) Matthew Chapman 1999-2000 + Copyright (C) Matthew Chapman 1999-2002 This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -21,7 +21,6 @@ #include "rdesktop.h" #define CVAL(p) (*(p++)) -#define SVAL(p) ((*((p++) + 1) << 8) | CVAL(p)) #define UNROLL8(exp) { exp exp exp exp exp exp exp exp } @@ -44,8 +43,7 @@ } BOOL -bitmap_decompress(unsigned char *output, int width, int height, - unsigned char *input, int size) +bitmap_decompress(unsigned char *output, int width, int height, unsigned char *input, int size) { unsigned char *end = input + size; unsigned char *prevline = NULL, *line = NULL; @@ -75,9 +73,14 @@ case 0xf: opcode = code & 0xf; if (opcode < 9) - count = SVAL(input); + { + count = CVAL(input); + count |= CVAL(input) << 8; + } else + { count = (opcode < 0xb) ? 8 : 1; + } offset = 0; break; @@ -110,8 +113,7 @@ switch (opcode) { case 0: /* Fill */ - if ((lastopcode == opcode) - && !((x == width) && (prevline == NULL))) + if ((lastopcode == opcode) && !((x == width) && (prevline == NULL))) insertmix = True; break; case 8: /* Bicolour */ @@ -163,9 +165,7 @@ if (prevline == NULL) line[x] = mix; else - line[x] = - prevline[x] ^ - mix; + line[x] = prevline[x] ^ mix; insertmix = False; count--; @@ -189,8 +189,7 @@ } else { - REPEAT(line[x] = - prevline[x] ^ mix); + REPEAT(line[x] = prevline[x] ^ mix); } break; @@ -198,8 +197,7 @@ if (prevline == NULL) { REPEAT(MASK_UPDATE(); - if (mask & mixmask) - line[x] = mix; + if (mask & mixmask) line[x] = mix; else line[x] = 0;); } @@ -207,11 +205,9 @@ { REPEAT(MASK_UPDATE(); if (mask & mixmask) - line[x] = - prevline[x] ^ mix; + line[x] = prevline[x] ^ mix; else - line[x] = - prevline[x];); + line[x] = prevline[x];); } break; @@ -226,12 +222,10 @@ case 8: /* Bicolour */ REPEAT(if (bicolour) { - line[x] = colour2; - bicolour = False;} + line[x] = colour2; bicolour = False;} else { - line[x] = colour1; - bicolour = True; count++;} + line[x] = colour1; bicolour = True; count++;} ); break; @@ -244,8 +238,7 @@ break; default: - NOTIMP("bitmap opcode 0x%x\n", - opcode); + unimpl("bitmap opcode 0x%x\n", opcode); return False; } }