#include <jpeg_conversion.hpp>
|
| | JpegConversion () |
| |
| | JpegConversion (unsigned int jpeg_quality) |
| |
| | ~JpegConversion () |
| |
| void | compress (base::samples::frame::Frame const &frame_input, base::samples::frame::Frame &frame_output) |
| |
| void | decompress (base::samples::frame::Frame const &frame_input, base::samples::frame::frame_mode_t const decompress_to, base::samples::frame::Frame &frame_output) |
| |
| void | decompress (uint8_t const *src, size_t src_size, int width, int height, base::samples::frame::frame_mode_t const decompress_to, uint8_t *dst) |
| |
| J_COLOR_SPACE | getJpegColorspace (base::samples::frame::frame_mode_t const frame_mode, bool &flip_rgb, bool &is_jpeg) |
| |
| bool | storeFrame (std::string filename, base::samples::frame::Frame const &frame, std::string *used_filename=NULL) |
| |
| bool | loadJpeg (std::string const &filename, uint32_t const width, uint32_t const height, base::samples::frame::Frame &frame) |
| |
Allows to convert jpeg-frames using the IJG library. Decompress MODE_JPEG to MODE_GRAYSCALE, MODE_RGB or MODE_BGR and
compress MODE_GRAYSCALE, MODE_RGB or MODE_BGR to MODE_JPEG.
◆ JpegConversion() [1/2]
| conversion::JpegConversion::JpegConversion |
( |
| ) |
|
|
inline |
◆ JpegConversion() [2/2]
| conversion::JpegConversion::JpegConversion |
( |
unsigned int |
jpeg_quality | ) |
|
|
inline |
◆ ~JpegConversion()
| conversion::JpegConversion::~JpegConversion |
( |
| ) |
|
|
inline |
◆ compress()
| void conversion::JpegConversion::compress |
( |
base::samples::frame::Frame const & |
frame_input, |
|
|
base::samples::frame::Frame & |
frame_output |
|
) |
| |
Compresses the passed image to JPEG. Supported frame color formats are MODE_GRAYSCALE, MODE_RGB, MODE_BGR and MODE_JPEG. To keep 'frame_input' constant, using MODE_BGR creates an extra copy of the passed image. Using the jpeg quality passed in the constructor. Throws a std::runtime_error if the color mode of the input image is not supported.
- Parameters
-
| frame_input | Image which should be converted to jpeg-format. Input frame has to have one of the valid color modes. |
| frame_output | Will be set to MODE_JPEG and resized if required. |
◆ decompress() [1/2]
| void conversion::JpegConversion::decompress |
( |
base::samples::frame::Frame const & |
frame_input, |
|
|
base::samples::frame::frame_mode_t const |
decompress_to, |
|
|
base::samples::frame::Frame & |
frame_output |
|
) |
| |
Decompress the passed frame to the color format of 'frame_output'. Throws a std::runtime_error if the input image is not a jpeg or the color format of the output image is not supported.
- Parameters
-
| frame_input | Input image, must be of color format MODE_JPEG. |
| frame_output | Has to contain the color format (MODE_GRAYSCALE, MODE_RGB, MODE_BGR and MODE_JPEG) the input jpeg should be converted to. Will be resized if necessary. Color channel data depth will be set to 8.
Important: Always use frame.init(... ) to set the color format! Otherwise the internal 'init()' call could be ignored. |
◆ decompress() [2/2]
| void conversion::JpegConversion::decompress |
( |
uint8_t const * |
src, |
|
|
size_t |
src_size, |
|
|
int |
width, |
|
|
int |
height, |
|
|
base::samples::frame::frame_mode_t const |
decompress_to, |
|
|
uint8_t * |
dst |
|
) |
| |
Required by FrameHelper, abstracting from frames. Take care to allocate enough memory for the decompressed image! If you are unsure about that, use 'decompress(frame, frame, frame_mode)' instead.
- Parameters
-
| src | Pointer to JPEG data. |
| width | Width of the input and the output image. |
| height | Heigth of the input and the output image. |
| decompress_to | Frame mode to decompress to. |
| dst | Pointer to memory which should receive the decompressed image. |
◆ getJpegColorspace()
| J_COLOR_SPACE conversion::JpegConversion::getJpegColorspace |
( |
base::samples::frame::frame_mode_t const |
frame_mode, |
|
|
bool & |
flip_rgb, |
|
|
bool & |
is_jpeg |
|
) |
| |
Maps the frame colorspace to the IJG colorspace.
- Parameters
-
| flip_rgb | Is set to true if the frame colorspace is BGR (IJG just handles RGB). The R and B channel have to be switched manually before compression and accordingly after decompression. |
| is_jpeg | Is set to true if the passed frame has already a jpeg format. |
◆ loadJpeg()
| bool conversion::JpegConversion::loadJpeg |
( |
std::string const & |
filename, |
|
|
uint32_t const |
width, |
|
|
uint32_t const |
height, |
|
|
base::samples::frame::Frame & |
frame |
|
) |
| |
Loads the jpeg and store its content to 'mFrameOutput'.
◆ storeFrame()
| bool conversion::JpegConversion::storeFrame |
( |
std::string |
filename, |
|
|
base::samples::frame::Frame const & |
frame, |
|
|
std::string * |
used_filename = NULL |
|
) |
| |
If not empty, the Frame will be stored to 'filename'. Take care that the path is valid.
- Parameters
-
| filename | Just pass the plain name of the file without any extension. |
| frame | Frame to store. Valid modes are MODE_RGB, MODE_BGR, MODE_GRAYSCALE and MODE_JPEG. |
| used_filename | According to the frame type the file extension will be added to the passed filename. You can pass the address of a string to 'used_filename' to receive the complete filename (file extension included) which will be used. |
- Returns
- True if the complete image could be written.
◆ JPEG_QUALITY
| const int conversion::JpegConversion::JPEG_QUALITY = 80 |
|
static |
The documentation for this class was generated from the following files: