Gazebo Rendering

API Reference

6.6.3
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  //
36  class IGNITION_RENDERING_VISIBLE Image
37  {
40 
42  public: Image() = default;
43 
48  public: Image(unsigned int _width, unsigned int _height,
49  PixelFormat _format);
50 
52  public: ~Image();
53 
56  public: unsigned int Width() const;
57 
60  public: unsigned int Height() const;
61 
64  public: PixelFormat Format() const;
65 
68  public: unsigned int Depth() const;
69 
72  public: unsigned int MemorySize() const;
73 
76  public: const void *Data() const;
77 
80  public: void *Data();
81 
85  public: template <typename T>
86  const T *Data() const;
87 
91  public: template <typename T>
92  T *Data();
93 
95  private: unsigned int width = 0;
96 
98  private: unsigned int height = 0;
99 
101  private: PixelFormat format = PF_UNKNOWN;
102 
105  private: DataPtr data = nullptr;
107  };
108 
110  template <typename T>
111  const T *Image::Data() const
112  {
113  return static_cast<const T *>(this->data.get());
114  }
115 
117  template <typename T>
119  {
120  return static_cast<T *>(this->data.get());
121  }
122  }
123  }
124 }
125 #endif
#define IGN_COMMON_WARN_IGNORE__DLL_INTERFACE_MISSING
PixelFormat
Image pixel format types.
Definition: gz/rendering/PixelFormat.hh:32
T get(T... args)
Encapsulates a raw image buffer and relevant properties.
Definition: gz/rendering/Image.hh:36
unsigned int Height() const
Get image height in pixels.
const void * Data() const
Get a const pointer to image data.
unsigned int Width() const
Get image width in pixels.
unsigned int MemorySize() const
Get image channel depth.
Image()=default
Default constructor.
PixelFormat Format() const
Get image pixel format.
@ PF_UNKNOWN
< Unknown or errant type
Definition: gz/rendering/PixelFormat.hh:35
#define IGN_COMMON_WARN_RESUME__DLL_INTERFACE_MISSING
unsigned int Depth() const
Get image channel depth.