cvw::ImageView
Read-only, non-owning view over image pixel data. More...
#include <image_view.hpp>
Public Types
| Name | |
|---|---|
| using typename F::value_type | value_type Scalar element type derived from the pixel format. |
Public Functions
| Name | |
|---|---|
| ImageView() =default Default-constructs a null view. | |
| ImageView(constvalue_type * data, int width, int height, size_t stride) Constructs a view from a pointer and dimensions. | |
| int | width() const Returns the image width in pixels. |
| int | height() const Returns the image height in pixels. |
| constexprint | channels() const Returns the number of channels determined by the format. |
| size_t | stride() const Returns the row stride in elements. |
| bool | empty() const Checks whether the view references no data. |
| constvalue_type * | data() const Returns a const pointer to the beginning of pixel data. |
| constvalue_type & | at(int row, int col, int ch =0) const Accesses a specific pixel channel by coordinates. |
Detailed Description
template <is_pixel_format F>
class cvw::ImageView;Read-only, non-owning view over image pixel data.
Template Parameters:
- F Pixel format tag satisfying is_pixel_format.
Since: 1.0.0
Note: Not thread-safe unless externally synchronized.
Provides lightweight access to an external pixel buffer. Does not manage the underlying memory; the caller must ensure the buffer outlives the view.
cvw::Image<cvw::BGR> img(640, 480);
auto v = img.view();
int w = v.width();Public Types Documentation
using value_type
using cvw::ImageView<F>::value_type = typename F::value_type;Scalar element type derived from the pixel format.
Public Functions Documentation
function ImageView
ImageView() =defaultDefault-constructs a null view.
Since: 1.0.0
Data pointer is nullptr; all accessors return zero.
function ImageView
inline ImageView(
constvalue_type * data,
int width,
int height,
size_t stride
)Constructs a view from a pointer and dimensions.
Parameters:
- data Pointer to the first pixel element. Must be non-null if width * height > 0.
- width Image width in pixels.
- height Image height in pixels.
- stride Row stride in elements (not bytes).
Since: 1.0.0
function width
inline int width() constReturns the image width in pixels.
Return: Width in pixels.
Since: 1.0.0
function height
inline int height() constReturns the image height in pixels.
Return: Height in pixels.
Since: 1.0.0
function channels
inline constexprint channels() constReturns the number of channels determined by the format.
Return: Channel count (compile-time constant).
Since: 1.0.0
function stride
inline size_t stride() constReturns the row stride in elements.
Return: Stride in elements (not bytes).
Since: 1.0.0
function empty
inline bool empty() constChecks whether the view references no data.
Return: True if the data pointer is null.
Since: 1.0.0
function data
inline constvalue_type * data() constReturns a const pointer to the beginning of pixel data.
Return: Const pointer to the first element.
Since: 1.0.0
function at
inline constvalue_type & at(
int row,
int col,
int ch =0
) constAccesses a specific pixel channel by coordinates.
Parameters:
- row Row index. Unit: pixels. Valid range: [0, height).
- col Column index. Unit: pixels. Valid range: [0, width).
- ch Channel index. Default: 0.
Exceptions:
- None (no bounds checking).
Return: Const reference to the channel value.
Since: 1.0.0
Warning: Undefined behavior for out-of-range indices.
Updated on 2026-05-17 at 13:22:38 +0000