/[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 30 by matty, Fri Sep 14 13:51:38 2001 UTC revision 207 by matthewc, Thu Sep 26 14:26:46 2002 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-2001     Copyright (C) Matthew Chapman 1999-2002
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 UNROLL8(exp) { exp exp exp exp exp exp exp exp }  #define UNROLL8(exp) { exp exp exp exp exp exp exp exp }
26    
# Line 44  Line 43 
43  }  }
44    
45  BOOL  BOOL
46  bitmap_decompress(unsigned char *output, int width, int height,  bitmap_decompress(unsigned char *output, int width, int height, unsigned char *input, int size)
                   unsigned char *input, int size)  
47  {  {
48          unsigned char *end = input + size;          unsigned char *end = input + size;
49          unsigned char *prevline = NULL, *line = NULL;          unsigned char *prevline = NULL, *line = NULL;
# Line 75  bitmap_decompress(unsigned char *output, Line 73  bitmap_decompress(unsigned char *output,
73                          case 0xf:                          case 0xf:
74                                  opcode = code & 0xf;                                  opcode = code & 0xf;
75                                  if (opcode < 9)                                  if (opcode < 9)
76                                          count = SVAL(input);                                  {
77                                            count = CVAL(input);
78                                            count |= CVAL(input) << 8;
79                                    }
80                                  else                                  else
81                                    {
82                                          count = (opcode < 0xb) ? 8 : 1;                                          count = (opcode < 0xb) ? 8 : 1;
83                                    }
84                                  offset = 0;                                  offset = 0;
85                                  break;                                  break;
86    
# Line 110  bitmap_decompress(unsigned char *output, Line 113  bitmap_decompress(unsigned char *output,
113                  switch (opcode)                  switch (opcode)
114                  {                  {
115                          case 0: /* Fill */                          case 0: /* Fill */
116                                  if ((lastopcode == opcode)                                  if ((lastopcode == opcode) && !((x == width) && (prevline == NULL)))
                                     && !((x == width) && (prevline == NULL)))  
117                                          insertmix = True;                                          insertmix = True;
118                                  break;                                  break;
119                          case 8: /* Bicolour */                          case 8: /* Bicolour */
# Line 163  bitmap_decompress(unsigned char *output, Line 165  bitmap_decompress(unsigned char *output,
165                                                  if (prevline == NULL)                                                  if (prevline == NULL)
166                                                          line[x] = mix;                                                          line[x] = mix;
167                                                  else                                                  else
168                                                          line[x] =                                                          line[x] = prevline[x] ^ mix;
                                                                 prevline[x] ^  
                                                                 mix;  
169    
170                                                  insertmix = False;                                                  insertmix = False;
171                                                  count--;                                                  count--;
# Line 189  bitmap_decompress(unsigned char *output, Line 189  bitmap_decompress(unsigned char *output,
189                                          }                                          }
190                                          else                                          else
191                                          {                                          {
192                                                  REPEAT(line[x] =                                                  REPEAT(line[x] = prevline[x] ^ mix);
                                                        prevline[x] ^ mix);  
193                                          }                                          }
194                                          break;                                          break;
195    
# Line 198  bitmap_decompress(unsigned char *output, Line 197  bitmap_decompress(unsigned char *output,
197                                          if (prevline == NULL)                                          if (prevline == NULL)
198                                          {                                          {
199                                                  REPEAT(MASK_UPDATE();                                                  REPEAT(MASK_UPDATE();
200                                                         if (mask & mixmask)                                                         if (mask & mixmask) line[x] = mix;
                                                        line[x] = mix;  
201                                                         else                                                         else
202                                                         line[x] = 0;);                                                         line[x] = 0;);
203                                          }                                          }
# Line 207  bitmap_decompress(unsigned char *output, Line 205  bitmap_decompress(unsigned char *output,
205                                          {                                          {
206                                                  REPEAT(MASK_UPDATE();                                                  REPEAT(MASK_UPDATE();
207                                                         if (mask & mixmask)                                                         if (mask & mixmask)
208                                                         line[x] =                                                         line[x] = prevline[x] ^ mix;
                                                        prevline[x] ^ mix;  
209                                                         else                                                         else
210                                                         line[x] =                                                         line[x] = prevline[x];);
                                                        prevline[x];);  
211                                          }                                          }
212                                          break;                                          break;
213    
# Line 226  bitmap_decompress(unsigned char *output, Line 222  bitmap_decompress(unsigned char *output,
222                                  case 8: /* Bicolour */                                  case 8: /* Bicolour */
223                                          REPEAT(if (bicolour)                                          REPEAT(if (bicolour)
224                                                 {                                                 {
225                                                 line[x] = colour2;                                                 line[x] = colour2; bicolour = False;}
                                                bicolour = False;}  
226                                                 else                                                 else
227                                                 {                                                 {
228                                                 line[x] = colour1;                                                 line[x] = colour1; bicolour = True; count++;}
                                                bicolour = True; count++;}  
229                                          );                                          );
230                                          break;                                          break;
231    
# Line 244  bitmap_decompress(unsigned char *output, Line 238  bitmap_decompress(unsigned char *output,
238                                          break;                                          break;
239    
240                                  default:                                  default:
241                                          unimpl("bitmap opcode 0x%x\n",                                          unimpl("bitmap opcode 0x%x\n", opcode);
                                                opcode);  
242                                          return False;                                          return False;
243                          }                          }
244                  }                  }

Legend:
Removed from v.30  
changed lines
  Added in v.207

  ViewVC Help
Powered by ViewVC 1.1.26