scantools
1.0.4
Graphics manipulation with a view towards scanned documents
|
This namespace gathers static methods for data compression and decompression. More...
Enumerations | |
enum | zlibCompressionStrategy { standard , filtered } |
Compression strategy. More... | |
Functions | |
QImage | faxG4Decode (const QByteArray &data, int width, int heightEstimate=0) |
Decompresses a bitonal image following the CCITT Group 4 compression standard. More... | |
QByteArray | faxG4Encode (const QImage &image) |
Compresses a bitonal image following the CCITT Group 4 compression standard. More... | |
QByteArray | zlibCompress (const QByteArray &src, zlibCompressionStrategy strategy=standard) |
Compresses a QByteArray using zlib. More... | |
QByteArray | zlibUncompress (const QByteArray &src, quint64 estimatedOutputSize=0) |
Uncompresses a QByteArray using zlib. More... | |
QByteArray | zopfliCompress (const QByteArray &src) |
Compresses a QByteArray using zopfli. More... | |
This namespace gathers static methods for data compression and decompression.
Compression strategy.
The zlib compression library allows to tune the compression algorithm, to achieve better compression rates depending on the type of input data.
Definition at line 36 of file compression.h.
QImage compression::faxG4Decode | ( | const QByteArray & | data, |
int | width, | ||
int | heightEstimate = 0 |
||
) |
Decompresses a bitonal image following the CCITT Group 4 compression standard.
This method reconstructs a bitonal image from the CCITT Group 4 compressed data.
data | Data that is to be decoded. |
width | Width of the encoded image. Note that image size cannot be deducted from FAX data. |
heightEstimate | Estimate for the height of the encoded image. The height can be deducted from the FAX data, so that this data is optional. Decompression speed is, however, slightly better if the correct height is known in advance. |
QByteArray compression::faxG4Encode | ( | const QImage & | image | ) |
Compresses a bitonal image following the CCITT Group 4 compression standard.
This method compresses a bitonal image following the CCITT Group 4 compression standard (also known as "Fax G4" compression, defined in ITU-T T.6). This compression method is lossless, typically achieves a 20:1 compression ratio and is used widely in FAX machines, as well as in TIFF and PDF files.
image | The image that is to be encoded. The method works best if the image is in format QImage::Format_Mono and if color 0 is the black and color 1 is white. If these conditions are not met, a local copy of the image is made and transformed to match these conditions; this will use extra processing time. |
QByteArray compression::zlibCompress | ( | const QByteArray & | src, |
zlibCompressionStrategy | strategy = standard |
||
) |
Compresses a QByteArray using zlib.
Compresses the contents of a QByteArray using zlib. In contrast to Qt's method "qCompress", the output of this method is a valid zLib data stream.
src | QByteArray holding uncompressed data |
strategy | Strategy used by zlib in the compression |
QByteArray compression::zlibUncompress | ( | const QByteArray & | src, |
quint64 | estimatedOutputSize = 0 |
||
) |
Uncompresses a QByteArray using zlib.
Compresses the contents of a QByteArray using zlib.
src | QByteArray holding compressed data |
estimatedOutputSize | Expected size of the uncompressed data, in bytes. |
QByteArray compression::zopfliCompress | ( | const QByteArray & | src | ) |
Compresses a QByteArray using zopfli.
Compresses the contents of a QByteArray using Google's 'zopfli' implementation, which produces better results than zlib, but is slower by a factor of almost 100x. The output of this method is a valid zLib data stream.
src | QByteArray holding uncompressed data |