These are the pre-v12 classes, kept so existing code keeps building. New code should use the modern API — see Migration Guide: v11 to v12.
optris::Image
The individual pixel values, like red, green or blue, are stored in a one-dimensional array. Depending on the width alignment additional bytes may be added at the end of each row to ensure that its size in bytes respects this alignment. The setter and getter functions as well as the iterators will skip this padding. The origin of coordinates is located in the upper left corner with the x-axis pointing right and the y-axis pointing down.
Public functions
Image
OTC_SDK_API Image(ColorFormat colorFormat, WidthAlignment widthAlignment) noexcept
Constructor.
Parameters
| Name | Description |
|---|---|
colorFormat |
defines the sequence in which the pixel values are stored internally. |
widthAlignment |
defines the alignment of the row size in bytes. If, e.g., it is set to four bytes, the row size will potentially be padded at the end so that it is a multiple of four. |
getPixel
OTC_SDK_API Pixel getPixel(int index) const
Returns the pixel at the given index.
Parameters
| Name | Description |
|---|---|
index |
of the desired pixel. |
Returns: the pixel at the given index.
Exceptions
| Name | Description |
|---|---|
SDKException |
if the index is out of bounds. |
getPixel
OTC_SDK_API Pixel getPixel(int x, int y) const
Returns the pixel at the given coordinates.
Parameters
| Name | Description |
|---|---|
x |
coordinate. |
y |
coordinate. |
Returns: the pixel at the given coordinates.
Exceptions
| Name | Description |
|---|---|
SDKException |
if the coordinates are out of bounds. |
setPixel
OTC_SDK_API void setPixel(int index, const Pixel &pixel)
Sets the pixel at the given index.
Parameters
| Name | Description |
|---|---|
index |
of the pixel to set. |
pixel |
to set. |
Exceptions
| Name | Description |
|---|---|
SDKException |
if the index is out of bounds. |
setPixel
OTC_SDK_API void setPixel(int x, int y, const Pixel &pixel)
Sets the pixel at the given coordinates.
Parameters
| Name | Description |
|---|---|
x |
coordinate. |
y |
coordinate. |
pixel |
to set. |
Exceptions
| Name | Description |
|---|---|
SDKException |
if the coordinates are out of bounds. |
getWidth
OTC_SDK_API int getWidth() const noexcept
Returns the width of the image in pixels.
Returns: image width in pixels.
getStride
OTC_SDK_API int getStride() const noexcept
Returns the stride of the image in bytes. The stride is the image width in bytes including potential padding.
Returns: stride of the image in bytes.
getHeight
OTC_SDK_API int getHeight() const noexcept
Returns the height of the image in pixels.
Returns: image height in pixels.
getSize
OTC_SDK_API int getSize() const noexcept
Returns the size of the image as total number of pixels.
Returns: size of the image as total number of pixels.
getSizeInBytes
OTC_SDK_API int getSizeInBytes() const noexcept
Returns the size of the internal storage in bytes. This includes potential width padding.
Returns: size of the internal storage in bytes.
isEmpty
OTC_SDK_API bool isEmpty() const noexcept
Returns whether the image is empty.
Returns: true if the image is empty. False otherwise.
clear
OTC_SDK_API void clear()
Clears the image.
resize
OTC_SDK_API void resize(int width, int height)
Resizes the image to the given dimensions.
Parameters
| Name | Description |
|---|---|
width |
in pixels. |
height |
in pixels. |
getColorFormat
OTC_SDK_API ColorFormat getColorFormat() const noexcept
Returns the color format.
Returns: color format.
getWidthAlignment
OTC_SDK_API WidthAlignment getWidthAlignment() const noexcept
Returns the width alignment.
Returns: width alignment.
copyDataTo
OTC_SDK_API void copyDataTo(unsigned char *destination, int size) const noexcept
Copies the internally stored pixel values to the given array. This includes potential width padding.
Warning: No range checks are performed. The correct size of the destination array can be acquired with the getSizeInBytes() function.
Parameters
| Name | Description |
|---|---|
destination |
array to copy the data to. |
size |
in bytes. The specified size is limited to [0, frame size in bytes]. |
See also: getSizeInBytes()
getData
OTC_SDK_API const unsigned char * getData() const noexcept
Returns a pointer to the first element of the internal array. The size of the array can be acquired via the getSizeInBytes() function.
Returns: pointer to the first element of the internal array.
See also: getSizeInBytes()
getData
OTC_SDK_API unsigned char * getData() noexcept
Returns a pointer to the first element of the internal array. The size of the array can be acquired via the getSizeInBytes() function.
Returns: pointer to the first element of the internal array.
See also: getSizeInBytes()