Generic Image Library: image_view< Loc > Class Template Reference

###  | #  |

Public Types | Public Member Functions | Static Public Attributes | Friends | List of all members
image_view< Loc > Class Template Reference
Image View » Models | PixelBased » Models

A lightweight object that interprets memory as a 2D array of pixels. Models ImageViewConcept,PixelBasedConcept,HasDynamicXStepTypeConcept,HasDynamicYStepTypeConcept,HasTransposedTypeConcept. More...

`#include <image_view.hpp>`

## Public Types
using | value_type = typename Loc::value_type
using | reference = typename Loc::reference
using | coord_t = typename Loc::coord_t
using | difference_type = coord_t
using | point_t = typename Loc::point_t
using | locator = Loc
using | const_t = image_view<typename Loc::const_t>
using | iterator = iterator_from_2d<Loc>
using | const_iterator = typename const_t::iterator
using | const_reference = typename const_t::reference
using | pointer = typename std::iterator_traits<iterator>::pointer
using | reverse_iterator = std::reverse_iterator<iterator>
using | size_type = std::size_t
using | xy_locator = locator
using | x_iterator = typename xy_locator::x_iterator
using | y_iterator = typename xy_locator::y_iterator
using | x_coord_t = typename xy_locator::x_coord_t
using | y_coord_t = typename xy_locator::y_coord_t

## Public Member Functions
| image_view (image_view const &img_view)
template<typename View>
| image_view (View const &view)
template<typename L2>
| image_view (point_t const &dims, L2 const &loc)
template<typename L2>
| image_view (coord_t width, coord_t height, L2 const &loc)
template<typename View>
image_view & | operator= (View const &view)
image_view & | operator= (image_view const &view)
template<typename View>
bool | operator== (View const &view) const
template<typename View>
bool | operator!= (View const &view) const
void | swap (image_view< Loc > &other)
| Exchanges the elements of the current view with those of other in constant time.
auto | dimensions () const -> point_t const &
auto | pixels () const -> locator const &
auto | width () const -> x_coord_t
auto | height () const -> y_coord_t
auto | num_channels () const -> std::size_t
bool | is_1d_traversable () const
bool | empty () const
| Returns true if the view has no elements, false otherwise.
auto | front () const -> reference
| Returns a reference to the first element in raster order.
auto | back () const -> reference
| Returns a reference to the last element in raster order.

## Static Public Attributes
static const std::size_t | num_dimensions =2

## Friends
template<typename L2>
void | swap (image_view< L2 > &lhs, image_view< L2 > &rhs)

## Y navigation
auto | y_at (x_coord_t x, y_coord_t y) const -> y_iterator
auto | y_at (point_t const &p) const -> y_iterator
auto | col_begin (x_coord_t x) const -> y_iterator
auto | col_end (x_coord_t x) const -> y_iterator

## 1D navigation
auto | size () const -> size_type
auto | begin () const -> iterator
auto | end () const -> iterator
auto | rbegin () const -> reverse_iterator
auto | rend () const -> reverse_iterator
auto | operator[] (difference_type i) const -> reference
auto | at (difference_type i) const -> iterator
auto | at (point_t const &p) const -> iterator
auto | at (x_coord_t x, y_coord_t y) const -> iterator

## 2-D navigation
auto | operator() (point_t const &p) const -> reference
auto | operator() (x_coord_t x, y_coord_t y) const -> reference
template<std::size_t D>
auto | axis_iterator (point_t const &p) const -> typename axis< D >::iterator
auto | xy_at (x_coord_t x, y_coord_t y) const -> xy_locator
auto | xy_at (point_t const &p) const -> xy_locator

## X navigation
auto | x_at (x_coord_t x, y_coord_t y) const -> x_iterator
auto | x_at (point_t const &p) const -> x_iterator
auto | row_begin (y_coord_t y) const -> x_iterator
auto | row_end (y_coord_t y) const -> x_iterator

## Detailed Description

template<typename Loc>
class boost::gil::image_view< Loc >

A lightweight object that interprets memory as a 2D array of pixels. Models ImageViewConcept,PixelBasedConcept,HasDynamicXStepTypeConcept,HasDynamicYStepTypeConcept,HasTransposedTypeConcept.

Image view consists of a pixel 2D locator (defining the mechanism for navigating in 2D) and the image dimensions.

Image views to images are what ranges are to STL containers. They are lightweight objects, that don't own the pixels. It is the user's responsibility that the underlying data remains valid for the lifetime of the image view.

Similar to iterators and ranges, constness of views does not extend to constness of pixels. A const `image_view` does not allow changing its location in memory (resizing, moving) but does not prevent one from changing the pixels. The latter requires an image view whose value_type is const.

Images have interfaces consistent with STL 1D random access containers, so they can be used directly in STL algorithms like:

std::fill(img.begin(), img.end(), red_pixel);
std::fill
void fill(boost::gil::iterator_from_2d< IL > first, boost::gil::iterator_from_2d< IL > last, const V &val)
std::fill(I,I,V) with I being a iterator_from_2d
Definition algorithm.hpp:369

In addition, horizontal, vertical and 2D random access iterators are provided.

Note also that `image_view` does not require that its element type be a pixel. It could be instantiated with a locator whose `value_type` models only `Regular`. In this case the image view models the weaker RandomAccess2DImageViewConcept, and does not model PixelBasedConcept. Many generic algorithms don't require the elements to be pixels.

## Member Function Documentation

## ◆ back()

template<typename Loc>

auto back | ( |  | ) | const -> reference
| inline

Returns a reference to the last element in raster order.

Note
  Required by the ForwardCollection, since view model the concept.

See also
  https://www.boost.org/libs/utility/Collection.html

## ◆ empty()

template<typename Loc>

bool empty | ( |  | ) | const
| inline

Returns true if the view has no elements, false otherwise.

Note
  Required by the Collection concept

See also
  https://www.boost.org/libs/utility/Collection.html

## ◆ front()

template<typename Loc>

auto front | ( |  | ) | const -> reference
| inline

Returns a reference to the first element in raster order.

Note
  Required by the ForwardCollection, since view model the concept.

See also
  https://www.boost.org/libs/utility/Collection.html

## ◆ swap()

template<typename Loc>

void swap | ( | image_view< Loc > & | other | ) |
| inline

Exchanges the elements of the current view with those of other in constant time.

Note
  Required by the Collection concept

See also
  https://www.boost.org/libs/utility/Collection.html

The documentation for this class was generated from the following file:

- image_view.hpp