CVB++ 15.0
image_buffer_description.hpp
1#pragma once
2
3#include "../_cexports/c_gev_server.h"
4#include "../global.hpp"
5#include "../point_2d.hpp"
6#include "../size_2d.hpp"
7#include "../pfnc_format.hpp"
8
9namespace Cvb
10{
11 CVB_BEGIN_INLINE_NS
12 namespace GevServer
13 {
23 class ImageBufferDescription
24 {
25 friend class Stream;
26 friend class ChunkImageBufferDescription;
27
28 public:
29 ImageBufferDescription(const ImageBufferDescription &other) noexcept = default;
30 ImageBufferDescription &operator=(const ImageBufferDescription &other) noexcept = default;
31 ImageBufferDescription(ImageBufferDescription &&other) noexcept = default;
32 ImageBufferDescription &operator=(ImageBufferDescription &&other) noexcept = default;
33 virtual ~ImageBufferDescription() = default;
34
46 : ImageBufferDescription(size, PfncFormatValue::From(colorModel, dataType))
47 {
48 }
49
56 {
57 if (size.Width() < 1)
58 throw std::runtime_error("Width must be larger or equal to 1");
59 if (size.Height() < 1)
60 throw std::runtime_error("Height must be larger or equal to 1");
61 if (pixelFormat == PfncFormat::InvalidPixelFormat)
62 throw std::runtime_error("Invalid pixel format");
63
64 data_ = CExports::GSImageDataBlock{{CExports::TGSPayloadType::GSPT_Image},
65 static_cast<CExports::cvbuint32_t>(pixelFormat),
66 static_cast<CExports::cvbuint32_t>(size.Width()),
67 static_cast<CExports::cvbuint32_t>(size.Height()),
68 0,
69 0,
70 0,
71 0,
72 0};
73 }
74
76 PfncFormat PixelFormat() const noexcept
77 {
78 return static_cast<PfncFormat>(data_.PixelFormat);
79 }
80
82 void SetPixelFormat(const PfncFormat &pixelFormat)
83 {
84 if (pixelFormat == PfncFormat::InvalidPixelFormat)
85 throw std::runtime_error("Invalid pixel format");
86
87 data_.PixelFormat = static_cast<CExports::cvbuint32_t>(pixelFormat);
88 }
89
91 Size2D<int> Size() const noexcept
92 {
93 return Size2D<int>(static_cast<int>(data_.Width), static_cast<int>(data_.Height));
94 }
95
97 void SetSize(const Size2D<int> &size)
98 {
99 if (size.Width() < 1)
100 throw std::runtime_error("Width must be larger or equal to 1");
101 if (size.Height() < 1)
102 throw std::runtime_error("Height must be larger or equal to 1");
103
104 data_.Width = static_cast<CExports::cvbuint32_t>(size.Width());
105 data_.Height = static_cast<CExports::cvbuint32_t>(size.Height());
106 }
107
113 Point2D<int> Offset() const noexcept
114 {
115 return Point2D<int>(static_cast<int>(data_.XOffset), static_cast<int>(data_.YOffset));
116 }
117
124 {
125 if (point.X() < 0)
126 throw std::runtime_error("X must be larger or equal to 0");
127 if (point.Y() < 0)
128 throw std::runtime_error("Y must be larger or equal to 0");
129
130 data_.XOffset = static_cast<CExports::cvbuint32_t>(point.X());
131 data_.YOffset = static_cast<CExports::cvbuint32_t>(point.Y());
132 }
133
144 int LinePadding() const noexcept
145 {
146 return static_cast<int>(data_.XPadding);
147 }
148
159 void SetLinePadding(int padding)
160 {
161 data_.XPadding = static_cast<CExports::cvbuint32_t>(padding);
162 }
163
164 private:
166 CExports::GSImageDataBlock ImageDataBlock() const noexcept
167 {
168 return data_;
169 }
170
171 CExports::GSImageDataBlock data_ = {0};
172 };
173 } // namespace GevServer
174 CVB_END_INLINE_NS
175} // namespace Cvb
Data type description for an image plane.
Definition data_type.hpp:23
int LinePadding() const noexcept
Gets the line padding.
Definition image_buffer_description.hpp:144
void SetLinePadding(int padding)
Sets the line padding.
Definition image_buffer_description.hpp:159
PfncFormat PixelFormat() const noexcept
Gets the image pixel format value.
Definition image_buffer_description.hpp:76
void SetPixelFormat(const PfncFormat &pixelFormat)
Sets the image pixel format value.
Definition image_buffer_description.hpp:82
void SetOffset(Point2D< int > point)
Set the image's offset on the sensor.
Definition image_buffer_description.hpp:123
void SetSize(const Size2D< int > &size)
Sets the image size.
Definition image_buffer_description.hpp:97
ImageBufferDescription(Size2D< int > size, ColorModel colorModel, DataType dataType)
Creates a default image buffer description.
Definition image_buffer_description.hpp:45
Size2D< int > Size() const noexcept
Gets the image size.
Definition image_buffer_description.hpp:91
ImageBufferDescription(Size2D< int > size, PfncFormat pixelFormat)
Creates a default image buffer description.
Definition image_buffer_description.hpp:55
Point2D< int > Offset() const noexcept
Get the image's offset on the sensor.
Definition image_buffer_description.hpp:113
Helper methods for PfncFormat values. ///.
Definition pfnc_format.hpp:1005
Multi-purpose 2D vector class.
Definition point_2d.hpp:20
T X() const noexcept
Gets the x-component of the point.
Definition point_2d.hpp:84
T Y() const noexcept
Gets the y-component of the point.
Definition point_2d.hpp:104
Stores a pair of numbers that represents the width and the height of a subject, typically a rectangle...
Definition size_2d.hpp:20
T Height() const noexcept
Gets the vertical component of the size.
Definition size_2d.hpp:77
T Width() const noexcept
Gets the horizontal component of the size.
Definition size_2d.hpp:57
Describes a GenICam Pixel Format Naming Convention (PFNC) compatible image memory buffer with possibl...
Definition decl_int_swiss_knife_node.hpp:11
PfncFormat
GenICam Pixel Format Naming Convention (PFNC) format values.
Definition pfnc_format.hpp:21
Root namespace for the Image Manager interface.
Definition c_bayer_to_rgb.h:17
ColorModel
Color model that this image is using.
Definition global.hpp:176