Use JWCompress to create .jpg files using RGB or YUV image data.
More...
#include <JWCompress.hpp>
Public Member Functions | |
JWCompress (void) | |
Constructor. More... | |
virtual | ~JWCompress (void) |
Destructor. More... | |
virtual JWCompress & | compress (void) |
Compress the given data. More... | |
virtual JWCompress & | compress_yuv422 (const uint8_t *const data, const size_t bytes_per_row) |
Create a JPEG from 16-bit YUYV data (aka YUY2, or YUV 4:2:2 format). More... | |
virtual JWCompress & | set_size (const size_t width, const size_t height) |
Set the size of the image. More... | |
virtual JWCompress & | set_colour (const int components=3, const J_COLOR_SPACE colour_space=JCS_RGB) |
Set the number of colour components and the colour space. More... | |
virtual JWCompress & | set_default_parameters (const J_COLOR_SPACE colour_space=JCS_RGB) |
Set usable default values for most of the optional parameters. More... | |
virtual JWCompress & | set_quality (const int quality=75, const bool force_baseline=true) |
Constructs JPEG quantization tables appropriate for the indicated quality setting. More... | |
virtual JWCompress & | optimized_huffman_tables (void) |
Causes the compressor to compute optimal Huffman coding tables for the image. More... | |
virtual JWCompress & | set_smoothing (const int smoothing=0) |
Determine if smoothing is accessed. Zero turns it off, 100 sets the maximum amount of smoothing. More... | |
virtual std::string | get_filename (void) const |
The filename used for input (decompress) or output (compress) if set via set_file(). More... | |
virtual JWCompress & | set_output_file (const std::string &filename) |
Set the output file into which the compressed JPEG image will be stored. More... | |
virtual JWCompress & | set_output_file (FILE *f) |
Set the output file into which the compressed JPEG image will be stored. More... | |
virtual JWCompress & | use_arithmetic_coding (void) |
Arithmetic coding will usually result in marginally smaller files, but require more CPU than Huffman coding. More... | |
virtual JWCompress & | use_huffman_coding (void) |
Arithmetic coding will usually result in marginally smaller files, but require more CPU than Huffman coding. More... | |
virtual JWCompress & | use_integer_slow_dct (void) |
The FLOAT method is very slightly more accurate than the ISLOW method, but may give different results on different machines due to varying roundoff behavior. More... | |
virtual JWCompress & | use_integer_fast_dct (void) |
The FLOAT method is very slightly more accurate than the ISLOW method, but may give different results on different machines due to varying roundoff behavior. More... | |
virtual JWCompress & | use_float_dct (void) |
The FLOAT method is very slightly more accurate than the ISLOW method, but may give different results on different machines due to varying roundoff behavior. More... | |
Public Attributes | |
jpeg_compress_struct | cinfo |
IJG's compression structure. More... | |
jpeg_error_mgr | jerr |
IJG's structures and pointers to those structures used by derived classes. More... | |
jpeg_error_mgr * | jerr_ptr |
IJG's structures and pointers to those structures used by derived classes. More... | |
jpeg_compress_struct * | cinfo_ptr |
IJG's structures and pointers to those structures used by derived classes. More... | |
jpeg_decompress_struct * | dinfo_ptr |
IJG's structures and pointers to those structures used by derived classes. More... | |
Protected Member Functions | |
virtual JW & | set_file (const std::string &filename) |
Protected method to set the input or output file. More... | |
virtual JW & | set_file (FILE *f) |
Protected Attributes | |
std::string | fname |
The filename used for input (decompress) or output (compress) if set via set_file(). More... | |
FILE * | file |
Input/output file. Used for output when compressing, and input when decompressing. More... | |
Use JWCompress to create .jpg files using RGB or YUV image data.
JWCompress::JWCompress | ( | void | ) |
Constructor.
|
virtual |
Destructor.
|
virtual |
Compress the given data.
|
virtual |
Create a JPEG from 16-bit YUYV data (aka YUY2, or YUV 4:2:2 format).
This format is popular with web cams. The output file is closed in this method once the image has been written.
std::logic_error | if the output file has not been set |
std::logic_error | if the image width or height is invalid or has not been set |
std::invalid_argument | if the image data pointer is null |
std::invalid_argument | if the bytes per row is invalid |
|
inlinevirtualinherited |
The filename used for input (decompress) or output (compress) if set via set_file().
The only way to set the input or output file is to call JWCompress::set_output_file() or JWDecompress::set_input_file().
|
inlinevirtual |
Causes the compressor to compute optimal Huffman coding tables for the image.
This requires an extra pass over the data and therefore costs a good deal of space and time. The default is FALSE
, which tells the compressor to use the supplied or default Huffman tables. In most cases optimal tables save only a few percent of file size compared to the default tables.
|
virtual |
Set the number of colour components and the colour space.
|
virtual |
Set usable default values for most of the optional parameters.
This sets all JPEG parameters to reasonable defaults, using only the input image's color space. Many applications will only need to use this routine and perhaps set_quality().
|
protectedvirtualinherited |
Protected method to set the input or output file.
Use the equivalent functions in the derived classes instead.
std::runtime_error | if the named file cannot be opened |
|
protectedvirtualinherited |
std::runtime_error | if the file pointer is null |
|
inlinevirtual |
Set the output file into which the compressed JPEG image will be stored.
|
inlinevirtual |
Set the output file into which the compressed JPEG image will be stored.
|
virtual |
Constructs JPEG quantization tables appropriate for the indicated quality setting.
The quality value is expressed on the 0..100 scale recommended by IJG. The exact mapping from quality values to tables may change in future IJG releases as more is learned about DCT quantization. If the force_baseline parameter is TRUE
, then the quantization table entries are constrained to the range 1..255 for full JPEG baseline compatibility. In the current implementation, this only makes a difference for quality settings below 25, and it effectively prevents very small/low quality files from being generated. The IJG decoder is capable of reading the non-baseline files generated at low quality settings when force_baseline is FALSE
, but other decoders may not be.
|
virtual |
Set the size of the image.
|
inlinevirtual |
Determine if smoothing is accessed. Zero turns it off, 100 sets the maximum amount of smoothing.
|
inlinevirtual |
Arithmetic coding will usually result in marginally smaller files, but require more CPU than Huffman coding.
|
inlinevirtual |
The FLOAT method is very slightly more accurate than the ISLOW method, but may give different results on different machines due to varying roundoff behavior.
The integer methods should give the same results on all machines. On machines with sufficiently fast FP hardware, the floating-point method may also be the fastest. The IFAST method is considerably less accurate than the other two; its use is not recommended if high quality is a concern.
|
inlinevirtual |
Arithmetic coding will usually result in marginally smaller files, but require more CPU than Huffman coding.
|
inlinevirtual |
The FLOAT method is very slightly more accurate than the ISLOW method, but may give different results on different machines due to varying roundoff behavior.
The integer methods should give the same results on all machines. On machines with sufficiently fast FP hardware, the floating-point method may also be the fastest. The IFAST method is considerably less accurate than the other two; its use is not recommended if high quality is a concern.
|
inlinevirtual |
The FLOAT method is very slightly more accurate than the ISLOW method, but may give different results on different machines due to varying roundoff behavior.
The integer methods should give the same results on all machines. On machines with sufficiently fast FP hardware, the floating-point method may also be the fastest. The IFAST method is considerably less accurate than the other two; its use is not recommended if high quality is a concern.
jpeg_compress_struct JWCompress::cinfo |
IJG's compression structure.
|
inherited |
IJG's structures and pointers to those structures used by derived classes.
|
inherited |
IJG's structures and pointers to those structures used by derived classes.
|
protectedinherited |
Input/output file. Used for output when compressing, and input when decompressing.
|
protectedinherited |
The filename used for input (decompress) or output (compress) if set via set_file().
|
inherited |
IJG's structures and pointers to those structures used by derived classes.
|
inherited |
IJG's structures and pointers to those structures used by derived classes.