Main Page   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members   Related Pages  

codec44.cpp

Go to the documentation of this file.
00001 /*
00002 Copyright (c) 2002 Xavier Trochu
00003 
00004 This software is provided 'as-is', without any express or implied warranty. In no event
00005 will the authors be held liable for any damages arising from the use of this software.
00006 
00007 Permission is granted to anyone to use this software for any purpose, including commercial
00008 applications, and to alter it and redistribute it freely, subject to the following
00009 restrictions:
00010 
00011 1. The origin of this software must not be misrepresented; you must not claim that you
00012    wrote the original software. If you use this software in a product, an acknowledgment
00013    in the product documentation would be appreciated but is not required.
00014 
00015 2. Altered source versions must be plainly marked as such, and must not be misrepresented 
00016    as being the original software.
00017 
00018 3. This notice may not be removed or altered from any source distribution.
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     //~ int val;
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(); // size of compressed line !
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 }

Generated on Fri Aug 9 22:54:29 2002 for san_player by doxygen1.2.16