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{
11CVB_BEGIN_INLINE_NS
12namespace GevServer
13{
24{
25 friend class Stream;
26 friend class ChunkImageBufferDescription;
27
28public:
29
30 ImageBufferDescription(const ImageBufferDescription& other) noexcept = default;
31 ImageBufferDescription& operator=(const ImageBufferDescription& other) noexcept = default;
32 ImageBufferDescription(ImageBufferDescription&& other) noexcept = default;
33 ImageBufferDescription& operator=(ImageBufferDescription&& other) noexcept = default;
34 virtual ~ImageBufferDescription() = default;
35
47 : ImageBufferDescription(size, PfncFormatValue::From(colorModel, dataType))
48 {
49 }
50
57 {
58 if (size.Width() < 1)
59 throw std::runtime_error("Width must be larger or equal to 1");
60 if (size.Height() < 1)
61 throw std::runtime_error("Height must be larger or equal to 1");
62 if (pixelFormat == PfncFormat::InvalidPixelFormat)
63 throw std::runtime_error("Invalid pixel format");
64
65 data_ = CExports::GSImageDataBlock{{CExports::TGSPayloadType::GSPT_Image},
66 static_cast<CExports::cvbuint32_t>(pixelFormat),
67 static_cast<CExports::cvbuint32_t>(size.Width()),
68 static_cast<CExports::cvbuint32_t>(size.Height()),
69 0,
70 0,
71 0,
72 0,
73 0};
74 }
75
77 PfncFormat PixelFormat() const noexcept { return static_cast<PfncFormat>(data_.PixelFormat); }
78
80 void SetPixelFormat(const PfncFormat &pixelFormat)
81 {
82 if (pixelFormat == PfncFormat::InvalidPixelFormat)
83 throw std::runtime_error("Invalid pixel format");
84
85 data_.PixelFormat = static_cast<CExports::cvbuint32_t>(pixelFormat);
86 }
87
89 Size2D<int> Size() const noexcept
90 {
91 return Size2D<int>(static_cast<int>(data_.Width), static_cast<int>(data_.Height));
92 }
93
95 void SetSize(const Size2D<int> &size)
96 {
97 if (size.Width() < 1)
98 throw std::runtime_error("Width must be larger or equal to 1");
99 if (size.Height() < 1)
100 throw std::runtime_error("Height must be larger or equal to 1");
101
102 data_.Width = static_cast<CExports::cvbuint32_t>(size.Width());
103 data_.Height = static_cast<CExports::cvbuint32_t>(size.Height());
104 }
105
111 Point2D<int> Offset() const noexcept
112 {
113 return Point2D<int>(static_cast<int>(data_.XOffset), static_cast<int>(data_.YOffset));
114 }
115
122 {
123 if (point.X() < 0)
124 throw std::runtime_error("X must be larger or equal to 0");
125 if (point.Y() < 0)
126 throw std::runtime_error("Y must be larger or equal to 0");
127
128 data_.XOffset = static_cast<CExports::cvbuint32_t>(point.X());
129 data_.YOffset = static_cast<CExports::cvbuint32_t>(point.Y());
130 }
131
142 int LinePadding() const noexcept { return static_cast<int>(data_.XPadding); }
143
154 void SetLinePadding(int padding) { data_.XPadding = static_cast<CExports::cvbuint32_t>(padding); }
155
156private:
158 CExports::GSImageDataBlock ImageDataBlock() const noexcept { return data_; }
159
160 CExports::GSImageDataBlock data_ = { 0 };
161};
162}
163CVB_END_INLINE_NS
164}
Data type description for an image plane.
Definition: data_type.hpp:28
Describes a GenICam Pixel Format Naming Convention (PFNC) compatible image memory buffer with possibl...
Definition: chunk_image_buffer_description.hpp:30
Describes a GenICam Pixel Format Naming Convention (PFNC) compatible image memory buffer.
Definition: image_buffer_description.hpp:24
int LinePadding() const noexcept
Gets the line padding.
Definition: image_buffer_description.hpp:142
void SetLinePadding(int padding)
Sets the line padding.
Definition: image_buffer_description.hpp:154
PfncFormat PixelFormat() const noexcept
Gets the image pixel format value.
Definition: image_buffer_description.hpp:77
void SetPixelFormat(const PfncFormat &pixelFormat)
Sets the image pixel format value.
Definition: image_buffer_description.hpp:80
void SetOffset(Point2D< int > point)
Set the image's offset on the sensor.
Definition: image_buffer_description.hpp:121
void SetSize(const Size2D< int > &size)
Sets the image size.
Definition: image_buffer_description.hpp:95
ImageBufferDescription(Size2D< int > size, ColorModel colorModel, DataType dataType)
Creates a default image buffer description.
Definition: image_buffer_description.hpp:46
Size2D< int > Size() const noexcept
Gets the image size.
Definition: image_buffer_description.hpp:89
ImageBufferDescription(Size2D< int > size, PfncFormat pixelFormat)
Creates a default image buffer description.
Definition: image_buffer_description.hpp:56
Point2D< int > Offset() const noexcept
Get the image's offset on the sensor.
Definition: image_buffer_description.hpp:111
The stream to send Images or other data.
Definition: decl_stream.hpp:19
Helper methods for PfncFormat values. ///
Definition: pfnc_format.hpp:1005
T X() const noexcept
Gets the x-component of the point.
Definition: point_2d.hpp:86
T Y() const noexcept
Gets the y-component of the point.
Definition: point_2d.hpp:106
T Height() const noexcept
Gets the vertical component of the size.
Definition: size_2d.hpp:79
T Width() const noexcept
Gets the horizontal component of the size.
Definition: size_2d.hpp:59
PfncFormat
GenICam Pixel Format Naming Convention (PFNC) format values.
Definition: pfnc_format.hpp:21
Root namespace for the Image Manager interface.
Definition: c_barcode.h:24
ColorModel
Color model that this image is using.
Definition: global.hpp:157