VideoTools
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
grimageconverter.h
Go to the documentation of this file.
1 //
2 // Copyright (C) 2017 Graeme Walker
3 //
4 // This program is free software: you can redistribute it and/or modify
5 // it under the terms of the GNU General Public License as published by
6 // the Free Software Foundation, either version 3 of the License, or
7 // (at your option) any later version.
8 //
9 // This program is distributed in the hope that it will be useful,
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 // GNU General Public License for more details.
13 //
14 // You should have received a copy of the GNU General Public License
15 // along with this program. If not, see <http://www.gnu.org/licenses/>.
16 // ===
17 ///
18 /// \file grimageconverter.h
19 ///
20 
21 #ifndef GR_IMAGE_CONVERTER__H
22 #define GR_IMAGE_CONVERTER__H
23 
24 #include "gdef.h"
25 #include "grimage.h"
26 #include "grimagedata.h"
27 #include "grimagedecoder.h"
28 #include <vector>
29 #include <string>
30 
31 namespace Gr
32 {
33  class ImageConverter ;
34 }
35 
36 /// \class Gr::ImageConverter
37 /// An image format converter that can convert to and from the raw and jpeg
38 /// formats (only), with scaling and monochrome options.
39 ///
40 /// The implementation uses Gr::ImageDecoder for decoding, and Gr::JpegWriter
41 /// for encoding.
42 ///
44 {
45 public:
46  ImageConverter() ;
47  ///< Default constructor.
48 
49  bool toRaw( Image image_in , Image & image_out , int scale = 1 , bool monochrome_out = false ) ;
50  ///< Converts the image to raw format. Returns a false on error.
51 
52  bool toJpeg( Image image_in , Image & image_out , int scale = 1 , bool monochrome_out = false ) ;
53  ///< Converts the image to jpeg format. Returns false on error.
54 
55  static bool convertible( Gr::ImageType ) ;
56  ///< Returns true if the image type is convertible. In practice this
57  ///< returns true for jpeg and raw image types.
58 
59 private:
60  bool toRawImp( Image image_in , Image & image_out , int scale , bool monochrome_out ) ;
61  bool toJpegImp( Image image_in , Image & image_out , int scale , bool monochrome_out ) ;
62 
63 private:
64  ImageDecoder m_decoder ;
65  JpegWriter m_jpeg_writer ;
66  Image m_image_tmp ;
67 } ;
68 
69 #endif
ImageConverter()
Default constructor.
An encapsulation of image type, including width, height and number of channels, with support for a st...
Definition: grimagetype.h:43
bool toRaw(Image image_in, Image &image_out, int scale=1, bool monochrome_out=false)
Converts the image to raw format. Returns a false on error.
An interface for decoding encoded images into a raw format.
A class holding shared read-only image data (Gr::ImageBuffer) and its associated image type (Gr::Imag...
Definition: grimage.h:41
static bool convertible(Gr::ImageType)
Returns true if the image type is convertible.
bool toJpeg(Image image_in, Image &image_out, int scale=1, bool monochrome_out=false)
Converts the image to jpeg format. Returns false on error.
A write interface for libjpeg.
Definition: grjpeg.h:144
An image format converter that can convert to and from the raw and jpeg formats (only), with scaling and monochrome options.