blob: 46776473b494f73882a06dbce9d6a4ee500abe15 [file] [log] [blame]
Peter Åstrand462753d2004-11-16 15:23:25 +00001/* Copyright (C) 2000-2003 Constantin Kaplinsky. All Rights Reserved.
2 *
3 * This is free software; you can redistribute it and/or modify
4 * it under the terms of the GNU General Public License as published by
5 * the Free Software Foundation; either version 2 of the License, or
6 * (at your option) any later version.
7 *
8 * This software is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this software; if not, write to the Free Software
15 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
16 * USA.
17 */
18#include <rfb/CMsgReader.h>
19#include <rfb/CMsgHandler.h>
20#include <rfb/TightDecoder.h>
21
22using namespace rfb;
23
24#define EXTRA_ARGS CMsgHandler* handler
25#define FILL_RECT(r, p) handler->fillRect(r, p)
26#define IMAGE_RECT(r, p) handler->imageRect(r, p)
27#define BPP 8
28#include <rfb/tightDecode.h>
29#undef BPP
30#define BPP 16
31#include <rfb/tightDecode.h>
32#undef BPP
33#define BPP 32
34#include <rfb/tightDecode.h>
35#undef BPP
36
37Decoder* TightDecoder::create(CMsgReader* reader)
38{
39 return new TightDecoder(reader);
40}
41
42TightDecoder::TightDecoder(CMsgReader* reader_) : reader(reader_)
43{
44}
45
46TightDecoder::~TightDecoder()
47{
48}
49
50void TightDecoder::readRect(const Rect& r, CMsgHandler* handler)
51{
52 rdr::InStream* is = reader->getInStream();
53 rdr::U8* buf = reader->getImageBuf(r.area());
54 switch (reader->bpp()) {
55 case 8:
56 tightDecode8 (r, is, zis, (rdr::U8*) buf, handler); break;
57 case 16:
58 tightDecode16(r, is, zis, (rdr::U16*)buf, handler); break;
59 case 32:
60 tightDecode32(r, is, zis, (rdr::U32*)buf, handler); break;
61 }
62}