Thermal Camera SDK 10.0.1
SDK for Optris Thermal Cameras
Loading...
Searching...
No Matches
Image.h
Go to the documentation of this file.
1// Copyright (c) 2025 Optris GmbH Co. KG
2
10
11#pragma once
12
13#include <vector>
14
15#include "otcsdk/Api.h"
16#include "otcsdk/Exceptions.h"
17#include "otcsdk/common/Pixel.h"
20
21
22namespace optris
23{
24
37class Image
38{
39 // Special iterator access.
40 friend class ImageIterator;
41 friend class ConstImageIterator;
42
43
44public:
53 OTC_SDK_API Image(ColorFormat colorFormat, WidthAlignment widthAlignment) noexcept;
54
55
65 OTC_SDK_API Pixel getPixel(int index) const;
66
77 OTC_SDK_API Pixel getPixel(int x, int y) const;
78
87 OTC_SDK_API void setPixel(int index, const Pixel& pixel);
88
98 OTC_SDK_API void setPixel(int x, int y, const Pixel& pixel);
99
107 OTC_SDK_API ImageIterator getIterator() noexcept;
108
116 OTC_SDK_API ConstImageIterator getConstIterator() const noexcept;
117
123 OTC_SDK_API int getWidth() const noexcept;
124
132 OTC_SDK_API int getStride() const noexcept;
133
139 OTC_SDK_API int getHeight() const noexcept;
140
146 OTC_SDK_API int getSize() const noexcept;
147
155 OTC_SDK_API int getSizeInBytes() const noexcept;
156
162 OTC_SDK_API bool isEmpty() const noexcept;
163
166
173 OTC_SDK_API void resize(int width, int height);
174
180 OTC_SDK_API ColorFormat getColorFormat() const noexcept;
181
188
194 OTC_SDK_API Image clone() const noexcept;
195
209 OTC_SDK_API void copyDataTo(unsigned char* destination, int size) const noexcept;
210
220 OTC_SDK_API const unsigned char* getData() const noexcept;
221
222
223private:
224 ImageInfo _info;
225
226 std::vector<unsigned char> _pixelValues;
227};
228
229
230// Inline implementations
231inline ImageIterator Image::getIterator() noexcept
232{
233 return ImageIterator{*this};
234}
235
236inline ConstImageIterator Image::getConstIterator() const noexcept
237{
238 return ConstImageIterator{*this};
239}
240
241inline int Image::getWidth() const noexcept
242{
243 return _info.getWidth();
244}
245
246inline int Image::getStride() const noexcept
247{
248 return _info.getStride();
249}
250
251inline int Image::getHeight() const noexcept
252{
253 return _info.getHeight();
254}
255
256inline int Image::getSize() const noexcept
257{
258 return _info.getSize();
259}
260
261inline int Image::getSizeInBytes() const noexcept
262{
263 return static_cast<unsigned int>(_pixelValues.size());
264}
265
266inline bool Image::isEmpty() const noexcept
267{
268 return _pixelValues.empty();
269}
270
271inline ColorFormat Image::getColorFormat() const noexcept
272{
273 return _info.getColorFormat();
274}
275
277{
278 return _info.getWidthAlignment();
279}
280
281inline Image Image::clone() const noexcept
282{
283 return Image{*this};
284}
285
286inline const unsigned char* Image::getData() const noexcept
287{
288 return _pixelValues.data();
289}
290
291} // namespace optris
Contains defines controlling the Windows DLL export and import of symbols.
#define OTC_SDK_API
Only needed when working with Windows DLLs.
Definition Api.h:65
Contains the exceptions raised by the SDK.
Contains a class holding detail information about the properties of a false color image.
Contains class that realize the iteration over the pixels of false color images.
Contains a class encapsulating a pixel with three color channels and 8 bits of color depth.
Encapsulates all relevant information about a false color image.
Definition ImageInfo.h:57
OTC_SDK_API bool isEmpty() const noexcept
Returns whether the image is empty.
Definition Image.h:266
OTC_SDK_API Image clone() const noexcept
Returns a complete copy of this image.
Definition Image.h:281
OTC_SDK_API void copyDataTo(unsigned char *destination, int size) const noexcept
Copies the internally stored pixel values to the given array.
OTC_SDK_API int getStride() const noexcept
Returns the stride of the image in bytes.
Definition Image.h:246
OTC_SDK_API int getHeight() const noexcept
Returns the height of the image in pixels.
Definition Image.h:251
OTC_SDK_API Pixel getPixel(int x, int y) const
Returns the pixel at the given coordinates.
OTC_SDK_API ImageIterator getIterator() noexcept
Returns an iterator with read and write access.
Definition Image.h:231
OTC_SDK_API int getSizeInBytes() const noexcept
Returns the size of the internal storage in bytes.
Definition Image.h:261
OTC_SDK_API Pixel getPixel(int index) const
Returns the pixel at the given index.
OTC_SDK_API void clear()
Clears the image.
OTC_SDK_API Image(ColorFormat colorFormat, WidthAlignment widthAlignment) noexcept
Constructor.
OTC_SDK_API void setPixel(int x, int y, const Pixel &pixel)
Sets the pixel at the given coordinates.
OTC_SDK_API void resize(int width, int height)
Resizes the image to the given dimensions.
OTC_SDK_API WidthAlignment getWidthAlignment() const noexcept
Returns the width alignment.
Definition Image.h:276
OTC_SDK_API void setPixel(int index, const Pixel &pixel)
Sets the pixel at the given index.
OTC_SDK_API int getWidth() const noexcept
Returns the width of the image in pixels.
Definition Image.h:241
OTC_SDK_API int getSize() const noexcept
Returns the size of the image as total number of pixels.
Definition Image.h:256
OTC_SDK_API ConstImageIterator getConstIterator() const noexcept
Returns an iterator with read access.
Definition Image.h:236
OTC_SDK_API ColorFormat getColorFormat() const noexcept
Returns the color format.
Definition Image.h:271
OTC_SDK_API const unsigned char * getData() const noexcept
Returns a pointer to the first element of the internal array.
Definition Image.h:286
Represents a pixel with three color channels and 8 bits of color depth.
Definition Pixel.h:22
Main SDK namespace.
Definition DeviceInfo.h:23
ColorFormat
Represents the different available color formats.
Definition ImageInfo.h:32
WidthAlignment
Represents the different available width alignments.
Definition ImageInfo.h:47