/[rdesktop]/sourceforge.net/trunk/rdesktop/bitmap.c
This is repository of my old source code which isn't updated any more. Go to git.rot13.org for current projects!
ViewVC logotype

Diff of /sourceforge.net/trunk/rdesktop/bitmap.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 24 by matty, Sat Jan 6 03:12:10 2001 UTC revision 36 by matty, Sat Sep 15 14:30:46 2001 UTC
# Line 1  Line 1 
1  /*  /*
2     rdesktop: A Remote Desktop Protocol client.     rdesktop: A Remote Desktop Protocol client.
3     Bitmap decompression routines     Bitmap decompression routines
4     Copyright (C) Matthew Chapman 1999-2000     Copyright (C) Matthew Chapman 1999-2001
5        
6     This program is free software; you can redistribute it and/or modify     This program is free software; you can redistribute it and/or modify
7     it under the terms of the GNU General Public License as published by     it under the terms of the GNU General Public License as published by
# Line 21  Line 21 
21  #include "rdesktop.h"  #include "rdesktop.h"
22    
23  #define CVAL(p)   (*(p++))  #define CVAL(p)   (*(p++))
 #define SVAL(p)   ((*((p++) + 1) << 8) | CVAL(p))  
24    
25  #define REPEAT(statement) { while ((count > 0) && (x < width)) { statement; count--; x++; } }  #define UNROLL8(exp) { exp exp exp exp exp exp exp exp }
 #define MASK_UPDATE() { mixmask <<= 1; if (mixmask == 0) { mask = CVAL(input); mixmask = 1; } }  
26    
27  BOOL bitmap_decompress(unsigned char *output, int width, int height,  #define REPEAT(statement) \
28                         unsigned char *input, int size)  { \
29            while((count & ~0x7) && ((x+8) < width)) \
30                    UNROLL8( statement; count--; x++; ); \
31            \
32            while((count > 0) && (x < width)) { statement; count--; x++; } \
33    }
34    
35    #define MASK_UPDATE() \
36    { \
37            mixmask <<= 1; \
38            if (mixmask == 0) \
39            { \
40                    mask = fom_mask ? fom_mask : CVAL(input); \
41                    mixmask = 1; \
42            } \
43    }
44    
45    BOOL
46    bitmap_decompress(unsigned char *output, int width, int height,
47                      unsigned char *input, int size)
48  {  {
49          unsigned char *end = input + size;          unsigned char *end = input + size;
50          unsigned char *prevline = NULL, *line = NULL;          unsigned char *prevline = NULL, *line = NULL;
# Line 35  BOOL bitmap_decompress(unsigned char *ou Line 52  BOOL bitmap_decompress(unsigned char *ou
52          int lastopcode = -1, insertmix = False, bicolour = False;          int lastopcode = -1, insertmix = False, bicolour = False;
53          uint8 code, colour1 = 0, colour2 = 0;          uint8 code, colour1 = 0, colour2 = 0;
54          uint8 mixmask, mask = 0, mix = 0xff;          uint8 mixmask, mask = 0, mix = 0xff;
55            int fom_mask = 0;
56    
57          while (input < end)          while (input < end)
58          {          {
59                    fom_mask = 0;
60                  code = CVAL(input);                  code = CVAL(input);
61                  opcode = code >> 4;                  opcode = code >> 4;
62    
# Line 54  BOOL bitmap_decompress(unsigned char *ou Line 73  BOOL bitmap_decompress(unsigned char *ou
73    
74                          case 0xf:                          case 0xf:
75                                  opcode = code & 0xf;                                  opcode = code & 0xf;
76                                  count = (opcode < 13) ? SVAL(input) : 1;                                  if (opcode < 9)
77                                    {
78                                            count = CVAL(input);
79                                            count |= CVAL(input) << 8;
80                                    }
81                                    else
82                                    {
83                                            count = (opcode < 0xb) ? 8 : 1;
84                                    }
85                                  offset = 0;                                  offset = 0;
86                                  break;                                  break;
87    
# Line 84  BOOL bitmap_decompress(unsigned char *ou Line 111  BOOL bitmap_decompress(unsigned char *ou
111                  }                  }
112    
113                  /* Read preliminary data */                  /* Read preliminary data */
                 mixmask = 0;  
114                  switch (opcode)                  switch (opcode)
115                  {                  {
116                          case 0: /* Fill */                          case 0: /* Fill */
# Line 102  BOOL bitmap_decompress(unsigned char *ou Line 128  BOOL bitmap_decompress(unsigned char *ou
128                                  mix = CVAL(input);                                  mix = CVAL(input);
129                                  opcode -= 5;                                  opcode -= 5;
130                                  break;                                  break;
131                            case 9: /* FillOrMix_1 */
132                                    mask = 0x03;
133                                    opcode = 0x02;
134                                    fom_mask = 3;
135                                    break;
136                            case 0x0a:      /* FillOrMix_2 */
137                                    mask = 0x05;
138                                    opcode = 0x02;
139                                    fom_mask = 5;
140                                    break;
141    
142                  }                  }
143    
144                  lastopcode = opcode;                  lastopcode = opcode;
145                    mixmask = 0;
146    
147                  /* Output body */                  /* Output body */
148                  while (count > 0)                  while (count > 0)
# Line 200  BOOL bitmap_decompress(unsigned char *ou Line 239  BOOL bitmap_decompress(unsigned char *ou
239                                          );                                          );
240                                          break;                                          break;
241    
242                                  case 13:        /* White */                                  case 0xd:       /* White */
243                                          REPEAT(line[x] = 0xff);                                          REPEAT(line[x] = 0xff);
244                                          break;                                          break;
245    
246                                  case 14:        /* Black */                                  case 0xe:       /* Black */
247                                          REPEAT(line[x] = 0x00);                                          REPEAT(line[x] = 0x00);
248                                          break;                                          break;
249    
250                                  default:                                  default:
251                                          NOTIMP("bitmap opcode 0x%x\n",                                          unimpl("bitmap opcode 0x%x\n",
252                                                 opcode);                                                 opcode);
253                                          return False;                                          return False;
254                          }                          }

Legend:
Removed from v.24  
changed lines
  Added in v.36

  ViewVC Help
Powered by ViewVC 1.1.26