blob: 736bd5f79d69a5504a79b9c6a307df3afcd402bd [file] [log] [blame]
Constantin Kaplinsky47ed8d32004-10-08 09:43:57 +00001/* Copyright (C) 2002-2004 RealVNC Ltd. 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/ImageGetter.h>
19#include <rfb/encodings.h>
20#include <rfb/SMsgWriter.h>
21#include <rfb/HextileEncoder.h>
22
23using namespace rfb;
24
25#define EXTRA_ARGS ImageGetter* ig
26#define GET_IMAGE_INTO_BUF(r,buf) ig->getImage(buf, r);
27#define BPP 8
28#include <rfb/hextileEncode.h>
29#undef BPP
30#define BPP 16
31#include <rfb/hextileEncode.h>
32#undef BPP
33#define BPP 32
34#include <rfb/hextileEncode.h>
35#undef BPP
36
37Encoder* HextileEncoder::create(SMsgWriter* writer)
38{
39 return new HextileEncoder(writer);
40}
41
42HextileEncoder::HextileEncoder(SMsgWriter* writer_) : writer(writer_)
43{
44}
45
46HextileEncoder::~HextileEncoder()
47{
48}
49
50bool HextileEncoder::writeRect(const Rect& r, ImageGetter* ig, Rect* actual)
51{
52 writer->startRect(r, encodingHextile);
53 rdr::OutStream* os = writer->getOutStream();
54 switch (writer->bpp()) {
55 case 8: hextileEncode8(r, os, ig); break;
56 case 16: hextileEncode16(r, os, ig); break;
57 case 32: hextileEncode32(r, os, ig); break;
58 }
59 writer->endRect();
60 return true;
61}