image: add indexing operator for ints and points
This commit is contained in:
parent
c826822a43
commit
fc279753eb
36
image.cpp
36
image.cpp
@ -268,8 +268,44 @@ util::image::buffer<T>::downsample (float factor) const
|
||||
}
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
template <typename T>
|
||||
T
|
||||
buffer<T>::operator[] (point<2,size_t> p) const
|
||||
{
|
||||
return begin ()[p.y * s + p.x];
|
||||
}
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
template <typename T>
|
||||
T&
|
||||
buffer<T>::operator[] (point<2,size_t> p)
|
||||
{
|
||||
return begin ()[p.y * s + p.x];
|
||||
}
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
template <typename T>
|
||||
T
|
||||
buffer<T>::operator[] (size_t idx) const
|
||||
{
|
||||
return begin ()[idx];
|
||||
}
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
template <typename T>
|
||||
T&
|
||||
buffer<T>::operator[] (size_t idx)
|
||||
{
|
||||
return begin ()[idx];
|
||||
}
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
template <typename T>
|
||||
T*
|
||||
buffer<T>::data (void)
|
||||
{
|
||||
|
@ -18,6 +18,7 @@
|
||||
#define __UTIL_IMAGE_HPP
|
||||
|
||||
#include "extent.hpp"
|
||||
#include "point.hpp"
|
||||
|
||||
#include <cstdint>
|
||||
#include <cstdlib>
|
||||
@ -53,6 +54,12 @@ namespace util {
|
||||
size_t h;
|
||||
size_t s;
|
||||
|
||||
T operator[] (point<2,size_t>) const;
|
||||
T& operator[] (point<2,size_t>);
|
||||
|
||||
T operator[] (size_t) const;
|
||||
T& operator[] (size_t);
|
||||
|
||||
T* begin (void);
|
||||
T* end (void);
|
||||
T* data (void);
|
||||
|
Loading…
Reference in New Issue
Block a user