iipsrv
0.9.9
Main Page
Classes
Files
File List
RawTile.h
1
// RawTile class
2
3
/* IIP Image Server
4
5
Copyright (C) 2000-2009 Ruven Pillay.
6
7
This program is free software; you can redistribute it and/or modify
8
it under the terms of the GNU General Public License as published by
9
the Free Software Foundation; either version 2 of the License, or
10
(at your option) any later version.
11
12
This program is distributed in the hope that it will be useful,
13
but WITHOUT ANY WARRANTY; without even the implied warranty of
14
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
GNU General Public License for more details.
16
17
You should have received a copy of the GNU General Public License
18
along with this program; if not, write to the Free Software
19
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20
*/
21
22
23
#ifndef _RAWTILE_H
24
#define _RAWTILE_H
25
26
#include <cstring>
27
#include <string>
28
#include <cstdlib>
29
#include <ctime>
30
31
32
34
enum
ColourSpaces { GREYSCALE, sRGB, CIELAB };
35
37
enum
CompressionType { UNCOMPRESSED, JPEG, DEFLATE };
38
39
40
42
43
class
RawTile
{
44
45
public
:
46
48
int
tileNum
;
49
51
int
resolution
;
52
54
int
hSequence
;
55
57
int
vSequence
;
58
60
CompressionType
compressionType
;
61
63
int
quality
;
64
66
std::string
filename
;
67
69
time_t
timestamp
;
70
71
72
public
:
73
74
76
void
*
data
;
77
80
81
int
memoryManaged
;
82
84
int
dataLength
;
85
87
unsigned
int
width
;
88
90
unsigned
int
height
;
91
93
int
channels
;
94
96
int
bpc
;
97
99
bool
padded
;
100
101
103
112
RawTile
(
int
tn = 0,
int
res = 0,
int
hs = 0,
int
vs = 0,
113
int
w = 0,
int
h = 0,
int
c = 0,
int
b = 0 ) {
114
width
= w;
height
= h;
bpc
= b;
dataLength
= 0;
data
= NULL;
115
tileNum
= tn;
resolution
= res;
hSequence
= hs ;
vSequence
= vs;
116
memoryManaged
= 1;
channels
= c;
compressionType
= UNCOMPRESSED;
quality
= 0;
117
timestamp
= 0;
padded
= 0;
118
};
119
120
122
~RawTile
() {
123
if
(
data
&&
memoryManaged
){
124
if
(
bpc
==16)
delete
[] (
unsigned
short
*)
data
;
125
else
delete
[] (
unsigned
char
*)
data
;
126
}
127
}
128
129
131
RawTile
(
const
RawTile
& tile ) {
132
133
dataLength
= tile.
dataLength
;
134
width
= tile.
width
;
135
height
= tile.
height
;
136
channels
= tile.
channels
;
137
bpc
= tile.
bpc
;
138
tileNum
= tile.
tileNum
;
139
resolution
= tile.
resolution
;
140
hSequence
= tile.
hSequence
;
141
vSequence
= tile.
vSequence
;
142
compressionType
= tile.
compressionType
;
143
quality
= tile.
quality
;
144
filename
= tile.
filename
;
145
timestamp
= tile.
timestamp
;
146
padded
= tile.
padded
;
147
148
if
(
bpc
== 16 )
data
=
new
unsigned
short
[
dataLength
/2];
149
else
data
=
new
unsigned
char
[
dataLength
];
150
151
if
(
data
&& (
dataLength
> 0) && tile.
data
){
152
memcpy(
data
, tile.
data
,
dataLength
);
153
memoryManaged
= 1;
154
}
155
}
156
157
159
RawTile
&
operator=
(
const
RawTile
& tile ) {
160
161
dataLength
= tile.
dataLength
;
162
width
= tile.
width
;
163
height
= tile.
height
;
164
channels
= tile.
channels
;
165
bpc
= tile.
bpc
;
166
tileNum
= tile.
tileNum
;
167
resolution
= tile.
resolution
;
168
hSequence
= tile.
hSequence
;
169
vSequence
= tile.
vSequence
;
170
compressionType
= tile.
compressionType
;
171
quality
= tile.
quality
;
172
filename
= tile.
filename
;
173
timestamp
= tile.
timestamp
;
174
padded
= tile.
padded
;
175
176
if
(
bpc
== 16 )
data
=
new
unsigned
short
[
dataLength
/2];
177
else
data
=
new
unsigned
char
[
dataLength
];
178
179
if
(
data
&& (
dataLength
> 0) && tile.
data
){
180
memcpy(
data
, tile.
data
,
dataLength
);
181
memoryManaged
= 1;
182
}
183
184
return
*
this
;
185
}
186
187
189
int
size
() {
return
dataLength
; }
190
191
193
friend
int
operator ==
(
const
RawTile
& A,
const
RawTile
& B ) {
194
if
( (A.
tileNum
== B.
tileNum
) &&
195
(A.
resolution
== B.
resolution
) &&
196
(A.
hSequence
== B.
hSequence
) &&
197
(A.
vSequence
== B.
vSequence
) &&
198
(A.
compressionType
== B.
compressionType
) &&
199
(A.
quality
== B.
quality
) &&
200
(A.
filename
== B.
filename
) ){
201
return
( 1 );
202
}
203
else
return
( 0 );
204
}
205
206
208
friend
int
operator !=
(
const
RawTile
& A,
const
RawTile
& B ) {
209
if
( (A.
tileNum
== B.
tileNum
) &&
210
(A.
resolution
== B.
resolution
) &&
211
(A.
hSequence
== B.
hSequence
) &&
212
(A.
vSequence
== B.
vSequence
) &&
213
(A.
compressionType
== B.
compressionType
) &&
214
(A.
quality
== B.
quality
) &&
215
(A.
filename
== B.
filename
) ){
216
return
( 0 );
217
}
218
else
return
( 1 );
219
}
220
221
222
};
223
224
225
#endif
src
RawTile.h
Generated on Fri Jun 15 2012 16:23:58 for iipsrv by
1.8.1.1