image: add pixel offset query
This commit is contained in:
parent
0899c16557
commit
d5f1506afd
13
image.cpp
13
image.cpp
@ -255,13 +255,22 @@ util::image::buffer<T>::downsample (float factor) const
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
template <typename T>
|
||||
size_t
|
||||
buffer<T>::offset (point<2,size_t> p) const
|
||||
{
|
||||
return dot (stride (), p);
|
||||
}
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
template <typename T>
|
||||
T
|
||||
buffer<T>::operator[] (point<2,size_t> p) const
|
||||
{
|
||||
CHECK_LT (p.x, w);
|
||||
CHECK_LT (p.y, h);
|
||||
|
||||
return begin ()[p.y * s + p.x];
|
||||
return begin ()[offset (p)];
|
||||
}
|
||||
|
||||
|
||||
@ -273,7 +282,7 @@ buffer<T>::operator[] (point<2,size_t> p)
|
||||
CHECK_LT (p.x, w);
|
||||
CHECK_LT (p.y, h);
|
||||
|
||||
return begin ()[p.y * s + p.x];
|
||||
return begin ()[offset (p)];
|
||||
}
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user