iipsrv 1.3
iipsrv is an advanced high-performance feature-rich image server for web-based streamed viewing and zooming of ultra high-resolution images
JPEGImage.h
1/* IIP Server: JPEG input handler: Efficient decoding of tiles and regions from JPEG images
2
3 Copyright (C) 2024-2025 Ruven Pillay.
4
5 This program is free software: you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation, either version 3 of the License, or
8 (at your option) any later version.
9
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
14
15 You should have received a copy of the GNU General Public License
16 along with this program. If not, see <http://www.gnu.org/licenses/>.
17
18*/
19
20#ifndef _JPEGIMAGE_H
21#define _JPEGIMAGE_H
22
23#include "IIPImage.h"
24#include <jpeglib.h>
25
26
27
28#define TILESIZE 256
29
30
33class JPEGImage : public IIPImage {
34
35 private:
36
38 FILE *_input;
39
41 struct jpeg_decompress_struct cinfo;
42 struct jpeg_error_mgr jerr;
43
44
46
54 void process( unsigned int r, int l, int x, int y, unsigned int w, unsigned int h, void* d );
55
56
57
58 public:
59
62 _input = NULL;
63 tile_widths.push_back(TILESIZE); tile_heights.push_back(TILESIZE);
64 };
65
66
68
70 JPEGImage( const std::string& path ) : IIPImage(path){
71 _input = NULL;
72 tile_widths.push_back(TILESIZE); tile_heights.push_back(TILESIZE);
73 };
74
75
77
79 JPEGImage( const JPEGImage& image ): IIPImage( image ) {};
80
81
83
85 JPEGImage( const IIPImage& image ) : IIPImage(image){
86 _input = NULL;
87 tile_widths.push_back(TILESIZE); tile_heights.push_back(TILESIZE);
88 };
89
90
93
94
96 void openImage();
97
98
100
103 void loadImageInfo( int x, int y );
104
105
107 void closeImage();
108
109
111 bool regionDecoding(){ return true; };
112
113
115
122 RawTile getTile( int x, int y, unsigned int r, int l, unsigned int t, ImageEncoding e = ImageEncoding::RAW );
123
124
126
137 RawTile getRegion( int ha, int va, unsigned int res, int layers, int x, int y, unsigned int w, unsigned int h );
138
139
141
142 static std::string getCodecVersion(){
143#ifdef LIBJPEG_TURBO_VERSION
144#define STRINGIFY(x) #x
145#define TOSTRING(x) STRINGIFY(x)
146 return "libjpeg-turbo " TOSTRING(LIBJPEG_TURBO_VERSION);
147#else
148 return "libjpeg-" JPEG_LIB_VERSION;
149#endif
150 };
151
152};
153
154#endif
Base class to handle the input image sources.
Definition IIPImage.h:69
std::vector< unsigned int > tile_widths
The tile dimensions for each resolution.
Definition IIPImage.h:137
Definition JPEGImage.h:33
bool regionDecoding()
Return whether this image type directly handles region decoding.
Definition JPEGImage.h:111
void closeImage()
Overloaded function for closing a JPEG image.
Definition JPEGImage.cc:107
RawTile getRegion(int ha, int va, unsigned int res, int layers, int x, int y, unsigned int w, unsigned int h)
Overloaded function for returning a region from image.
Definition JPEGImage.cc:310
static std::string getCodecVersion()
Get codec version.
Definition JPEGImage.h:142
JPEGImage(const std::string &path)
Constructor.
Definition JPEGImage.h:70
JPEGImage()
Constructor.
Definition JPEGImage.h:61
JPEGImage(const JPEGImage &image)
Copy Constructor.
Definition JPEGImage.h:79
JPEGImage(const IIPImage &image)
Copy Constructor.
Definition JPEGImage.h:85
void loadImageInfo(int x, int y)
Overloaded function for loading JPEG image information.
Definition JPEGImage.cc:127
void openImage()
Overloaded function for opening a TIFF image.
Definition JPEGImage.cc:62
~JPEGImage()
Destructor.
Definition JPEGImage.h:92
RawTile getTile(int x, int y, unsigned int r, int l, unsigned int t, ImageEncoding e=ImageEncoding::RAW)
Overloaded function for getting a particular tile.
Definition JPEGImage.cc:240
Class to represent a single image tile.
Definition RawTile.h:45