iipsrv 1.2
iipsrv is an advanced high-performance feature-rich image server for web-based streamed viewing and zooming of ultra high-resolution images
KakaduImage.h
1// Kakadu JPEG2000 Image class Interface
2
3/* IIP Kakadu JPEG2000 Class
4
5
6 Development supported by Moravian Library in Brno (Moravska zemska
7 knihovna v Brne, http://www.mzk.cz/) R&D grant MK00009494301 & Old
8 Maps Online (http://www.oldmapsonline.org/) from the Ministry of
9 Culture of the Czech Republic.
10
11
12 Copyright (C) 2009-2022 IIPImage.
13 Author: Ruven Pillay
14
15 This program is free software; you can redistribute it and/or modify
16 it under the terms of the GNU General Public License as published by
17 the Free Software Foundation; either version 3 of the License, or
18 (at your option) any later version.
19
20 This program is distributed in the hope that it will be useful,
21 but WITHOUT ANY WARRANTY; without even the implied warranty of
22 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
23 GNU General Public License for more details.
24
25 You should have received a copy of the GNU General Public License
26 along with this program; if not, write to the Free Software Foundation,
27 Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
28*/
29
30
31#ifndef _KAKADUIMAGE_H
32#define _KAKADUIMAGE_H
33
34
35#include "IIPImage.h"
36
37#include <jpx.h>
38#include <jp2.h>
39#include <kdu_stripe_decompressor.h>
40#include <fstream>
41
42#define TILESIZE 256
43
44// Kakadu 7.5 uses namespaces
45#if KDU_MAJOR_VERSION > 7 || (KDU_MAJOR_VERSION == 7 && KDU_MINOR_VERSION >= 5)
46using namespace kdu_supp; // Also includes the `kdu_core' namespace
47#endif
48
49
50
52class KakaduImage : public IIPImage {
53
54 private:
55
57 kdu_codestream codestream;
58
60 kdu_compressed_source *input;
61
63 jpx_source jpx_input;
64
66 jp2_family_src src;
67
69 jpx_codestream_source jpx_stream;
70
72 kdu_stripe_decompressor decompressor;
73
75 kdu_dims comp_dims;
76
78
86 void process( unsigned int r, int l, int x, int y, unsigned int w, unsigned int h, void* d );
87
89
91 void delete_buffer( void* b );
92
93
94 public:
95
98 tile_widths.push_back(TILESIZE); tile_heights.push_back(TILESIZE); input = NULL;
99 };
100
102
104 KakaduImage( const std::string& path ): IIPImage( path ){
105 tile_widths.push_back(TILESIZE); tile_heights.push_back(TILESIZE); input = NULL;
106 };
107
109
111 KakaduImage( const KakaduImage& image ): IIPImage( image ) {};
112
114
116 KakaduImage( const IIPImage& image ): IIPImage( image ){
117 tile_widths.push_back(TILESIZE); tile_heights.push_back(TILESIZE); input = NULL;
118 };
119
121
124 if( this != &image ){
125 closeImage();
126 IIPImage::operator=(image);
127 }
128 return *this;
129 }
130
131
134
135
137 static void setupLogging();
138
139
141 void openImage();
142
144
147 void loadImageInfo( int x, int y );
148
151
153 bool regionDecoding(){ return true; };
154
156
162 RawTile getTile( int x, int y, unsigned int r, int l, unsigned int t );
163
165
176 RawTile getRegion( int ha, int va, unsigned int r, int l, int x, int y, unsigned int w, unsigned int h );
177
182 };
183
186
187
188};
189
190
191#endif
Main class to handle the pyramidal image source.
Definition: IIPImage.h:76
IIPImage & operator=(IIPImage image)
Assignment operator.
Definition: IIPImage.h:457
std::vector< unsigned int > tile_widths
The tile dimensions for each resolution.
Definition: IIPImage.h:139
Image class for Kakadu JPEG2000 Images: Inherits from IIPImage. Uses the Kakadu library.
Definition: KakaduImage.h:52
KDU_READMODE kdu_readmode
Read-mode.
Definition: KakaduImage.h:185
KakaduImage()
Constructor.
Definition: KakaduImage.h:97
bool regionDecoding()
Return whether this image type directly handles region decoding.
Definition: KakaduImage.h:153
KakaduImage(const std::string &path)
Constructor.
Definition: KakaduImage.h:104
static void setupLogging()
Overloaded static function for seting up logging for codec library.
void openImage()
Overloaded function for opening a TIFF image.
void loadImageInfo(int x, int y)
Overloaded function for loading TIFF image information.
~KakaduImage()
Destructor.
Definition: KakaduImage.h:133
RawTile getTile(int x, int y, unsigned int r, int l, unsigned int t)
Overloaded function for getting a particular tile.
void closeImage()
Overloaded function for closing a JPEG2000 image.
KDU_READMODE
Read-mode types.
Definition: KakaduImage.h:179
@ KDU_FUSSY
Fussy mode.
Definition: KakaduImage.h:180
@ KDU_RESILIENT
Reslient mode for damaged JP2 streams.
Definition: KakaduImage.h:181
@ KDU_FAST
Default fast mode.
Definition: KakaduImage.h:179
KakaduImage(const KakaduImage &image)
Copy Constructor.
Definition: KakaduImage.h:111
KakaduImage(const IIPImage &image)
Constructor from IIPImage object.
Definition: KakaduImage.h:116
KakaduImage & operator=(KakaduImage image)
Assignment Operator.
Definition: KakaduImage.h:123
RawTile getRegion(int ha, int va, unsigned int r, int l, int x, int y, unsigned int w, unsigned int h)
Overloaded function for returning a region for a given angle and resolution.
Class to represent a single image tile.
Definition: RawTile.h:47