Fawkes API Fawkes Development Version
jpeg_compressor.h
1
2/***************************************************************************
3 * jpeg_compressor.h - JPEG image compressor interface
4 *
5 * Created: Fri Aug 11 18:53:19 2006 (on train to Cologne)
6 * Copyright 2005-2007 Tim Niemueller [www.niemueller.de]
7 *
8 ****************************************************************************/
9
10/* This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation; either version 2 of the License, or
13 * (at your option) any later version. A runtime exception applies to
14 * this software (see LICENSE.GPL_WRE file mentioned below for details).
15 *
16 * This program is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU Library General Public License for more details.
20 *
21 * Read the full text in the LICENSE.GPL_WRE file in the doc directory.
22 */
23
24#ifndef _FIREVISION_UTILS_COMPRESSION_JPEG_COMPRESSOR_H_
25#define _FIREVISION_UTILS_COMPRESSION_JPEG_COMPRESSOR_H_
26
27#include <fvutils/compression/imagecompressor.h>
28
29namespace firevision {
30
32{
33public:
34 /** JPEG color space. */
36 JPEG_CS_RGB, /**< RGB */
37 JPEG_CS_YUV /**< YUV444 packed */
38 };
39
40 /** JPEG color space. */
42 JPEG_CI_LIBJPEG, /**< Force usage of libjpeg for compression */
43 JPEG_CI_MMAL /**< Force usage of MMAL for compression */
44 };
45
46 explicit JpegImageCompressor(unsigned int quality = 80, JpegColorspace jcs = JPEG_CS_RGB);
48 unsigned int quality = 80,
50 virtual ~JpegImageCompressor();
51
52 virtual void
53 set_image_dimensions(unsigned int width, unsigned int height)
54 {
55 impl_->set_image_dimensions(width, height);
56 }
57 virtual void
58 set_image_buffer(colorspace_t cspace, unsigned char *buffer)
59 {
60 impl_->set_image_buffer(cspace, buffer);
61 }
62 virtual void
63 set_destination_buffer(unsigned char *buf, unsigned int buf_size)
64 {
65 impl_->set_destination_buffer(buf, buf_size);
66 }
67 virtual size_t
69 {
70 return impl_->compressed_size();
71 }
72 virtual void
73 set_filename(const char *filename)
74 {
75 impl_->set_filename(filename);
76 }
77 virtual void
79 {
81 }
82 virtual bool
84 {
85 return impl_->supports_compression_destination(cd);
86 }
87 virtual void
89 {
90 impl_->compress();
91 }
92 virtual size_t
94 {
96 }
97 virtual bool
99 {
100 return impl_->supports_vflip();
101 }
102 virtual void
103 set_vflip(bool enable)
104 {
105 impl_->set_vflip(enable);
106 }
107
108private:
109 ImageCompressor *impl_;
110};
111
112} // end namespace firevision
113
114#endif
Image compressor interface.
virtual void set_image_dimensions(unsigned int width, unsigned int height)=0
Set dimensions of image to compress.
virtual bool supports_compression_destination(CompressionDestination cd)=0
Check if compressor supports desired compression destination.
virtual void set_filename(const char *filename)=0
Set file name.
virtual void compress()=0
Compress image.
virtual void set_vflip(bool enable)=0
Enable or disable vflipping.
virtual size_t recommended_compressed_buffer_size()=0
Get the recommended size for the compressed buffer.
CompressionDestination
Where to put the compressed image.
virtual void set_destination_buffer(unsigned char *buf, unsigned int buf_size)=0
Set destination buffer (if compressing to memory).
virtual bool supports_vflip()=0
Check if image compressor can do vflip during compress.
virtual void set_image_buffer(colorspace_t cspace, unsigned char *buffer)=0
Set image buffer to compress.
virtual size_t compressed_size()=0
Get compressed size.
virtual void set_compression_destination(CompressionDestination cd)=0
Set compression destination.
Jpeg image compressor.
virtual void compress()
Compress image.
virtual size_t compressed_size()
Get compressed size.
virtual bool supports_vflip()
Check if image compressor can do vflip during compress.
JpegCompressorImplementation
JPEG color space.
@ JPEG_CI_LIBJPEG
Force usage of libjpeg for compression.
@ JPEG_CI_MMAL
Force usage of MMAL for compression.
JpegImageCompressor(unsigned int quality=80, JpegColorspace jcs=JPEG_CS_RGB)
Constructor.
virtual bool supports_compression_destination(ImageCompressor::CompressionDestination cd)
Check if compressor supports desired compression destination.
virtual size_t recommended_compressed_buffer_size()
Get the recommended size for the compressed buffer.
virtual ~JpegImageCompressor()
Destructor.
virtual void set_image_buffer(colorspace_t cspace, unsigned char *buffer)
Set image buffer to compress.
virtual void set_compression_destination(ImageCompressor::CompressionDestination cd)
Set compression destination.
virtual void set_destination_buffer(unsigned char *buf, unsigned int buf_size)
Set destination buffer (if compressing to memory).
virtual void set_vflip(bool enable)
Enable or disable vflipping.
virtual void set_image_dimensions(unsigned int width, unsigned int height)
Set dimensions of image to compress.
virtual void set_filename(const char *filename)
Set file name.