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
PNGCompressor Class Reference

Wrapper class to PNG library: Handles 8 and 16 bit PNG as well as alpha transparency. More...

#include <PNGCompressor.h>

Inheritance diagram for PNGCompressor:
Compressor

Public Member Functions

 PNGCompressor (int compressionLevel)
 Constructor.
 
void InitCompression (const RawTile &rawtile, unsigned int strip_height)
 Initialize strip based compression.
 
unsigned int CompressStrip (unsigned char *source, unsigned char *output, unsigned int tile_height)
 Compress a strip of image data.
 
unsigned int Finish (unsigned char *output)
 Finish the strip based compression and free memory.
 
unsigned int Compress (RawTile &t)
 Compress an entire buffer of image data at once in one command.
 
unsigned int getHeaderSize () const
 Return the PNG header size.
 
unsigned char * getHeader ()
 Return a pointer to the header itself.
 
const char * getMimeType () const
 Return the PNG mime type.
 
const char * getSuffix () const
 Return the image filename suffix.
 
CompressionType getCompressionType () const
 Get compression type.
 
int getQuality () const
 Get the current compression level.
 
void setQuality (int quality)
 Set the compression level.
 
- Public Member Functions inherited from Compressor
 Compressor (int compressionLevel)
 Constructor.
 
int getQuality () const
 Get the current quality level.
 
void setResolution (float x, float y, int units)
 Set the physical output resolution.
 
void setICCProfile (const std::string &profile)
 Set the ICC profile.
 
void setXMPMetadata (const std::string &x)
 Set XMP metadata.
 
virtual unsigned int getHeaderSize () const
 Return the image header size.
 
virtual unsigned char * getHeader ()
 Return a pointer to the image header itself.
 
virtual void InitCompression (const RawTile &rawtile, unsigned int strip_height)
 Initialise strip based compression.
 
virtual unsigned int CompressStrip (unsigned char *s, unsigned char *o, unsigned int tile_height)
 Compress a strip of image data.
 
virtual unsigned int Finish (unsigned char *output)
 Finish the strip based compression and free memory.
 
virtual unsigned int Compress (RawTile &t)
 Compress an entire buffer of image data at once in one command.
 
virtual void addXMPMetadata (const std::string &m)
 Add metadata to the image header.
 
virtual const char * getMimeType () const
 Get mime type.
 
virtual const char * getSuffix () const
 Get file suffix.
 
virtual CompressionType getCompressionType () const
 Get compression type.
 

Additional Inherited Members

virtual void writeICCProfile ()
 Write ICC profile.
 
virtual void writeXMPMetadata ()
 Write XMP metadata.
 
- Protected Attributes inherited from Compressor
int Q
 Quality or compression level for all image types.
 
unsigned char * header
 Pointer to the header data for the output image.
 
unsigned int header_size
 Size of the header data.
 
float dpi_x
 Physical resolution for X and Y directions.
 
float dpi_y
 
int dpi_units
 Resolution units.
 
std::string icc
 ICC Profile.
 
std::string xmp
 XMP metadata.
 

Detailed Description

Wrapper class to PNG library: Handles 8 and 16 bit PNG as well as alpha transparency.

Constructor & Destructor Documentation

◆ PNGCompressor()

PNGCompressor::PNGCompressor ( int  compressionLevel)
inline

Constructor.

Parameters
compressionLevelPNG compression level (zlib range is 0-9)

References png_destination_mgr::info_ptr, png_destination_mgr::output_size, and png_destination_mgr::png_ptr.

Member Function Documentation

◆ Compress()

unsigned int PNGCompressor::Compress ( RawTile t)
virtual

Compress an entire buffer of image data at once in one command.

Parameters
ttile of image data
Returns
size of compressed data

Reimplemented from Compressor.

◆ CompressStrip()

unsigned int PNGCompressor::CompressStrip ( unsigned char *  source,
unsigned char *  output,
unsigned int  tile_height 
)
virtual

Compress a strip of image data.

Parameters
sourcesource image data
tile_heightpixel height of the tile we are compressing
outputoutput_buffer
Returns
size of compressed strip

Reimplemented from Compressor.

◆ Finish()

unsigned int PNGCompressor::Finish ( unsigned char *  output)
virtual

Finish the strip based compression and free memory.

Parameters
outputOutput buffer
Returns
size of output generated

Reimplemented from Compressor.

◆ getCompressionType()

CompressionType PNGCompressor::getCompressionType ( ) const
inlinevirtual

Get compression type.

Reimplemented from Compressor.

◆ getHeader()

unsigned char * PNGCompressor::getHeader ( )
inlinevirtual

Return a pointer to the header itself.

Reimplemented from Compressor.

References Compressor::header.

◆ getHeaderSize()

unsigned int PNGCompressor::getHeaderSize ( ) const
inlinevirtual

Return the PNG header size.

Reimplemented from Compressor.

References Compressor::header_size.

◆ getMimeType()

const char * PNGCompressor::getMimeType ( ) const
inlinevirtual

Return the PNG mime type.

Reimplemented from Compressor.

◆ getQuality()

int PNGCompressor::getQuality ( ) const
inline

Get the current compression level.

Returns
Deflate compresson level

References Compressor::Q.

◆ getSuffix()

const char * PNGCompressor::getSuffix ( ) const
inlinevirtual

Return the image filename suffix.

Reimplemented from Compressor.

◆ InitCompression()

void PNGCompressor::InitCompression ( const RawTile rawtile,
unsigned int  strip_height 
)
virtual

Initialize strip based compression.

For strip based encoding, we need to first initialize with InitCompression, then compress a single strip at a time using CompressStrip and finally clean up using Finish

Parameters
rawtileRawTile object containing the image to be compressed
strip_heightheight in pixels of the strip we want to compress

Reimplemented from Compressor.

◆ setQuality()

void PNGCompressor::setQuality ( int  quality)
inline

Set the compression level.

Parameters
qualityDeflate compression level: 0-9 with (0 = no compression) Note that compression to 1 (Z_BEST_SPEED) results in a ~3x slowdown wrt to no compression

References Compressor::Q.


The documentation for this class was generated from the following file: