00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #include "codec44.h"
00021 #include "chunck.h"
00022 #include "blitter.h"
00023
00024 #ifdef DEBUG
00025 #include <iostream>
00026 #endif
00027
00028 using namespace std;
00029
00030 bool codec44_decoder::decode(blitter & dst, chunck & src) throw(exception) {
00031
00032 int size_line;
00033 int num;
00034 int w, width = get_rect().width()+1;
00035 int h, height = get_rect().height()+1;
00036 bool zero;
00037 #ifdef DEBUG_CODEC44
00038 cout << "codec44 : " << width << "x" << height << endl;
00039 #endif
00040
00041 for(h = 0; h < height-1; h++)
00042 {
00043 w = width;
00044 size_line = src.get_word();
00045 #ifdef DEBUG_CODEC44
00046 cout << "codec44 : h == " << h << " : size_line == " << size_line << endl;
00047 #endif
00048 zero = true;
00049 while(size_line > 1) {
00050 num = src.get_word();
00051 size_line -= 2;
00052 if(zero) {
00053 #ifdef DEBUG_CODEC44
00054 cout << "codec44 : zeroing " << num << " entries" << endl;
00055 #endif
00056 if(w == num) num--;
00057 w -= num;
00058 if(num) dst.put(0, num);
00059 } else {
00060 num += 1;
00061 #ifdef DEBUG_CODEC44
00062 cout << "codec44 : blitting " << num << " entries" << endl;
00063 #endif
00064 if(w == num) num--;
00065 w -= num;
00066 dst.blit(src, num);
00067 size_line -= num;
00068 }
00069 zero = !zero;
00070 }
00071 }
00072 return true;
00073 }