RawTile.h
00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023 #ifndef _RAWTILE_H
00024 #define _RAWTILE_H
00025
00026 #include <cstring>
00027 #include <string>
00028 #include <cstdlib>
00029
00030
00031
00033 enum ColourSpaces { GREYSCALE, sRGB, CIELAB };
00034
00036 enum CompressionType { UNCOMPRESSED, JPEG, DEFLATE };
00037
00038
00039
00041
00042 class RawTile{
00043
00044 public:
00045
00047 int tileNum;
00048
00050 int resolution;
00051
00053 int hSequence;
00054
00056 int vSequence;
00057
00059 CompressionType compressionType;
00060
00062 int quality;
00063
00065 std::string filename;
00066
00068 time_t timestamp;
00069
00070
00071 public:
00072
00073
00075 void *data;
00076
00079
00080 int memoryManaged;
00081
00083 int dataLength;
00084
00086 unsigned int width;
00087
00089 unsigned int height;
00090
00092 int channels;
00093
00095 int bpc;
00096
00098 bool padded;
00099
00100
00102
00111 RawTile( int tn = 0, int res = 0, int hs = 0, int vs = 0,
00112 int w = 0, int h = 0, int c = 0, int b = 0 ) {
00113 width = w; height = h; bpc = b; dataLength = 0; data = NULL;
00114 tileNum = tn; resolution = res; hSequence = hs ; vSequence = vs;
00115 memoryManaged = 1; channels = c; compressionType = UNCOMPRESSED; quality = 0;
00116 timestamp = 0; padded = 0;
00117 };
00118
00119
00121 ~RawTile() {
00122 if( data && memoryManaged ){
00123 if(bpc==16) delete[] (unsigned short*) data;
00124 else delete[] (unsigned char*) data;
00125 }
00126 }
00127
00128
00130 RawTile( const RawTile& tile ) {
00131
00132 dataLength = tile.dataLength;
00133 width = tile.width;
00134 height = tile.height;
00135 channels = tile.channels;
00136 bpc = tile.bpc;
00137 tileNum = tile.tileNum;
00138 resolution = tile.resolution;
00139 hSequence = tile.hSequence;
00140 vSequence = tile.vSequence;
00141 compressionType = tile.compressionType;
00142 quality = tile.quality;
00143 filename = tile.filename;
00144 timestamp = tile.timestamp;
00145 padded = tile.padded;
00146
00147 if( bpc == 16 ) data = new unsigned short[dataLength/2];
00148 else data = new unsigned char[dataLength];
00149
00150 if( data && (dataLength > 0) && tile.data ){
00151 memcpy( data, tile.data, dataLength );
00152 memoryManaged = 1;
00153 }
00154 }
00155
00156
00158 RawTile& operator= ( const RawTile& tile ) {
00159
00160 dataLength = tile.dataLength;
00161 width = tile.width;
00162 height = tile.height;
00163 channels = tile.channels;
00164 bpc = tile.bpc;
00165 tileNum = tile.tileNum;
00166 resolution = tile.resolution;
00167 hSequence = tile.hSequence;
00168 vSequence = tile.vSequence;
00169 compressionType = tile.compressionType;
00170 quality = tile.quality;
00171 filename = tile.filename;
00172 timestamp = tile.timestamp;
00173 padded = tile.padded;
00174
00175 if( bpc == 16 ) data = new unsigned short[dataLength/2];
00176 else data = new unsigned char[dataLength];
00177
00178 if( data && (dataLength > 0) && tile.data ){
00179 memcpy( data, tile.data, dataLength );
00180 memoryManaged = 1;
00181 }
00182
00183 return *this;
00184 }
00185
00186
00188 int size() { return dataLength; }
00189
00190
00192 friend int operator == ( const RawTile& A, const RawTile& B ) {
00193 if( (A.tileNum == B.tileNum) &&
00194 (A.resolution == B.resolution) &&
00195 (A.hSequence == B.hSequence) &&
00196 (A.vSequence == B.vSequence) &&
00197 (A.compressionType == B.compressionType) &&
00198 (A.quality == B.quality) &&
00199 (A.filename == B.filename) ){
00200 return( 1 );
00201 }
00202 else return( 0 );
00203 }
00204
00205
00207 friend int operator != ( const RawTile& A, const RawTile& B ) {
00208 if( (A.tileNum == B.tileNum) &&
00209 (A.resolution == B.resolution) &&
00210 (A.hSequence == B.hSequence) &&
00211 (A.vSequence == B.vSequence) &&
00212 (A.compressionType == B.compressionType) &&
00213 (A.quality == B.quality) &&
00214 (A.filename == B.filename) ){
00215 return( 0 );
00216 }
00217 else return( 1 );
00218 }
00219
00220
00221 };
00222
00223
00224 #endif