stromx  0.8.0
Image.h
1 /*
2  * Copyright 2011 Matthias Fuchs
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 #ifndef STROMX_RUNTIME_IMAGE_H
18 #define STROMX_RUNTIME_IMAGE_H
19 
20 #include <stdint.h>
21 #include "stromx/runtime/Matrix.h"
22 
23 namespace stromx
24 {
25  namespace runtime
26  {
28  class STROMX_RUNTIME_API Image : public Matrix
29  {
30  public:
31  enum PixelType
32  {
33  NONE,
34  MONO_8,
35  MONO_16,
36  RGB_24,
37  RGB_48,
38  BGR_24,
39  BGR_48,
40  BAYERBG_8,
41  BAYERBG_16,
42  BAYERGB_8,
43  BAYERGB_16
44  };
45 
46  virtual ~Image() {}
47 
49  virtual unsigned int width() const = 0;
50 
52  virtual unsigned int height() const = 0;
53 
55  virtual unsigned int stride() const = 0;
56 
58  virtual PixelType pixelType() const = 0;
59 
61  virtual unsigned int pixelSize() const;
62 
64  virtual unsigned int numChannels() const;
65 
67  virtual unsigned int depth() const;
68 
74  virtual void initializeImage(const unsigned int width,
75  const unsigned int height,
76  const unsigned int stride,
77  uint8_t* data,
78  const PixelType pixelType) = 0;
79 
81  static unsigned int pixelSize(const PixelType pixelType);
82 
84  static unsigned int numChannels(const PixelType pixelType);
85 
87  static unsigned depth(const PixelType pixelType);
88 
89  protected:
91  static const runtime::VariantHandle dataVariantFromPixelType(const PixelType pixelType);
92 
94  static Matrix::ValueType valueTypeFromPixelType(const PixelType pixelType);
95  };
96 
98  template <>
99  class STROMX_RUNTIME_API data_traits<Image>
100  {
101  public:
102  static const VariantHandle & variant();
103  };
105  }
106 }
107 
108 #endif // STROMX_RUNTIME_IMAGE_H
Definition: VariantHandle.h:34
The stromx class library.
Definition: AdjustRgbChannels.cpp:29
Abstract image.
Definition: Matrix.h:28
Abstract image.
Definition: Image.h:28