Gazebo Rendering

API Reference

6.7.0
gz/rendering/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 GZ_RENDERING_IMAGE_HH_
18 #define GZ_RENDERING_IMAGE_HH_
19 
20 #include <memory>
21 
22 #include <gz/common/SuppressWarning.hh>
23 
24 #include "gz/rendering/config.hh"
26 #include "gz/rendering/Export.hh"
27 
28 namespace ignition
29 {
30  namespace rendering
31  {
32  inline namespace IGNITION_RENDERING_VERSION_NAMESPACE {
33  //
34  class Camera;
35  class PixelBuffer;
36 
39  class IGNITION_RENDERING_VISIBLE Image
40  {
43 
45  public: Image() = default;
46 
51  public: Image(unsigned int _width, unsigned int _height,
52  PixelFormat _format);
53 
55  public: ~Image();
56 
59  public: unsigned int Width() const;
60 
63  public: unsigned int Height() const;
64 
67  public: PixelFormat Format() const;
68 
71  public: unsigned int Depth() const;
72 
75  public: unsigned int MemorySize() const;
76 
79  public: const void *Data() const;
80 
83  public: void *Data();
84 
88  public: template <typename T>
89  const T *Data() const;
90 
94  public: template <typename T>
95  T *Data();
96 
103  private: explicit Image(const PixelBuffer &_buffer);
104 
106  private: friend class Camera;
107 
109  private: unsigned int width = 0;
110 
112  private: unsigned int height = 0;
113 
115  private: PixelFormat format = PF_UNKNOWN;
116 
119  private: DataPtr data = nullptr;
121  };
122 
124  template <typename T>
125  const T *Image::Data() const
126  {
127  return static_cast<const T *>(this->data.get());
128  }
129 
131  template <typename T>
133  {
134  return static_cast<T *>(this->data.get());
135  }
136  }
137  }
138 }
139 #endif
Posable camera used for rendering the scene graph.
Definition: gz/rendering/Camera.hh:52
Encapsulates a raw image buffer and relevant properties.
Definition: gz/rendering/Image.hh:40
Image()=default
Default constructor.
unsigned int MemorySize() const
Get image channel depth.
unsigned int Width() const
Get image width in pixels.
void * Data()
Get a pointer to image data.
unsigned int Depth() const
Get image channel depth.
unsigned int Height() const
Get image height in pixels.
const void * Data() const
Get a const pointer to image data.
PixelFormat Format() const
Get image pixel format.
Image(unsigned int _width, unsigned int _height, PixelFormat _format)
Constructor.
Non owning, writable view of a caller owned pixel buffer.
Definition: gz/rendering/PixelBuffer.hh:49
#define IGN_COMMON_WARN_IGNORE__DLL_INTERFACE_MISSING
#define IGN_COMMON_WARN_RESUME__DLL_INTERFACE_MISSING
PixelFormat
Image pixel format types.
Definition: gz/rendering/PixelFormat.hh:33
@ PF_UNKNOWN
< Unknown or errant type
Definition: gz/rendering/PixelFormat.hh:35