Basic Image AlgorithmS Library
2.8.0
|
Wrapper for fast libjpeg methods. More...
#include <Base/Image/CompressJpeg.hh>
Public Member Functions | |
int | Compress (BIAS::Image< unsigned char > &srcImg, int quality=60) |
Start compression for given BIAS::Image into buffer. More... | |
int | Compress (unsigned int width, unsigned int height, unsigned int channels, unsigned char *data, int quality=60) |
Start compression for given image data from buffer. More... | |
int | Compress (unsigned int width, unsigned int height, unsigned int channels, unsigned char *inData, unsigned char *outData, long &outBytes, int quality=60) |
Start compression for given image data to given output buffer. More... | |
int | Decompress (BIAS::Image< unsigned char > &destImg, bool readComment=false) |
Start decompression of previously given data (from ReadJPEG() or SetCompressedData()), results will be stored in destination image. More... | |
int | Decompress (unsigned int &width, unsigned int &height, unsigned int &channels, unsigned char *&data) |
Start decompression of previously given data (from ReadJPEG() or SetCompressedData()), results will be stored in data, width, ... More... | |
int | Decompress (unsigned int &width, unsigned int &height, unsigned int &channels, unsigned char *inData, long inBytes, unsigned char *outData) |
Start decompression of given data and write result to given output buffer. More... | |
void | GetCompressedData (void *&data, long &length) |
Get pointer to memory where to find compressed data and its length in byte. More... | |
long | GetCompressedDataSize () |
Return compressed data length in bytes. More... | |
int | Init (long size=10485760) |
Initialize object with standard values and limit shared memory area to given size (in byte, default is 10 MByte). More... | |
bool | IsInitialized () |
Returns if an internal buffer has been initialized. More... | |
JpegHandler () | |
Constructor with empty internal buffer. More... | |
JpegHandler (long size) | |
Constructor with initialized internal buffer. More... | |
int | ReadJPEG (const std::string &filename) |
Read JPEG file named filename and store its informations in compressed data field. More... | |
void | Release () |
Releases allocated memory. More... | |
void | SetCompressedData (void *data, long length) |
Copy memory area in which compressed data can be found and set its length in byte. More... | |
void | SetVerbose (const bool verbose) |
Print error messages to standard output or keep quiet? More... | |
int | WriteJPEG (const std::string &filename) |
Write previously compressed data to file named filename. More... | |
virtual | ~JpegHandler () |
Destructor releases internal buffer. More... | |
Protected Attributes | |
long | bufferSize_ |
Length in byte of compression buffer (max. More... | |
void * | data_ |
Pointer to compression buffer (compressed data) More... | |
long | dataLength_ |
Length in byte of compressed data. More... | |
bool | verbose_ |
Print error messages or keep quiet? More... | |
Wrapper for fast libjpeg methods.
Class for memory-to-memory JPEG compression. Compress a given BIAS::Image (unsigned char) to data array in shared memory or decompress a given JPEG file located in user memory into a BIAS::Image (unsigned char).
Definition at line 50 of file CompressJpeg.hh.
JpegHandler::JpegHandler | ( | ) |
Constructor with empty internal buffer.
Definition at line 678 of file CompressJpeg.cpp.
JpegHandler::JpegHandler | ( | long | size | ) |
Constructor with initialized internal buffer.
Definition at line 686 of file CompressJpeg.cpp.
|
virtual |
Destructor releases internal buffer.
Definition at line 695 of file CompressJpeg.cpp.
int JpegHandler::Compress | ( | BIAS::Image< unsigned char > & | srcImg, |
int | quality = 60 |
||
) |
Start compression for given BIAS::Image into buffer.
Definition at line 726 of file CompressJpeg.cpp.
References BIAS::ImageBase::GetChannelCount(), BIAS::ImageBase::GetHeight(), BIAS::Image< StorageType >::GetImageData(), and BIAS::ImageBase::GetWidth().
Referenced by BIAS::ImageIO::ExportLibJPEG(), and BIAS::VideoTransmitter::Process().
int JpegHandler::Compress | ( | unsigned int | width, |
unsigned int | height, | ||
unsigned int | channels, | ||
unsigned char * | data, | ||
int | quality = 60 |
||
) |
Start compression for given image data from buffer.
Definition at line 750 of file CompressJpeg.cpp.
int JpegHandler::Compress | ( | unsigned int | width, |
unsigned int | height, | ||
unsigned int | channels, | ||
unsigned char * | inData, | ||
unsigned char * | outData, | ||
long & | outBytes, | ||
int | quality = 60 |
||
) |
Start compression for given image data to given output buffer.
The internal buffer is not used here, hence it is allowed to be uninitialized.
Definition at line 799 of file CompressJpeg.cpp.
int JpegHandler::Decompress | ( | BIAS::Image< unsigned char > & | destImg, |
bool | readComment = false |
||
) |
Start decompression of previously given data (from ReadJPEG() or SetCompressedData()), results will be stored in destination image.
Decompress() will initialize destination image properly if needed.
Definition at line 775 of file CompressJpeg.cpp.
Referenced by BIAS::VideoSource_Net::GrabSingle(), and BIAS::ImageIO::ImportLibJPEG().
int JpegHandler::Decompress | ( | unsigned int & | width, |
unsigned int & | height, | ||
unsigned int & | channels, | ||
unsigned char *& | data | ||
) |
Start decompression of previously given data (from ReadJPEG() or SetCompressedData()), results will be stored in data, width, ...
New memory for data will only be allocated if data == NULL, else old allocated memory will be used, so set data = NULL if you're not sure about it's size!
Definition at line 786 of file CompressJpeg.cpp.
int JpegHandler::Decompress | ( | unsigned int & | width, |
unsigned int & | height, | ||
unsigned int & | channels, | ||
unsigned char * | inData, | ||
long | inBytes, | ||
unsigned char * | outData | ||
) |
Start decompression of given data and write result to given output buffer.
The internal buffer is not used here, hence it is allowed to be uninitialized.
Definition at line 819 of file CompressJpeg.cpp.
|
inline |
Get pointer to memory where to find compressed data and its length in byte.
Definition at line 140 of file CompressJpeg.hh.
Referenced by BIAS::VideoTransmitter::Process().
|
inline |
Return compressed data length in bytes.
Definition at line 148 of file CompressJpeg.hh.
int JpegHandler::Init | ( | long | size = 10485760 | ) |
Initialize object with standard values and limit shared memory area to given size (in byte, default is 10 MByte).
Re-initialization is only required for changing buffer size.
Definition at line 700 of file CompressJpeg.cpp.
Referenced by BIAS::ImageIO::ExportLibJPEG(), BIAS::ImageIO::ImportLibJPEG(), BIAS::VideoTransmitter::Init(), BIAS::VideoSource_V4L::OpenDevice(), and BIAS::VideoSource_Net::VideoSource_Net().
|
inline |
Returns if an internal buffer has been initialized.
Definition at line 75 of file CompressJpeg.hh.
int JpegHandler::ReadJPEG | ( | const std::string & | filename | ) |
Read JPEG file named filename and store its informations in compressed data field.
Definition at line 854 of file CompressJpeg.cpp.
Referenced by BIAS::ImageIO::ImportLibJPEG().
void JpegHandler::Release | ( | ) |
Releases allocated memory.
Use it to regain memory but call Init() again bevor using object afterwards!
Definition at line 716 of file CompressJpeg.cpp.
Referenced by BIAS::VideoSource_Net::CloseDevice(), BIAS::ImageIO::ExportLibJPEG(), and BIAS::ImageIO::ImportLibJPEG().
|
inline |
Copy memory area in which compressed data can be found and set its length in byte.
Definition at line 154 of file CompressJpeg.hh.
Referenced by BIAS::VideoSource_Net::GrabSingle().
|
inline |
Print error messages to standard output or keep quiet?
Definition at line 175 of file CompressJpeg.hh.
Referenced by BIAS::ImageIO::ExportLibJPEG(), and BIAS::ImageIO::ImportLibJPEG().
int JpegHandler::WriteJPEG | ( | const std::string & | filename | ) |
Write previously compressed data to file named filename.
Definition at line 825 of file CompressJpeg.cpp.
Referenced by BIAS::ImageIO::ExportLibJPEG().
|
protected |
Length in byte of compression buffer (max.
data size)
Definition at line 186 of file CompressJpeg.hh.
|
protected |
Pointer to compression buffer (compressed data)
Definition at line 180 of file CompressJpeg.hh.
|
protected |
Length in byte of compressed data.
Definition at line 183 of file CompressJpeg.hh.
|
protected |
Print error messages or keep quiet?
Definition at line 189 of file CompressJpeg.hh.