template<typename T = float, size_t Channels = 4>
spice::image class

Represents an image.

Template parameters
T
Channels

Public types

using value_type = T
Alias for the type used to represent individual pixel values.

Public static variables

static const T min constexpr
The value representing no emission or occlusion for this image type (i.e. "black")
static const T max constexpr
The value representing the maximum renderable emission or occlusion for this image type (i.e. "white")

Constructors, destructors, conversion operators

image()
Default-construct a new image object.
image(image const& other)
Copy-construct a new image object.
image(image&& other)
Move an image object.
image(size_t width, size_t height)
Construct a new image object with the given width and height, initialising all values with T{}
image(T const*const data, size_t width, size_t height)
Construct a new image object with the given width and height and initialise it with the provided data.

Public functions

auto data() -> T*const noexcept
Get direct access to the underlying data.
auto data() const -> T const *const noexcept
Get direct access to the underlying data.
auto width() const -> size_t
Get the width of the image.
auto height() const -> size_t
Get the height of the image.
auto channels() const -> size_t constexpr
Get the number of channels in the image.
auto size() const -> size_t constexpr
Get the size of the data array containing the image.
auto operator[](size_t offset) -> T&
Get a reference to the sample at the specified offset.
auto operator[](size_t offset) const -> T const &
Get a constant reference to the sample at the specified offset.
auto operator()(int x, int y) -> color_view<T>
Get pixel value at specified coordinates.
auto operator()(int x, int y) const -> color_view<T const > const
Get pixel value at specified coordinates.
auto operator()(int x, int y, int c) -> T&
Get reference to scalar value at specified coordinates.
auto operator()(int x, int y, int c) const -> T const &
Get reference to scalar value at specified coordinates.
auto operator+=(image const& rhs) -> image&
Add rhs element-wise to this image.
auto operator+=(T const& rhs) -> image&
Add rhs element-wise to this image.
auto operator-=(image const& rhs) -> image&
Subtract rhs element-wise from this image.
auto operator-=(T const& rhs) -> image&
Subtract rhs element-wise from this image.
auto operator*=(image const& rhs) -> image&
Subtract lhs element-wise from rhs
auto operator*=(T const& rhs) -> image&
Multiply rhs element-wise with this image.
auto operator/=(image const& rhs) -> image&
Divide this image element-wise by rhs
auto operator/=(T const& rhs) -> image&
Divide rhs element-wise by this image.

Friends

auto operator==(image const& lhs, image const& rhs) -> bool
Compares two images.
auto operator!=(image const& lhs, image const& rhs) -> bool
Compares two images for inequality.
template<typename T_other>
auto operator==(T_other const& lhs, image const& rhs) -> std::enable_if_t<!std::is_same<image, T_other>::value, bool>
Compares two images.
template<typename T_other>
auto operator!=(T_other const& lhs, image const& rhs) -> std::enable_if_t<!std::is_same<image, T_other>::value, bool>
Compares two images for inequality.
template<typename T_other>
auto operator==(image const& lhs, T_other const& rhs) -> bool
Compares two images.
template<typename T_other>
auto operator!=(image const& lhs, T_other const& rhs) -> std::enable_if_t<!std::is_same<image, T_other>::value, bool>
Compares two images for inequality.
auto operator+(image lhs, image const& rhs) -> image
Add rhs element-wise to lhs.
auto operator+(image lhs, T const& rhs) -> image
Add rhs element-wise to lhs.
auto operator+(T const& lhs, image rhs) -> image
Add lhs element-wise to rhs
auto operator-(image lhs, image const& rhs) -> image
Subtract rhs element-wise from lhs
auto operator-(image lhs, T const& rhs) -> image
Subtract rhs element-wise from lhs
auto operator*(image lhs, image const& rhs) -> image
Multiply lhs element-wise with rhs
auto operator*(image lhs, T const& rhs) -> image
Multiply rhs element-wise with lhs
auto operator*(T const& lhs, image rhs) -> image
Multiply rhs element-wise with lhs
auto operator/(image lhs, image const& rhs) -> image
Divide lhs element-wise by rhs
auto operator/(image lhs, T const& rhs) -> image
Divide rhs element-wise by lhs

Function documentation

template<typename T, size_t Channels>
spice::image<T, Channels>::image(image const& other)

Copy-construct a new image object.

Parameters
other

template<typename T, size_t Channels>
spice::image<T, Channels>::image(image&& other)

Move an image object.

Parameters
other

template<typename T, size_t Channels>
spice::image<T, Channels>::image(size_t width, size_t height)

Construct a new image object with the given width and height, initialising all values with T{}

Parameters
width
height

template<typename T, size_t Channels>
spice::image<T, Channels>::image(T const*const data, size_t width, size_t height)

Construct a new image object with the given width and height and initialise it with the provided data.

Parameters
data pointer to data array in planar memory layout
width
height

The data array is assumed to have the following properties:

  • Planar memory layout (i.e. all red samples before all green samples before all blue samples etc...)
  • RGB[A[X...]] channel order
  • length width * height * Channels

template<typename T, size_t Channels>
T*const spice::image<T, Channels>::data() noexcept

Get direct access to the underlying data.

Returns T * const

template<typename T, size_t Channels>
T const *const spice::image<T, Channels>::data() const noexcept

Get direct access to the underlying data.

Returns T * const&

template<typename T, size_t Channels>
size_t spice::image<T, Channels>::width() const

Get the width of the image.

Returns size_t

template<typename T, size_t Channels>
size_t spice::image<T, Channels>::height() const

Get the height of the image.

Returns size_t

template<typename T, size_t Channels>
size_t spice::image<T, Channels>::channels() const constexpr

Get the number of channels in the image.

Returns constexpr size_t

template<typename T, size_t Channels>
size_t spice::image<T, Channels>::size() const constexpr

Get the size of the data array containing the image.

Returns constexpr size_t

template<typename T, size_t Channels>
T& spice::image<T, Channels>::operator[](size_t offset)

Get a reference to the sample at the specified offset.

Parameters
offset
Returns T &

template<typename T, size_t Channels>
T const & spice::image<T, Channels>::operator[](size_t offset) const

Get a constant reference to the sample at the specified offset.

Parameters
offset
Returns T &

template<typename T, size_t Channels>
color_view<T> spice::image<T, Channels>::operator()(int x, int y)

Get pixel value at specified coordinates.

Parameters
x The x-coordinate
y The y-coordinate
Returns color<T, Channels>& A reference to the image's color at the given coordinates

template<typename T, size_t Channels>
color_view<T const > const spice::image<T, Channels>::operator()(int x, int y) const

Get pixel value at specified coordinates.

Parameters
x The x-coordinate
y The y-coordinate
Returns color<T, Channels>& A constant reference to the image's color at the given coordinates

template<typename T, size_t Channels>
T& spice::image<T, Channels>::operator()(int x, int y, int c)

Get reference to scalar value at specified coordinates.

Parameters
x The x-coordinate
y The y-coordinate
c The channel
Returns T& A reference to the image's color at the given coordinates

template<typename T, size_t Channels>
T const & spice::image<T, Channels>::operator()(int x, int y, int c) const

Get reference to scalar value at specified coordinates.

Parameters
x The x-coordinate
y The y-coordinate
c The channel
Returns T const & A constant reference to the image's color at the given coordinates

template<typename T, size_t Channels>
image& spice::image<T, Channels>::operator+=(image const& rhs)

Add rhs element-wise to this image.

Parameters
rhs
Returns image&

template<typename T, size_t Channels>
image& spice::image<T, Channels>::operator+=(T const& rhs)

Add rhs element-wise to this image.

Parameters
rhs
Returns image&

template<typename T, size_t Channels>
image& spice::image<T, Channels>::operator-=(image const& rhs)

Subtract rhs element-wise from this image.

Parameters
rhs
Returns image&

template<typename T, size_t Channels>
image& spice::image<T, Channels>::operator-=(T const& rhs)

Subtract rhs element-wise from this image.

Parameters
rhs
Returns image&

template<typename T, size_t Channels>
image& spice::image<T, Channels>::operator*=(image const& rhs)

Subtract lhs element-wise from rhs

Parameters
rhs
Returns image&

Multiply this image element-wise with rhs

template<typename T, size_t Channels>
image& spice::image<T, Channels>::operator*=(T const& rhs)

Multiply rhs element-wise with this image.

Parameters
rhs
Returns image&

template<typename T, size_t Channels>
image& spice::image<T, Channels>::operator/=(image const& rhs)

Divide this image element-wise by rhs

Parameters
rhs
Returns image&

template<typename T, size_t Channels>
image& spice::image<T, Channels>::operator/=(T const& rhs)

Divide rhs element-wise by this image.

Parameters
rhs
Returns image&

template<typename T, size_t Channels>
bool operator==(image const& lhs, image const& rhs)

Compares two images.

Parameters
lhs
rhs
Returns true if the two have the same number of elements with corresponding values, false otherwise

template<typename T, size_t Channels>
bool operator!=(image const& lhs, image const& rhs)

Compares two images for inequality.

Parameters
lhs
rhs
Returns true if the two have an unequal number of elements or non-corresponding values, false otherwise

template<typename T, size_t Channels> template<typename T_other>
std::enable_if_t<!std::is_same<image, T_other>::value, bool> operator==(T_other const& lhs, image const& rhs)

Compares two images.

Template parameters
T_other A type implementing the subscript operator as well as width, height and channels member functions
Parameters
lhs
rhs
Returns true if the two have the same number of elements with corresponding values, false otherwise

template<typename T, size_t Channels> template<typename T_other>
std::enable_if_t<!std::is_same<image, T_other>::value, bool> operator!=(T_other const& lhs, image const& rhs)

Compares two images for inequality.

Template parameters
T_other A type implementing the subscript operator as well as width, height and channels member functions
Parameters
lhs
rhs
Returns true if the two have an unequal number of elements or non-corresponding values, false otherwise

template<typename T, size_t Channels> template<typename T_other>
bool operator==(image const& lhs, T_other const& rhs)

Compares two images.

Template parameters
T_other A type implementing the subscript operator as well as width, height and channels member functions
Parameters
lhs
rhs
Returns true if the two have the same number of elements with corresponding values, false otherwise

template<typename T, size_t Channels> template<typename T_other>
std::enable_if_t<!std::is_same<image, T_other>::value, bool> operator!=(image const& lhs, T_other const& rhs)

Compares two images for inequality.

Template parameters
T_other A type implementing the subscript operator as well as width, height and channels member functions
Parameters
lhs
rhs
Returns true if the two have an unequal number of elements or non-corresponding values, false otherwise

template<typename T, size_t Channels>
image operator+(image lhs, image const& rhs)

Add rhs element-wise to lhs.

Parameters
lhs
rhs
Returns image&

template<typename T, size_t Channels>
image operator+(image lhs, T const& rhs)

Add rhs element-wise to lhs.

Parameters
lhs
rhs
Returns image&

template<typename T, size_t Channels>
image operator+(T const& lhs, image rhs)

Add lhs element-wise to rhs

Parameters
lhs
rhs
Returns image&

template<typename T, size_t Channels>
image operator-(image lhs, image const& rhs)

Subtract rhs element-wise from lhs

Parameters
lhs
rhs
Returns image&

template<typename T, size_t Channels>
image operator-(image lhs, T const& rhs)

Subtract rhs element-wise from lhs

Parameters
lhs
rhs
Returns image&

template<typename T, size_t Channels>
image operator*(image lhs, image const& rhs)

Multiply lhs element-wise with rhs

Parameters
lhs
rhs
Returns image&

template<typename T, size_t Channels>
image operator*(image lhs, T const& rhs)

Multiply rhs element-wise with lhs

Parameters
lhs
rhs
Returns image&

template<typename T, size_t Channels>
image operator*(T const& lhs, image rhs)

Multiply rhs element-wise with lhs

Parameters
lhs
rhs
Returns image&

template<typename T, size_t Channels>
image operator/(image lhs, image const& rhs)

Divide lhs element-wise by rhs

Parameters
lhs
rhs
Returns image&

template<typename T, size_t Channels>
image operator/(image lhs, T const& rhs)

Divide rhs element-wise by lhs

Parameters
lhs
rhs
Returns image&