Skip to content

cvw::ImageMutView

Mutable, 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
ImageMutView() =default
Default-constructs a null view.
ImageMutView(value_type * data, int width, int height, size_t stride)
Constructs a mutable 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.
value_type *data()
Returns a mutable pointer to pixel data.
constvalue_type *data() const
Returns a const pointer to pixel data.
value_type &at(int row, int col, int ch =0)
Accesses a specific pixel channel by coordinates.
ImageView<F>as_const_view() const
Converts this mutable view to a read-only ImageView.

Detailed Description

cpp
template <is_pixel_format F>
class cvw::ImageMutView;

Mutable, 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 read-write 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::Gray> img(640, 480);
auto mv = img.mutable_view();
mv.at(0, 0) = 128;

Public Types Documentation

using value_type

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

Scalar element type derived from the pixel format.

Public Functions Documentation

function ImageMutView

cpp
ImageMutView() =default

Default-constructs a null view.

Since: 1.0.0

function ImageMutView

cpp
inline ImageMutView(
    value_type * data,
    int width,
    int height,
    size_t stride
)

Constructs a mutable 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 value_type * data()

Returns a mutable pointer to pixel data.

Return: Mutable pointer to the first element.

Since: 1.0.0

function data

cpp
inline constvalue_type * data() const

Returns a const pointer to pixel data.

Return: Const pointer to the first element.

Since: 1.0.0

function at

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

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: Mutable reference to the channel value.

Since: 1.0.0

Warning: Undefined behavior for out-of-range indices.

function as_const_view

cpp
inline ImageView<F> as_const_view() const

Converts this mutable view to a read-only [ImageView.

Return: An ImageView referencing the same pixel buffer.

Since: 1.0.0


Updated on 2026-05-17 at 13:22:38 +0000

Built with VitePress