-
Notifications
You must be signed in to change notification settings - Fork 9
/
tiger-1.4d.cxx
95 lines (79 loc) · 2.62 KB
/
tiger-1.4d.cxx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
/* Copyright (C) 2000-2003 Constantin Kaplinsky. All Rights Reserved.
* Copyright 2004-2005 Cendio AB.
* Copyright (C) 2011, 2014 D. R. Commander. All Rights Reserved.
*
* This is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This software is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this software; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
* USA.
*/
#include <rfb/TightDecoder.h>
using namespace rfb;
#if BPP == 8
#include <rdr/Exception.h>
#include <rfb/PixelFormat.h>
#include <rfb/PixelBuffer.h>
#include <rdr/MemInStream.h>
static rdr::U8* imageBuf = NULL;
static int imageBufSize = 0;
rdr::U8* getImageBuf(int required, const PixelFormat& pf)
{
int requiredBytes = required * (pf.bpp / 8);
int size = requiredBytes;
if (imageBufSize < size) {
imageBufSize = size;
delete [] imageBuf;
imageBuf = new rdr::U8[imageBufSize];
}
return imageBuf;
}
static rdr::MemInStream *mis = NULL;
static TightDecoder *td = NULL;
static FullFramePixelBuffer *fb = NULL;
extern XImage *image;
#endif
#define HandleTightBPP CONCAT2E(HandleTight,BPP)
static Bool HandleTightBPP(int rx, int ry, int rw, int rh)
{
try {
Rect r(rx, ry, rx + rw, ry + rh);
int i;
for (i = 0; i < 4; i++) {
if (zlibStreamActive[i]) break;
}
if (i == 4) {
if (td) { delete td; td = NULL; }
if (fb) { delete fb; fb = NULL; }
if (mis) { delete mis; mis = NULL; }
}
if (!td) td = new TightDecoder;
PixelFormat clientPF(myFormat.bitsPerPixel, myFormat.depth,
myFormat.bigEndian==1, myFormat.trueColour==1, myFormat.redMax,
myFormat.greenMax, myFormat.blueMax, myFormat.redShift,
myFormat.greenShift, myFormat.blueShift);
if (!fb) fb = new FullFramePixelBuffer(clientPF, image->width,
image->height, (rdr::U8 *)image->data, image->bytes_per_line);
if (!mis) {
mis = new rdr::MemInStream(sendBuf, SEND_BUF_SIZE);
}
mis->reposition(sbptr);
td->readRect(r, fb, mis);
sbptr = mis->pos();
}
catch(rdr::Exception e) {
fprintf(stderr, "ERROR: %s\n", e.str());
return FALSE;
}
return TRUE;
}
#undef HandleTightBPP