ImFusion SDK 4.3
ImageCompression Class Reference

#include <ImFusion/Base/ImageCompression.h>

Saving and loading of compressed image data. More...

+ Inheritance diagram for ImageCompression:

Detailed Description

Saving and loading of compressed image data.

Public Member Functions

 ImageCompression (SharedImageSet *is, const ImageDescriptor &desc, int frames=1)
 Constructor for loading data with empty image set container.
 
 ImageCompression (SharedImageSet *is)
 Constructor with an allocated image set container to load, analyze or save.
 
 ~ImageCompression ()
 Destructor deleting auxiliary variables but not image data.
 
void setProgress (Progress *p)
 Set optional progress callback.
 
void setOptions (int numRuns, int diffRX, int diffRY)
 Set options for thorough compression.
 
unsigned long long analyze ()
 Process the image data with given settings and return predicted size in KB.
 
unsigned long long size (int mode) const
 Return size in KB for a given compression mode after analysis.
 
int scaling () const
 Return the integer intensity scaling that was found during analysis.
 
bool load (std::istream &file)
 Loads a compressed image from file.
 
bool save (std::ostream &file, bool borderRLE)
 Save an image set using thorough compression, return true upon success.
 
bool saveOnTheFly (std::ostream &file, const MemImage *img)
 Save an image or single image frame right on the fly.
 

Static Public Member Functions

static bool compress (const MemImage *img, int mode, int level, unsigned char *buffer, int &bufferSize)
 Compress image.
 
static bool uncompress (unsigned char *buffer, int bufferSize, int mode, MemImage *img)
 Uncompress image.
 

Member Function Documentation

◆ saveOnTheFly()

bool saveOnTheFly ( std::ostream & file,
const MemImage * img )

Save an image or single image frame right on the fly.

The numRuns parameter is ignored, full 8 or 16 bit range is assumed for default Huffman codes, previous frame codes are disabled.

◆ compress()

static bool compress ( const MemImage * img,
int mode,
int level,
unsigned char * buffer,
int & bufferSize )
static

Compress image.

Parameters
imgimage to compress
modecompression mode: 0 = zlib default strategy, 1 = zlib huffman, 2 = zlib rle, 3 = png
levelcompression level ranging from 0 (no compression) to 9 (maximum compression). Has no effect for huffman and rle mode
[out]bufferoutput buffer. Size should be at least twice the size of the input image in bytes
[in,out]bufferSizesize of provided output buffer on input, number of bytes written on return
Returns
true if successful, false otherwise

◆ uncompress()

static bool uncompress ( unsigned char * buffer,
int bufferSize,
int mode,
MemImage * img )
static

Uncompress image.

Parameters
bufferinput buffer
bufferSizesize of input buffer
modecompression mode: 0 = zlib default strategy, 1 = zlib huffman, 2 = zlib rle, 3 = png
[out]imguncompressed image
Returns
true if successful, false otherwise

The documentation for this class was generated from the following file:
Search Tab / S to search, Esc to close