Ignition Rendering

API Reference

0.1.0
Image.hh
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2015 Open Source Robotics Foundation
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 IGNITION_RENDERING_IMAGE_HH_
18 #define IGNITION_RENDERING_IMAGE_HH_
19 
20 #include <memory>
22 #include "ignition/rendering/Export.hh"
23 
24 namespace ignition
25 {
26  namespace rendering
27  {
30  class IGNITION_RENDERING_VISIBLE Image
31  {
34 
36  public: Image() = default;
37 
42  public: Image(unsigned int _width, unsigned int _height,
43  PixelFormat _format);
44 
46  public: ~Image();
47 
50  public: unsigned int Width() const;
51 
54  public: unsigned int Height() const;
55 
58  public: PixelFormat Format() const;
59 
62  public: unsigned int Depth() const;
63 
66  public: unsigned int MemorySize() const;
67 
70  public: const void *Data() const;
71 
74  public: void *Data();
75 
79  public: template <typename T>
80  const T *Data() const;
81 
85  public: template <typename T>
86  T *Data();
87 
89  private: unsigned int width = 0;
90 
92  private: unsigned int height = 0;
93 
95  private: PixelFormat format = PF_UNKNOWN;
96 
98  private: DataPtr data = nullptr;
99  };
100 
102  template <typename T>
103  const T *Image::Data() const
104  {
105  return static_cast<const T *>(this->data.get());
106  }
107 
109  template <typename T>
111  {
112  return static_cast<T *>(this->data.get());
113  }
114  }
115 }
116 #endif
Encapsulates a raw image buffer and relevant properties.
Definition: Image.hh:30
const void * Data() const
Get a const pointer to image data.
PixelFormat
Definition: PixelFormat.hh:29
< Unknown or errant type
Definition: PixelFormat.hh:32
Definition: ArrowVisual.hh:22