Skip to content

cvw::ImageView

Read-only, non-owning view over image pixel data. More...

#include <image_view.hpp>

Public Types

Name
using typename F::value_typevalue_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.
intwidth() const
Returns the image width in pixels.
intheight() const
Returns the image height in pixels.
constexprintchannels() const
Returns the number of channels determined by the format.
size_tstride() const
Returns the row stride in elements.
boolempty() 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

cpp
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.

cpp
cvw::Image<cvw::BGR> img(640, 480);
auto v = img.view();
int w = v.width();

Public Types Documentation

using value_type

cpp
using cvw::ImageView<F>::value_type =  typename F::value_type;

Scalar element type derived from the pixel format.

Public Functions Documentation

function ImageView

cpp
ImageView() =default

Default-constructs a null view.

Since: 1.0.0

Data pointer is nullptr; all accessors return zero.

function ImageView

cpp
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

cpp
inline int width() const

Returns the image width in pixels.

Return: Width in pixels.

Since: 1.0.0

function height

cpp
inline int height() const

Returns the image height in pixels.

Return: Height in pixels.

Since: 1.0.0

function channels

cpp
inline constexprint channels() const

Returns the number of channels determined by the format.

Return: Channel count (compile-time constant).

Since: 1.0.0

function stride

cpp
inline size_t stride() const

Returns the row stride in elements.

Return: Stride in elements (not bytes).

Since: 1.0.0

function empty

cpp
inline bool empty() const

Checks whether the view references no data.

Return: True if the data pointer is null.

Since: 1.0.0

function data

cpp
inline constvalue_type * data() const

Returns a const pointer to the beginning of pixel data.

Return: Const pointer to the first element.

Since: 1.0.0

function at

cpp
inline constvalue_type & at(
    int row,
    int col,
    int ch =0
) const

Accesses 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

Built with VitePress