stromx  0.8.0
ImageWrapper.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_IMAGEWRAPPER_H
18 #define STROMX_RUNTIME_IMAGEWRAPPER_H
19 
20 #include "stromx/runtime/Image.h"
21 
22 namespace stromx
23 {
24  namespace runtime
25  {
27  class STROMX_RUNTIME_API ImageWrapper : public Image
28  {
29  public:
34  ImageWrapper(const unsigned int bufferSize, uint8_t* const buffer);
35 
40  ImageWrapper();
41 
42  // Implementation of stromx::runtime::Matrix
43  virtual const VariantHandle & variant() const { return m_variant; }
44  virtual uint8_t* buffer() { return m_buffer; }
45  virtual unsigned int bufferSize() const { return m_bufferSize; };
46  virtual unsigned int rows() const { return m_height; }
47  virtual unsigned int cols() const { return m_cols; }
48  virtual uint8_t* data() { return m_data; }
49  virtual const uint8_t* data() const { return m_data; }
50  virtual unsigned int stride() const { return m_stride; }
51  virtual ValueType valueType() const { return m_valueType; }
52  virtual unsigned int valueSize() const;
53  virtual void initializeMatrix(const unsigned int rows,
54  const unsigned int cols,
55  const unsigned int stride,
56  uint8_t* data,
57  const ValueType valueType);
58 
59  // Implementation of stromx::runtime::Image
60  virtual unsigned int width() const { return m_width; }
61  virtual unsigned int height() const { return m_height; }
62  virtual PixelType pixelType() const { return m_pixelType; }
63  virtual void initializeImage(const unsigned int width,
64  const unsigned int height,
65  const unsigned int stride,
66  uint8_t* data,
67  const PixelType pixelType);
68 
70  void resize(const unsigned int width, const unsigned int height, const PixelType pixelType);
71 
77  void resize(const unsigned int size);
78 
79  protected:
88  void setBuffer(uint8_t* const buffer, const unsigned int bufferSize);
89 
97  virtual void allocate(const unsigned int width, const unsigned int height,
98  const Image::PixelType pixelType) = 0;
99 
100 
101  private:
102  void validate(const unsigned int width,
103  const unsigned int height,
104  const unsigned int stride,
105  const uint8_t* data,
106  const PixelType pixelType) const;
107 
108 
109  unsigned int m_width;
110  unsigned int m_height;
111  unsigned int m_cols;
112  unsigned int m_stride;
113  unsigned int m_bufferSize;
114  PixelType m_pixelType;
115  ValueType m_valueType;
116  uint8_t* m_data;
117  uint8_t* m_buffer;
118  VariantHandle m_variant;
119  };
120  }
121 }
122 
123 #endif // STROMX_RUNTIME_IMAGEWRAPPER_H
Concrete image without memory management.
Definition: ImageWrapper.h:27
Definition: VariantHandle.h:34
virtual const uint8_t * data() const
Definition: ImageWrapper.h:49
virtual const VariantHandle & variant() const
Definition: ImageWrapper.h:43
virtual unsigned int width() const
Definition: ImageWrapper.h:60
virtual PixelType pixelType() const
Definition: ImageWrapper.h:62
virtual uint8_t * data()
Definition: ImageWrapper.h:48
virtual unsigned int bufferSize() const
Definition: ImageWrapper.h:45
The stromx class library.
Definition: AdjustRgbChannels.cpp:29
virtual unsigned int cols() const
Definition: ImageWrapper.h:47
virtual uint8_t * buffer()
Definition: ImageWrapper.h:44
Abstract image.
Definition: Image.h:28
virtual unsigned int stride() const
Definition: ImageWrapper.h:50
virtual unsigned int height() const
Definition: ImageWrapper.h:61
virtual unsigned int rows() const
Definition: ImageWrapper.h:46
virtual ValueType valueType() const
Definition: ImageWrapper.h:51