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
Compressor.h
1/* Generic compressor class - extended by JPEG and PNG Compressor classes
2
3 Copyright (C) 2017-2023 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, write to the Free Software Foundation,
17 Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
18*/
19
20
21#ifndef _COMPRESSOR_H
22#define _COMPRESSOR_H
23
24
25
26#include <string>
27#include "RawTile.h"
28
29
30
33
34 protected:
35
37 int Q;
38
40 unsigned char *header;
41
43 unsigned int header_size;
44
46 float dpi_x, dpi_y;
47
49
51
53 std::string icc;
54
56 std::string xmp;
57
59 virtual void writeICCProfile() {};
60
62 virtual void writeXMPMetadata() {};
63
64
65 public:
66
68
69 Compressor( int compressionLevel ) :
70 Q( compressionLevel ),
71 header( NULL ),
72 header_size( 0 ),
73 dpi_x( 0 ),
74 dpi_y( 0 ),
75 dpi_units( 0 ) {};
76
77
78 virtual ~Compressor() {};
79
80
82 inline int getQuality() const { return Q; }
83
84
86 inline void setResolution( float x, float y, int units ){ dpi_x = x; dpi_y = y; dpi_units = units; };
87
88
90
91 inline void setICCProfile( const std::string& profile ){ icc = profile; }
92
93
95
96 inline void setXMPMetadata( const std::string& x ){ xmp = x; }
97
98
100
101 virtual unsigned int getHeaderSize() const { return 0; };
102
103
105
106 virtual unsigned char* getHeader() { return NULL; };
107
108
110
116 virtual void InitCompression( const RawTile& rawtile, unsigned int strip_height ) {};
117
118
120
125 virtual unsigned int CompressStrip( unsigned char* s, unsigned char* o, unsigned int tile_height ) { return 0; };
126
127
129
132 virtual unsigned int Finish( unsigned char* output ) { return 0; };
133
134
136
139 virtual unsigned int Compress( RawTile& t ) { return 0; };
140
141
143
144 virtual void addXMPMetadata( const std::string& m ) {};
145
146
148
149 virtual const char* getMimeType() const { return "image/example"; };
150
151
153
154 virtual const char* getSuffix() const { return "img"; };
155
156
158
159 virtual CompressionType getCompressionType() const { return UNCOMPRESSED; };
160
161};
162
163#endif
Base class for IIP output images.
Definition: Compressor.h:32
virtual const char * getSuffix() const
Get file suffix.
Definition: Compressor.h:154
int dpi_units
Resolution units.
Definition: Compressor.h:50
virtual unsigned int CompressStrip(unsigned char *s, unsigned char *o, unsigned int tile_height)
Compress a strip of image data.
Definition: Compressor.h:125
Compressor(int compressionLevel)
Constructor.
Definition: Compressor.h:69
std::string xmp
XMP metadata.
Definition: Compressor.h:56
int getQuality() const
Get the current quality level.
Definition: Compressor.h:82
virtual void writeICCProfile()
Write ICC profile.
Definition: Compressor.h:59
virtual void writeXMPMetadata()
Write XMP metadata.
Definition: Compressor.h:62
unsigned int header_size
Size of the header data.
Definition: Compressor.h:43
std::string icc
ICC Profile.
Definition: Compressor.h:53
int Q
Quality or compression level for all image types.
Definition: Compressor.h:37
virtual unsigned int Finish(unsigned char *output)
Finish the strip based compression and free memory.
Definition: Compressor.h:132
unsigned char * header
Pointer to the header data for the output image.
Definition: Compressor.h:40
virtual void InitCompression(const RawTile &rawtile, unsigned int strip_height)
Initialise strip based compression.
Definition: Compressor.h:116
float dpi_x
Physical resolution for X and Y directions.
Definition: Compressor.h:46
virtual unsigned int getHeaderSize() const
Return the image header size.
Definition: Compressor.h:101
void setResolution(float x, float y, int units)
Set the physical output resolution.
Definition: Compressor.h:86
virtual CompressionType getCompressionType() const
Get compression type.
Definition: Compressor.h:159
void setICCProfile(const std::string &profile)
Set the ICC profile.
Definition: Compressor.h:91
virtual unsigned char * getHeader()
Return a pointer to the image header itself.
Definition: Compressor.h:106
virtual unsigned int Compress(RawTile &t)
Compress an entire buffer of image data at once in one command.
Definition: Compressor.h:139
virtual void addXMPMetadata(const std::string &m)
Add metadata to the image header.
Definition: Compressor.h:144
void setXMPMetadata(const std::string &x)
Set XMP metadata.
Definition: Compressor.h:96
virtual const char * getMimeType() const
Get mime type.
Definition: Compressor.h:149
Class to represent a single image tile.
Definition: RawTile.h:47