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 
29 namespace firevision {
30 #if 0 /* just to make Emacs auto-indent happy */
31 }
32 #endif
33 
35  public:
36 
37  /** JPEG color space. */
39  JPEG_CS_RGB, /**< RGB */
40  JPEG_CS_YUV /**< YUV444 packed */
41  };
42 
43  /** JPEG color space. */
45  JPEG_CI_LIBJPEG, /**< Force usage of libjpeg for compression */
46  JPEG_CI_MMAL /**< Force usage of MMAL for compression */
47  };
48 
49  explicit JpegImageCompressor(unsigned int quality = 80, JpegColorspace jcs = JPEG_CS_RGB);
51  unsigned int quality = 80, JpegColorspace jcs = JPEG_CS_RGB);
52  virtual ~JpegImageCompressor();
53 
54  virtual void set_image_dimensions(unsigned int width, unsigned int height)
55  { impl_->set_image_dimensions(width, height); }
56  virtual void set_image_buffer(colorspace_t cspace, unsigned char *buffer)
57  { impl_->set_image_buffer(cspace, buffer); }
58  virtual void set_destination_buffer(unsigned char *buf, unsigned int buf_size)
59  { impl_->set_destination_buffer(buf, buf_size); }
60  virtual size_t compressed_size()
61  { return impl_->compressed_size(); }
62  virtual void set_filename(const char *filename)
63  { impl_->set_filename(filename); }
65  { impl_->set_compression_destination(cd); }
67  { return impl_->supports_compression_destination(cd); }
68  virtual void compress()
69  { impl_->compress(); }
71  { return impl_->recommended_compressed_buffer_size(); }
72  virtual bool supports_vflip()
73  { return impl_->supports_vflip(); }
74  virtual void set_vflip(bool enable)
75  { impl_->set_vflip(enable); }
76 
77  private:
78  ImageCompressor *impl_;
79 };
80 
81 } // end namespace firevision
82 
83 #endif
virtual bool supports_vflip()=0
Check if image compressor can do vflip during compress.
Force usage of libjpeg for compression.
virtual void set_vflip(bool enable)=0
Enable or disable vflipping.
Force usage of MMAL for compression.
virtual void set_compression_destination(ImageCompressor::CompressionDestination cd)
Set compression destination.
virtual void set_image_dimensions(unsigned int width, unsigned int height)=0
Set dimensions of image to compress.
virtual void set_destination_buffer(unsigned char *buf, unsigned int buf_size)=0
Set destination buffer (if compressing to memory).
virtual size_t compressed_size()
Get compressed size.
JpegCompressorImplementation
JPEG color space.
virtual void compress()
Compress image.
CompressionDestination
Where to put the compressed image.
virtual bool supports_compression_destination(CompressionDestination cd)=0
Check if compressor supports desired compression destination.
Jpeg image compressor.
virtual void set_image_buffer(colorspace_t cspace, unsigned char *buffer)
Set image buffer to compress.
virtual void set_compression_destination(CompressionDestination cd)=0
Set compression destination.
virtual void set_filename(const char *filename)
Set file name.
JpegImageCompressor(unsigned int quality=80, JpegColorspace jcs=JPEG_CS_RGB)
Constructor.
virtual size_t recommended_compressed_buffer_size()=0
Get the recommended size for the compressed buffer.
virtual void set_filename(const char *filename)=0
Set file name.
virtual void set_image_dimensions(unsigned int width, unsigned int height)
Set dimensions of image to compress.
virtual void set_destination_buffer(unsigned char *buf, unsigned int buf_size)
Set destination buffer (if compressing to memory).
virtual bool supports_vflip()
Check if image compressor can do vflip during compress.
virtual void set_vflip(bool enable)
Enable or disable vflipping.
virtual ~JpegImageCompressor()
Destructor.
Image compressor interface.
virtual size_t recommended_compressed_buffer_size()
Get the recommended size for the compressed buffer.
virtual bool supports_compression_destination(ImageCompressor::CompressionDestination cd)
Check if compressor supports desired compression destination.
virtual size_t compressed_size()=0
Get compressed size.
virtual void compress()=0
Compress image.
virtual void set_image_buffer(colorspace_t cspace, unsigned char *buffer)=0
Set image buffer to compress.