/[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 7 by matty, Fri Jul 7 09:40:03 2000 UTC revision 25 by matty, Sat Jan 6 03:47:04 2001 UTC
# Line 18  Line 18 
18     Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.     Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
19  */  */
20    
21  #include "includes.h"  #include "rdesktop.h"
22    
23  #define CVAL(p)   (*(p++))  #define CVAL(p)   (*(p++))
24  #define SVAL(p)   ((*((p++) + 1) << 8) | CVAL(p))  #define SVAL(p)   ((*((p++) + 1) << 8) | CVAL(p))
25    
26  #define REPEAT(statement) { while ((count > 0) && (x < width)) { statement; count--; x++; } }  #define REPEAT(statement) { while ((count > 0) && (x < width)) { statement; count--; x++; } }
27  #define MASK_UPDATE() { maskpix <<= 1; if (maskpix == 0) { mask = CVAL(input); maskpix = 1; } }  #define MASK_UPDATE() { mixmask <<= 1; if (mixmask == 0) { mask = CVAL(input); mixmask = 1; } }
28    
29  BOOL bitmap_decompress(unsigned char *output, int width, int height,  BOOL
30                         unsigned char *input, int size)  bitmap_decompress(unsigned char *output, int width, int height,
31                      unsigned char *input, int size)
32  {  {
33          unsigned char *end = input + size;          unsigned char *end = input + size;
34          unsigned char *prevline, *line = NULL;          unsigned char *prevline = NULL, *line = NULL;
35          int opcode, count, offset, isfillormix, x = width;          int opcode, count, offset, isfillormix, x = width;
36          uint8 code, mask, maskpix, color1, color2;          int lastopcode = -1, insertmix = False, bicolour = False;
37          uint8 mix = 0xff;          uint8 code, colour1 = 0, colour2 = 0;
38            uint8 mixmask, mask = 0, mix = 0xff;
39    
         dump_data(input, end-input);  
40          while (input < end)          while (input < end)
41          {          {
                 fprintf(stderr, "Offset %d from end\n", end-input);  
42                  code = CVAL(input);                  code = CVAL(input);
43                  opcode = code >> 4;                  opcode = code >> 4;
44    
# Line 85  BOOL bitmap_decompress(unsigned char *ou Line 85  BOOL bitmap_decompress(unsigned char *ou
85                  }                  }
86    
87                  /* Read preliminary data */                  /* Read preliminary data */
88                  maskpix = 0;                  mixmask = 0;
89                  switch (opcode)                  switch (opcode)
90                  {                  {
91                          case 3: /* Color */                          case 0: /* Fill */
92                                  color1 = CVAL(input);                                  if ((lastopcode == opcode)
93                          case 8: /* Bicolor */                                      && !((x == width) && (prevline == NULL)))
94                                  color2 = CVAL(input);                                          insertmix = True;
95                                  break;                                  break;
96                          case 6: /* SetMix/Mix */                          case 8: /* Bicolour */
97                          case 7: /* SetMix/FillOrMix */                                  colour1 = CVAL(input);
98                            case 3: /* Colour */
99                                    colour2 = CVAL(input);
100                                    break;
101                            case 6: /* SetMix/Mix */
102                            case 7: /* SetMix/FillOrMix */
103                                  mix = CVAL(input);                                  mix = CVAL(input);
104                                  opcode -= 5;                                  opcode -= 5;
105                                  break;                                  break;
106                  }                  }
107                    lastopcode = opcode;
108    
109                  /* Output body */                  /* Output body */
110                  while (count > 0)                  while (count > 0)
# Line 106  BOOL bitmap_decompress(unsigned char *ou Line 112  BOOL bitmap_decompress(unsigned char *ou
112                          if (x >= width)                          if (x >= width)
113                          {                          {
114                                  if (height <= 0)                                  if (height <= 0)
115                                          return True;                                          return False;
116    
117                                  x = 0;                                  x = 0;
118                                  height--;                                  height--;
# Line 117  BOOL bitmap_decompress(unsigned char *ou Line 123  BOOL bitmap_decompress(unsigned char *ou
123    
124                          switch (opcode)                          switch (opcode)
125                          {                          {
126                                  case 0: /* Fill */                                  case 0: /* Fill */
127                                          fprintf(stderr, "Fill %d\n", count);                                          if (insertmix)
128                                            {
129                                                    if (prevline == NULL)
130                                                            line[x] = mix;
131                                                    else
132                                                            line[x] =
133                                                                    prevline[x] ^
134                                                                    mix;
135    
136                                                    insertmix = False;
137                                                    count--;
138                                                    x++;
139                                            }
140    
141                                          if (prevline == NULL)                                          if (prevline == NULL)
142                                                  REPEAT(line[x] = 0)                                          {
143                                                    REPEAT(line[x] = 0);
144                                            }
145                                          else                                          else
146                                                  REPEAT(line[x] = prevline[x])                                          {
147                                                    REPEAT(line[x] = prevline[x]);
148                                            }
149                                          break;                                          break;
150    
151                                  case 1: /* Mix */                                  case 1: /* Mix */
                                         fprintf(stderr, "Mix %d\n", count);  
152                                          if (prevline == NULL)                                          if (prevline == NULL)
153                                                  REPEAT(line[x] = mix)                                          {
154                                                    REPEAT(line[x] = mix);
155                                            }
156                                          else                                          else
157                                                  REPEAT(line[x] = prevline[x] ^ mix)                                          {
158                                                    REPEAT(line[x] =
159                                                           prevline[x] ^ mix);
160                                            }
161                                          break;                                          break;
162    
163  #if 0                                  case 2: /* Fill or Mix */
                                 case 2: /* Fill or Mix */  
                                         REPEAT(line[x] = 0);  
                                         break;  
164                                          if (prevline == NULL)                                          if (prevline == NULL)
165                                              REPEAT(                                          {
166                                                     MASK_UPDATE();                                                  REPEAT(MASK_UPDATE();
167                                                           if (mask & mixmask)
168                                                     if (mask & maskpix)                                                         line[x] = mix;
169                                                          line[x] = mix;                                                         else
170                                                     else                                                         line[x] = 0;);
171                                                          line[x] = 0;                                          }
                                             )  
172                                          else                                          else
173                                              REPEAT(                                          {
174                                                     MASK_UPDATE();                                                  REPEAT(MASK_UPDATE();
175                                                           if (mask & mixmask)
176                                                     if (mask & maskpix)                                                         line[x] =
177                                                          line[x] = prevline[x] ^ mix;                                                         prevline[x] ^ mix;
178                                                     else                                                         else
179                                                          line[x] = prevline[x];                                                         line[x] =
180                                              )                                                         prevline[x];);
181                                            }
182                                          break;                                          break;
 #endif  
183    
184                                  case 3: /* Colour */                                  case 3: /* Colour */
185                                          fprintf(stderr, "Colour %d\n", count);                                          REPEAT(line[x] = colour2);
                                         REPEAT(line[x] = color2)  
186                                          break;                                          break;
187    
188                                  case 4: /* Copy */                                  case 4: /* Copy */
189                                          fprintf(stderr, "Copy %d\n", count);                                          REPEAT(line[x] = CVAL(input));
                                         REPEAT(line[x] = CVAL(input))  
190                                          break;                                          break;
191    
192  #if 0                                  case 8: /* Bicolour */
193                                  case 8: /* Bicolor */                                          REPEAT(if (bicolour)
194                                          REPEAT(line[x] = color1; line[++x] = color2)                                                 {
195                                                   line[x] = colour2;
196                                                   bicolour = False;}
197                                                   else
198                                                   {
199                                                   line[x] = colour1;
200                                                   bicolour = True; count++;}
201                                            );
202                                          break;                                          break;
203    
204                                  case 13: /* White */                                  case 13:        /* White */
205                                          REPEAT(line[x] = 0xff)                                          REPEAT(line[x] = 0xff);
206                                          break;                                          break;
207    
208                                  case 14: /* Black */                                  case 14:        /* Black */
209                                          REPEAT(line[x] = 0x00)                                          REPEAT(line[x] = 0x00);
210                                          break;                                          break;
 #endif  
211    
212                                  default:                                  default:
213                                          fprintf(stderr, "Unknown bitmap opcode 0x%x\n", opcode);                                          NOTIMP("bitmap opcode 0x%x\n",
214                                                   opcode);
215                                          return False;                                          return False;
216                          }                          }
217                  }                  }

Legend:
Removed from v.7  
changed lines
  Added in v.25

  ViewVC Help
Powered by ViewVC 1.1.26