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;
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 ); }
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; }
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]; }
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
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 ); }
int32_t getY1() const
Definition: Area.h:69
GLenum GLint GLint y
Definition: GLee.h:987
T * getData(const Vec2i &offset)
Returns a pointer to the data of the Channel's pixel at offset. Result is a uint8_t* for Channel8u an...
Definition: Channel.h:94
bool line()
Increments which row the Iter points to, and returns false when no rows remain in the Channel...
Definition: Channel.h:234
uint8_t getIncrement() const
Returns the amount to increment a T* to increment by a pixel. For a planar channel this is 1...
Definition: Channel.h:85
float getAspectRatio() const
Returns the Channel aspect ratio, which is its width / height.
Definition: Channel.h:79
int int * max
Definition: GLee.h:17208
int32_t getY2() const
Definition: Area.h:73
int32_t getX2() const
Definition: Area.h:71
T & v(int32_t xOff, int32_t yOff) const
Returns a reference to the value of the pixel that the Iter currently points to, offset by (xOff...
Definition: Channel.h:145
int32_t getRowBytes() const
Returns the width of a row of the Channel measured in bytes, which is not necessarily getWidth() * ge...
Definition: Channel.h:83
Iter getIter(const Area &area)
Returns an Iter which iterates the Area area.
Definition: Channel.h:261
GLenum GLsizei width
Definition: GLee.h:969
const T & vClamped(int32_t xOff, int32_t yOff) const
Returns a reference to the value of the pixel that the Iter currently points to, offset by (xOff...
Definition: Channel.h:215
Convenience class for iterating the pixels of a Channel. The iteration is const, performing read-only...
Definition: Channel.h:191
ConstIter(const ChannelT< T > &channelT, const Area &area)
Definition: Channel.h:193
static Vec2< int > zero()
Definition: Vector.h:295
const T & v() const
Returns a reference to the value of the pixel that the Iter currently points to.
Definition: Channel.h:211
GLsizei GLsizei GLenum GLenum const GLvoid * data
Definition: GLee.h:1011
Vec2i getSize() const
Returns the size of the Channel in pixels.
Definition: Channel.h:77
T x
Definition: Vector.h:71
Vec2i getUL() const
Definition: Area.h:75
typedef void(APIENTRYP GLEEPFNGLBLENDCOLORPROC)(GLclampf red
ChannelT< uint16_t > Channel16u
16-bit image channel. Suitable as an intermediate representation and ImageIo but not a first-class ci...
Definition: Channel.h:277
const T * getData(const Vec2i &offset) const
Returns a const pointer to the data of the Channel's pixel at offset. Result is a uint8_t* for Channe...
Definition: Channel.h:96
int32_t getHeight() const
Returns the height of the Channel in pixels.
Definition: Channel.h:75
int32_t getX1() const
Definition: Area.h:67
ChannelT< float > Channel32f
32-bit floating point image channel
Definition: Channel.h:279
#define min(a, b)
Definition: AppImplMsw.cpp:36
const int32_t y() const
Returns the y coordinate of the pixel the Iter currently points to.
Definition: Channel.h:154
ChannelT< uint8_t > Channel
8-bit image channel. Synonym for Channel8u.
Definition: Channel.h:273
bool isPlanar() const
Returns whether the Channel represents a tightly packed array of values. This will be false if the Ch...
Definition: Channel.h:87
int32_t getWidth() const
Definition: Area.h:47
GLenum GLsizei GLsizei height
Definition: GLee.h:1029
int32_t getWidth() const
Returns the width of the Channel in pixels.
Definition: Channel.h:73
T * getData(int32_t x, int32_t y)
Returns a pointer to the data of the Channel's pixel at (x, y). Result is a uint8_t* for Channel8u an...
Definition: Channel.h:98
const T * getData() const
Returns a const pointer to the data of the Channel's first pixel. Result is a uint8_t* for Channel8u ...
Definition: Channel.h:92
T areaAverage(const Area &area) const
Returns an averaged value for the Area defined by area.
Definition: Channel.cpp:225
void copyFrom(const ChannelT< T > &srcChannel, const Area &srcArea, const Vec2i &relativeOffset=Vec2i::zero())
Copies the Area srcArea of the Channel srcChannel to this Channel. The destination Area is srcArea of...
Definition: Channel.cpp:203
Area getClipBy(const Area &clip) const
Definition: Area.cpp:82
GLenum GLint x
Definition: GLee.h:987
bool pixel()
Increments which pixel of the current row the Iter points to, and returns false when no pixels remain...
Definition: Channel.h:227
Vec2i getPos() const
Returns the coordinate of the pixel the Iter currently points to.
Definition: Channel.h:156
GLintptr offset
Definition: GLee.h:2095
const int32_t y() const
Returns the y coordinate of the pixel the Iter currently points to.
Definition: Channel.h:222
A single channel of image data, either a color channel of a Surface or a grayscale image...
Definition: Channel.h:37
Vec2i getPos() const
Returns the coordinate of the pixel the Iter currently points to.
Definition: Channel.h:224
void setDeallocator(void(*aDeallocatorFunc)(void *), void *aDeallocatorRefcon)
Definition: Channel.cpp:175
const GLdouble * v
Definition: GLee.h:1384
Iter(ChannelT< T > &channelT, const Area &area)
Definition: Channel.h:125
void setValue(Vec2i pos, T v)
Convenience method for setting a single value v at pixel pos. For performance-sensitive code consider...
Definition: Channel.h:105
T y
Definition: Vector.h:71
ChannelT clone(bool copyPixels=true) const
Returns a new Channel which is a duplicate. If copyPixels the pixel values are copied, otherwise the clone's pixels remain uninitialized.
Definition: Channel.cpp:182
ConstIter getIter() const
Returns a ConstIter which iterates the entire Channel.
Definition: Channel.h:263
Iter getIter()
Returns an Iter which iterates the entire Channel.
Definition: Channel.h:259
ChannelT()
Constructs an empty Channel, which is the equivalent of NULL and should not be used directly...
Definition: Channel.h:57
T & v() const
Returns a reference to the value of the pixel that the Iter currently points to.
Definition: Channel.h:143
std::shared_ptr< Obj > mObj
Definition: Channel.h:268
T * getData()
Returns a pointer to the data of the Channel's first pixel. Result is a uint8_t* for Channel8u and a ...
Definition: Channel.h:90
const int32_t x() const
Returns the x coordinate of the pixel the Iter currently points to.
Definition: Channel.h:152
GLboolean reset
Definition: GLee.h:1101
Convenience class for iterating the pixels of a Channel.
Definition: Channel.h:123
T getValue(Vec2i pos) const
Convenience method for getting a single value at pixel pos. For performance-sensitive code consider C...
Definition: Channel.h:103
int32_t getHeight()
Returns the height of the Area the Iter iterates.
Definition: Channel.h:247
Area getBounds() const
Returns the bounding Area of the Channel in pixels: [0,0]-(width,height)
Definition: Channel.h:81
std::shared_ptr< class ImageSource > ImageSourceRef
Definition: Channel.h:33
int32_t getHeight()
Returns the height of the Area the Iter iterates.
Definition: Channel.h:179
const T * getData(int32_t x, int32_t y) const
Returns a const pointer to the data of the Channel's pixel at (x, y). Result is a uint8_t* for Channe...
Definition: Channel.h:100
bool pixel()
Increments which pixel of the current row the Iter points to, and returns false when no pixels remain...
Definition: Channel.h:159
ConstIter getIter(const Area &area) const
Returns a ConstIter which iterates the Area area.
Definition: Channel.h:265
T & vClamped(int32_t xOff, int32_t yOff) const
Returns a reference to the value of the pixel that the Iter currently points to, offset by (xOff...
Definition: Channel.h:147
const int32_t x() const
Returns the x coordinate of the pixel the Iter currently points to.
Definition: Channel.h:220
int32_t getWidth()
Returns the width of the Area the Iter iterates.
Definition: Channel.h:177
int32_t getWidth()
Returns the width of the Area the Iter iterates.
Definition: Channel.h:245
ChannelT< uint8_t > Channel8u
8-bit image channel
Definition: Channel.h:275
int32_t getHeight() const
Definition: Area.h:48
bool line()
Increments which row the Iter points to, and returns false when no rows remain in the Channel...
Definition: Channel.h:166
const T & v(int32_t xOff, int32_t yOff) const
Returns a reference to the value of the pixel that the Iter currently points to, offset by (xOff...
Definition: Channel.h:213
Vec2< int > Vec2i
Definition: Vector.h:1313