41 Obj( int32_t width, int32_t height );
42 Obj( int32_t aWidth, int32_t aHeight, int32_t aRowBytes, uint8_t aIncrement,
bool aOwnsData, T *aData );
45 int32_t mWidth, mHeight, mRowBytes;
50 void (*mDeallocatorFunc)(
void *refcon);
51 void *mDeallocatorRefcon;
59 ChannelT( int32_t width, int32_t height );
61 ChannelT( int32_t width, int32_t height, int32_t rowBytes, uint8_t increment, T *data );
94 T*
getData(
const Vec2i &offset ) {
return reinterpret_cast<T*
>(
reinterpret_cast<unsigned char*
>(
mObj->mData + offset.
x *
mObj->mIncrement ) + offset.
y *
mObj->mRowBytes ); }
96 const T*
getData(
const Vec2i &offset )
const {
return reinterpret_cast<T*
>(
reinterpret_cast<unsigned char*
>(
mObj->mData + offset.
x *
mObj->mIncrement ) + offset.
y *
mObj->mRowBytes ); }
98 T*
getData( int32_t x, int32_t y ) {
return reinterpret_cast<T*
>(
reinterpret_cast<unsigned char*
>(
mObj->mData + x *
mObj->mIncrement ) + y *
mObj->mRowBytes ); }
100 const T*
getData( int32_t x, int32_t y )
const {
return reinterpret_cast<T*
>(
reinterpret_cast<unsigned char*
>(
mObj->mData + x *
mObj->mIncrement ) + y *
mObj->mRowBytes ); }
103 T
getValue (
Vec2i pos )
const { pos.
x = constrain<int32_t>( pos.
x, 0,
mObj->mWidth - 1); pos.
y = constrain<int32_t>( pos.
y, 0,
mObj->mHeight - 1 );
return *
getData( pos ); }
105 void setValue(
Vec2i pos, T v ) { pos.
x = constrain<int32_t>( pos.
x, 0,
mObj->mWidth - 1); pos.
y = constrain<int32_t>( pos.
y, 0,
mObj->mHeight - 1 ); *
getData( pos ) = v; }
114 void setDeallocator(
void(*aDeallocatorFunc)(
void * ),
void *aDeallocatorRefcon );
117 typedef std::shared_ptr<Obj>
ChannelT::*unspecified_bool_type;
118 operator unspecified_bool_type()
const {
return (
mObj.get() == 0 ) ? 0 : &
ChannelT::mObj; }
119 void reset() {
mObj.reset(); }
131 mLinePtr =
reinterpret_cast<uint8_t*
>( channelT.
getData( clippedArea.
getUL() ) );
132 mPtr =
reinterpret_cast<T*
>( mLinePtr );
133 mStartX = mX = clippedArea.
getX1();
134 mStartY = mY = clippedArea.
getY1();
135 mEndX = clippedArea.
getX2();
136 mEndY = clippedArea.
getY2();
138 mY = clippedArea.
getY1() - 1;
143 T&
v()
const {
return *mPtr; }
145 T&
v( int32_t xOff, int32_t yOff )
const {
return mPtr[xOff * mInc + yOff * mRowInc]; }
148 { xOff = std::min(std::max(mX + xOff, mStartX),mEndX - 1) - mX; yOff = std::min(std::max( mY + yOff, mStartY ), mEndY - 1) - mY;
149 return *(T*)((uint8_t*)( mPtr + xOff * mInc ) + yOff * mRowInc); }
152 const int32_t
x()
const {
return mX; }
154 const int32_t
y()
const {
return mY; }
169 mPtr =
reinterpret_cast<T*
>( mLinePtr );
185 int32_t mRowInc, mWidth, mHeight;
186 int32_t mX, mY, mStartX, mStartY, mEndX, mEndY;
199 mLinePtr =
reinterpret_cast<const uint8_t*
>( channelT.
getData( clippedArea.
getUL() ) );
200 mPtr =
reinterpret_cast<const T*
>( mLinePtr );
201 mStartX = mX = clippedArea.
getX1();
202 mStartY = mY = clippedArea.
getY1();
203 mEndX = clippedArea.
getX2();
204 mEndY = clippedArea.
getY2();
206 mY = clippedArea.
getY1() - 1;
211 const T&
v()
const {
return *mPtr; }
213 const T&
v( int32_t xOff, int32_t yOff )
const {
return mPtr[xOff * mInc + yOff * mRowInc]; }
215 const T&
vClamped( int32_t xOff, int32_t yOff )
const
216 { xOff = std::min(std::max(mX + xOff, mStartX),mEndX - 1) - mX; yOff = std::min(std::max( mY + yOff, mStartY ), mEndY - 1) - mY;
217 return *(T*)((uint8_t*)( mPtr + xOff * mInc ) + yOff * mRowInc); }
220 const int32_t
x()
const {
return mX; }
222 const int32_t
y()
const {
return mY; }
237 mPtr =
reinterpret_cast<const T*
>( mLinePtr );
251 const uint8_t *mLinePtr;
253 int32_t mRowInc, mWidth, mHeight;
254 int32_t mX, mY, mStartX, mStartY, mEndX, mEndY;
265 ConstIter
getIter(
const Area &area )
const {
return ConstIter( *
this, area ); }