Fawkes API  Fawkes Development Version
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
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  JpegImageCompressor(unsigned int quality = 80, JpegColorspace jcs = JPEG_CS_RGB);
44  virtual ~JpegImageCompressor();
45 
46  virtual void set_image_dimensions(unsigned int width, unsigned int height);
47  virtual void set_image_buffer(colorspace_t cspace, unsigned char *buffer);
48  virtual void set_destination_buffer(unsigned char *buf, unsigned int buf_size);
49  virtual size_t compressed_size();
50  virtual void set_filename(const char *filename);
51  virtual void set_compression_destination(ImageCompressor::CompressionDestination cd);
52  virtual bool supports_compression_destination(ImageCompressor::CompressionDestination cd);
53  virtual void compress();
54  virtual size_t recommended_compressed_buffer_size();
55 
56  private:
57  unsigned char *jpeg_buffer;
58  unsigned int jpeg_buffer_size;
59  unsigned char *buffer;
60 
61  unsigned int quality;
62 
63  unsigned int width;
64  unsigned int height;
65 
66  unsigned int jpeg_bytes;
67 
68  const char *filename;
69 
70  JpegColorspace jpeg_cs;
71  CompressionDestination compdest;
72 };
73 
74 } // end namespace firevision
75 
76 #endif