--- sourceforge.net/trunk/rdesktop/bitmap.c 2000/07/25 12:34:29 9 +++ sourceforge.net/trunk/rdesktop/bitmap.c 2001/01/06 03:12:10 24 @@ -18,7 +18,7 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ -#include "includes.h" +#include "rdesktop.h" #define CVAL(p) (*(p++)) #define SVAL(p) ((*((p++) + 1) << 8) | CVAL(p)) @@ -30,11 +30,11 @@ unsigned char *input, int size) { unsigned char *end = input + size; - unsigned char *prevline, *line = NULL; + unsigned char *prevline = NULL, *line = NULL; int opcode, count, offset, isfillormix, x = width; - int lastopcode = -1, insertmix = False; - uint8 code, colour1, colour2, mask, mixmask; - uint8 mix = 0xff; + int lastopcode = -1, insertmix = False, bicolour = False; + uint8 code, colour1 = 0, colour2 = 0; + uint8 mixmask, mask = 0, mix = 0xff; while (input < end) { @@ -87,17 +87,18 @@ mixmask = 0; switch (opcode) { - case 0: /* Fill */ - if ((lastopcode == opcode) && (x != width)) + case 0: /* Fill */ + if ((lastopcode == opcode) + && !((x == width) && (prevline == NULL))) insertmix = True; break; - case 8: /* Bicolour */ + case 8: /* Bicolour */ colour1 = CVAL(input); - case 3: /* Colour */ + case 3: /* Colour */ colour2 = CVAL(input); break; - case 6: /* SetMix/Mix */ - case 7: /* SetMix/FillOrMix */ + case 6: /* SetMix/Mix */ + case 7: /* SetMix/FillOrMix */ mix = CVAL(input); opcode -= 5; break; @@ -121,13 +122,15 @@ switch (opcode) { - case 0: /* Fill */ + case 0: /* Fill */ if (insertmix) { if (prevline == NULL) line[x] = mix; else - line[x] = prevline[x] ^ mix; + line[x] = + prevline[x] ^ + mix; insertmix = False; count--; @@ -135,61 +138,79 @@ } if (prevline == NULL) - REPEAT(line[x] = 0) + { + REPEAT(line[x] = 0); + } else - REPEAT(line[x] = prevline[x]) + { + REPEAT(line[x] = prevline[x]); + } break; - case 1: /* Mix */ + case 1: /* Mix */ if (prevline == NULL) - REPEAT(line[x] = mix) + { + REPEAT(line[x] = mix); + } else - REPEAT(line[x] = prevline[x] ^ mix) + { + REPEAT(line[x] = + prevline[x] ^ mix); + } break; - case 2: /* Fill or Mix */ + case 2: /* Fill or Mix */ if (prevline == NULL) - REPEAT( - MASK_UPDATE(); - - if (mask & mixmask) - line[x] = mix; - else - line[x] = 0; - ) + { + REPEAT(MASK_UPDATE(); + if (mask & mixmask) + line[x] = mix; + else + line[x] = 0;); + } else - REPEAT( - MASK_UPDATE(); - - if (mask & mixmask) - line[x] = prevline[x] ^ mix; - else - line[x] = prevline[x]; - ) + { + REPEAT(MASK_UPDATE(); + if (mask & mixmask) + line[x] = + prevline[x] ^ mix; + else + line[x] = + prevline[x];); + } break; - case 3: /* Colour */ - REPEAT(line[x] = colour2) + case 3: /* Colour */ + REPEAT(line[x] = colour2); break; - case 4: /* Copy */ - REPEAT(line[x] = CVAL(input)) + case 4: /* Copy */ + REPEAT(line[x] = CVAL(input)); break; - case 8: /* Bicolour */ - REPEAT(line[x] = colour1; line[++x] = colour2) + case 8: /* Bicolour */ + REPEAT(if (bicolour) + { + line[x] = colour2; + bicolour = False;} + else + { + line[x] = colour1; + bicolour = True; count++;} + ); break; - case 13: /* White */ - REPEAT(line[x] = 0xff) + case 13: /* White */ + REPEAT(line[x] = 0xff); break; - case 14: /* Black */ - REPEAT(line[x] = 0x00) + case 14: /* Black */ + REPEAT(line[x] = 0x00); break; default: - NOTIMP("bitmap opcode 0x%x\n", opcode); + NOTIMP("bitmap opcode 0x%x\n", + opcode); return False; } }