/[rdesktop]/jpeg/rdesktop/trunk/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 /jpeg/rdesktop/trunk/bitmap.c

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

revision 1372 by jsorg71, Mon Jan 8 04:47:06 2007 UTC revision 1417 by jsorg71, Thu Aug 30 04:47:36 2007 UTC
# Line 746  bitmap_decompress3(uint8 * output, int w Line 746  bitmap_decompress3(uint8 * output, int w
746          return True;          return True;
747  }  }
748    
749    /* decompress a colour plane */
750    static int
751    process_plane(uint8 * in, int width, int height, uint8 * out, int size)
752    {
753            int indexw;
754            int indexh;
755            int code;
756            int collen;
757            int replen;
758            int color;
759            int x;
760            int revcode;
761            uint8 * last_line;
762            uint8 * this_line;
763            uint8 * org_in;
764            uint8 * org_out;
765    
766            org_in = in;
767            org_out = out;
768            last_line = 0;
769            indexh = 0;
770            while (indexh < height)
771            {
772                    out = (org_out + width * height * 4) - ((indexh + 1) * width * 4);
773                    color = 0;
774                    this_line = out;
775                    indexw = 0;
776                    if (last_line == 0)
777                    {
778                            while (indexw < width)
779                            {
780                                    code = CVAL(in);
781                                    replen = code & 0xf;
782                                    collen = (code >> 4) & 0xf;
783                                    revcode = (replen << 4) | collen;
784                                    if ((revcode <= 47) && (revcode >= 16))
785                                    {
786                                            replen = revcode;
787                                            collen = 0;
788                                    }
789                                    while (collen > 0)
790                                    {
791                                            color = CVAL(in);
792                                            *out = color;
793                                            out += 4;
794                                            indexw++;
795                                            collen--;
796                                    }
797                                    while (replen > 0)
798                                    {
799                                            *out = color;
800                                            out += 4;
801                                            indexw++;
802                                            replen--;
803                                    }
804                            }
805                    }
806                    else
807                    {
808                            while (indexw < width)
809                            {
810                                    code = CVAL(in);
811                                    replen = code & 0xf;
812                                    collen = (code >> 4) & 0xf;
813                                    revcode = (replen << 4) | collen;
814                                    if ((revcode <= 47) && (revcode >= 16))
815                                    {
816                                            replen = revcode;
817                                            collen = 0;
818                                    }
819                                    while (collen > 0)
820                                    {
821                                            x = CVAL(in);
822                                            if (x & 1)
823                                            {
824                                                    x = x >> 1;
825                                                    x = x + 1;
826                                                    color = -x;
827                                            }
828                                            else
829                                            {
830                                                    x = x >> 1;
831                                                    color = x;
832                                            }
833                                            x = last_line[indexw * 4] + color;
834                                            *out = x;
835                                            out += 4;
836                                            indexw++;
837                                            collen--;
838                                    }
839                                    while (replen > 0)
840                                    {
841                                            x = last_line[indexw * 4] + color;
842                                            *out = x;
843                                            out += 4;
844                                            indexw++;
845                                            replen--;
846                                    }
847                            }
848                    }
849                    indexh++;
850                    last_line = this_line;
851            }
852            return (int) (in - org_in);
853    }
854    
855    /* 4 byte bitmap decompress */
856    static RD_BOOL
857    bitmap_decompress4(uint8 * output, int width, int height, uint8 * input, int size)
858    {
859            int code;
860            int bytes_pro;
861            int total_pro;
862    
863            code = CVAL(input);
864            if (code != 0x10)
865            {
866                    return False;
867            }
868            total_pro = 1;
869            bytes_pro = process_plane(input, width, height, output + 3, size - total_pro);
870            total_pro += bytes_pro;
871            input += bytes_pro;
872            bytes_pro = process_plane(input, width, height, output + 2, size - total_pro);
873            total_pro += bytes_pro;
874            input += bytes_pro;
875            bytes_pro = process_plane(input, width, height, output + 1, size - total_pro);
876            total_pro += bytes_pro;
877            input += bytes_pro;
878            bytes_pro = process_plane(input, width, height, output + 0, size - total_pro);
879            total_pro += bytes_pro;
880            return size == total_pro;
881    }
882    
883  /* main decompress function */  /* main decompress function */
884  RD_BOOL  RD_BOOL
885  bitmap_decompress(uint8 * output, int width, int height, uint8 * input, int size, int Bpp)  bitmap_decompress(uint8 * output, int width, int height, uint8 * input, int size, int Bpp)
# Line 763  bitmap_decompress(uint8 * output, int wi Line 897  bitmap_decompress(uint8 * output, int wi
897                  case 3:                  case 3:
898                          rv = bitmap_decompress3(output, width, height, input, size);                          rv = bitmap_decompress3(output, width, height, input, size);
899                          break;                          break;
900                    case 4:
901                            rv = bitmap_decompress4(output, width, height, input, size);
902                            break;
903                    default:
904                            unimpl("Bpp %d\n", Bpp);
905                            break;
906          }          }
907          return rv;          return rv;
908  }  }

Legend:
Removed from v.1372  
changed lines
  Added in v.1417

  ViewVC Help
Powered by ViewVC 1.1.26