This documentation is automatically generated from the openFrameworks source code using doxygen and refers to the most recent release, version 0.12.0.
ofPixels.h
Go to the documentation of this file.
62};
155};
244 void setFromExternalPixels(PixelType * newPixels,size_t w, size_t h, ofPixelFormat pixelFormat);
245 void setFromAlignedPixels(const PixelType * newPixels, size_t width, size_t height, size_t channels, size_t stride);
246 void setFromAlignedPixels(const PixelType * newPixels, size_t width, size_t height, ofPixelFormat pixelFormat, size_t stride);
248 void setFromAlignedPixels(const PixelType * newPixels, size_t width, size_t height, ofPixelFormat pixelFormat, std::vector<size_t> strides);
267 void cropTo(ofPixels_<PixelType> &toPix, size_t x, size_t y, size_t width, size_t height) const;
286 bool resize(size_t dstWidth, size_t dstHeight, ofInterpolationMethod interpMethod=OF_INTERPOLATE_NEAREST_NEIGHBOR);
295 bool resizeTo(ofPixels_<PixelType> & dst, ofInterpolationMethod interpMethod=OF_INTERPOLATE_NEAREST_NEIGHBOR) const;
530 Pixels(PixelType * begin, PixelType * end, size_t componentsPerPixel, ofPixelFormat pixelFormat);
542 Line(PixelType * _begin, size_t stride, size_t componentsPerPixel, size_t lineNum, ofPixelFormat pixelFormat);
583 Lines(PixelType * _begin, PixelType * _end, size_t stride, size_t componentsPerPixel, size_t lines, ofPixelFormat pixelFormat);
600 ConstPixels(const PixelType * begin, const PixelType * end, size_t componentsPerPixel, ofPixelFormat pixelFormat);
612 ConstLine(const PixelType * _begin, size_t stride, size_t componentsPerPixel, size_t lineNum, ofPixelFormat pixelFormat);
645 ConstLines(const PixelType * _begin, const PixelType * _end, size_t stride, size_t componentsPerPixel, size_t lines, ofPixelFormat pixelFormat);
672 static float bicubicInterpolate(const float *patch, float x,float y, float x2,float y2, float x3,float y3);
734 const float srcMax = ( (sizeof(SrcType) == sizeof(float) ) ? 1.f : std::numeric_limits<SrcType>::max() );
735 const float dstMax = ( (sizeof(PixelType) == sizeof(float) ) ? 1.f : std::numeric_limits<PixelType>::max() );
789inline typename ofPixels_<PixelType>::const_reverse_iterator ofPixels_<PixelType>::rbegin() const{
801inline ofPixels_<PixelType>::Pixel::Pixel(PixelType * pixel, size_t componentsPerPixel, ofPixelFormat pixelFormat)
810inline const typename ofPixels_<PixelType>::Pixel& ofPixels_<PixelType>::Pixel::operator*() const{
816inline const typename ofPixels_<PixelType>::Pixel* ofPixels_<PixelType>::Pixel::operator->() const{
852inline typename ofPixels_<PixelType>::Pixel ofPixels_<PixelType>::Pixel::operator+(size_t i) const{
858inline typename ofPixels_<PixelType>::Pixel ofPixels_<PixelType>::Pixel::operator-(size_t i) const{
883inline typename ofPixels_<PixelType>::Pixel & ofPixels_<PixelType>::Pixel::operator=(Pixel const& rhs){
892inline typename ofPixels_<PixelType>::Pixel & ofPixels_<PixelType>::Pixel::operator=(ConstPixel const& rhs){
960 ofLogWarning() << "returning color not supported yet for " << ofToString(pixelFormat) << " format";
970inline ofPixels_<PixelType>::Pixels::Pixels(PixelType * begin, PixelType * end, size_t componentsPerPixel, ofPixelFormat pixelFormat)
999inline ofPixels_<PixelType>::Line::Line(PixelType * _begin, size_t stride, size_t componentsPerPixel, size_t lineNum, ofPixelFormat pixelFormat)
1009inline const typename ofPixels_<PixelType>::Line& ofPixels_<PixelType>::Line::operator*() const{
1015inline const typename ofPixels_<PixelType>::Line* ofPixels_<PixelType>::Line::operator->() const{
1055inline typename ofPixels_<PixelType>::Line ofPixels_<PixelType>::Line::operator+(size_t i) const{
1070inline bool ofPixels_<PixelType>::Line::operator!=(typename ofPixels_<PixelType>::Line const& rhs) const{
1071 return rhs._begin != _begin || rhs._end != _end || rhs.stride != stride || rhs.lineNum!=lineNum;
1076inline bool ofPixels_<PixelType>::Line::operator<(typename ofPixels_<PixelType>::Line const& rhs) const{
1082inline bool ofPixels_<PixelType>::Line::operator>(typename ofPixels_<PixelType>::Line const& rhs) const{
1088inline bool ofPixels_<PixelType>::Line::operator>=(typename ofPixels_<PixelType>::Line const& rhs) const{
1158inline typename ofPixels_<PixelType>::Pixels ofPixels_<PixelType>::Line::getPixels(size_t first, size_t numPixels){
1159 return Pixels(&getPixel(first)[0], &getPixel(first+numPixels)[0], componentsPerPixel, pixelFormat);
1164inline ofPixels_<PixelType>::Lines::Lines(PixelType * _begin, PixelType * _end, size_t stride, size_t componentsPerPixel, size_t lines, ofPixelFormat pixelFormat)
1188 return Line(pixels+(width*getNumChannels()*line), width*getNumChannels(), getNumChannels(), line,pixelFormat);
1199inline typename ofPixels_<PixelType>::Lines ofPixels_<PixelType>::getLines(size_t first, size_t numLines){
1200 return Lines(getLine(first).begin(),getLine(first+numLines).begin(),width*getNumChannels(),getNumChannels(),numLines,pixelFormat);
1211inline ofPixels_<PixelType>::ConstPixel::ConstPixel(const PixelType * pixel, size_t componentsPerPixel, ofPixelFormat pixelFormat)
1220inline const typename ofPixels_<PixelType>::ConstPixel& ofPixels_<PixelType>::ConstPixel::operator*() const{
1226inline const typename ofPixels_<PixelType>::ConstPixel* ofPixels_<PixelType>::ConstPixel::operator->() const{
1232inline typename ofPixels_<PixelType>::ConstPixel& ofPixels_<PixelType>::ConstPixel::operator++(){
1239inline typename ofPixels_<PixelType>::ConstPixel ofPixels_<PixelType>::ConstPixel::operator++(int){
1247inline typename ofPixels_<PixelType>::ConstPixel ofPixels_<PixelType>::ConstPixel::operator+(size_t i) const{
1253inline typename ofPixels_<PixelType>::ConstPixel ofPixels_<PixelType>::ConstPixel::operator-(size_t i) const{
1259inline typename ofPixels_<PixelType>::ConstPixel ofPixels_<PixelType>::ConstPixel::operator+=(size_t i){
1331 ofLogWarning() << "returning color not supported yet for " << ofToString(pixelFormat) << " format";
1341inline ofPixels_<PixelType>::ConstPixels::ConstPixels(const PixelType * begin, const PixelType * end, size_t componentsPerPixel, ofPixelFormat pixelFormat)
1349inline ofPixels_<PixelType>::ConstPixels::ConstPixels(const ConstPixel & begin, const ConstPixel & end)
1357inline typename ofPixels_<PixelType>::ConstPixel ofPixels_<PixelType>::ConstPixels::begin() const{
1363inline typename ofPixels_<PixelType>::ConstPixel ofPixels_<PixelType>::ConstPixels::end() const{
1369inline ofPixels_<PixelType>::ConstLine::ConstLine(const PixelType * _begin, size_t stride, size_t componentsPerPixel, size_t lineNum, ofPixelFormat pixelFormat)
1379inline const typename ofPixels_<PixelType>::ConstLine& ofPixels_<PixelType>::ConstLine::operator*() const{
1385inline const typename ofPixels_<PixelType>::ConstLine* ofPixels_<PixelType>::ConstLine::operator->() const{
1400inline typename ofPixels_<PixelType>::ConstLine ofPixels_<PixelType>::ConstLine::operator++(int) {
1408inline typename ofPixels_<PixelType>::ConstLine ofPixels_<PixelType>::ConstLine::operator+(size_t i) const{
1414inline typename ofPixels_<PixelType>::ConstLine ofPixels_<PixelType>::ConstLine::operator+=(size_t i){
1423inline bool ofPixels_<PixelType>::ConstLine::operator!=(typename ofPixels_<PixelType>::ConstLine const& rhs) const{
1424 return rhs._begin != _begin || rhs._end != _end || rhs.stride != stride || rhs.lineNum!=lineNum;
1429inline bool ofPixels_<PixelType>::ConstLine::operator<(typename ofPixels_<PixelType>::ConstLine const& rhs) const{
1435inline typename ofPixels_<PixelType>::const_iterator ofPixels_<PixelType>::ConstLine::begin() const{
1441inline typename ofPixels_<PixelType>::const_iterator ofPixels_<PixelType>::ConstLine::end() const{
1459inline typename ofPixels_<PixelType>::ConstPixel ofPixels_<PixelType>::ConstLine::getPixel(size_t pixel) const{
1465inline typename ofPixels_<PixelType>::ConstPixels ofPixels_<PixelType>::ConstLine::getPixels() const{
1471inline typename ofPixels_<PixelType>::ConstPixels ofPixels_<PixelType>::ConstLine::getPixels(size_t first, size_t numPixels) const{
1472 return ConstPixels(&getPixel(first)[0], &getPixel(first+numPixels)[0], componentsPerPixel, pixelFormat);
1477inline ofPixels_<PixelType>::ConstLines::ConstLines(const PixelType * _begin, const PixelType * _end, size_t stride, size_t componentsPerPixel, size_t lines, ofPixelFormat pixelFormat)
1487inline typename ofPixels_<PixelType>::ConstLine ofPixels_<PixelType>::ConstLines::begin() const{
1500inline typename ofPixels_<PixelType>::ConstLine ofPixels_<PixelType>::getConstLine(size_t line) const{
1501 return ConstLine(pixels+(width*getNumChannels()*line), width*getNumChannels(), getNumChannels(), line,pixelFormat);
1507 return ConstLines(begin(),end(),width*getNumChannels(),getNumChannels(),getHeight(),pixelFormat);
1512inline typename ofPixels_<PixelType>::ConstLines ofPixels_<PixelType>::getConstLines(size_t first, size_t numLines) const{
1513 return ConstLines(getConstLine(first).begin(),getConstLine(first+numLines).begin(),width*getNumChannels(),getNumChannels(),numLines,pixelFormat);
1518inline typename ofPixels_<PixelType>::ConstPixels ofPixels_<PixelType>::getConstPixelsIter() const{
void set(float red, float green, float blue, float alpha=limit())
Set an ofColor_ by using RGB values.
Definition ofColor.cpp:214
size_t getHeight() const
Get the height of the pixel array.
Definition ofPixels.cpp:804
const PixelType & operator[](size_t pos) const
Provides access to each channel of each pixel. If you have RGB pixel data, then you'll have 3 values ...
Definition ofPixels.cpp:789
void setFromPixels(const PixelType *newPixels, size_t w, size_t h, size_t channels)
Definition ofPixels.cpp:373
void setImageType(ofImageType imageType)
Changes the image type for the ofPixels object.
Definition ofPixels.cpp:957
bool resizeTo(ofPixels_< PixelType > &dst, ofInterpolationMethod interpMethod=OF_INTERPOLATE_NEAREST_NEIGHBOR) const
Resize the ofPixels instance to the size of the ofPixels object passed in dst.
Definition ofPixels.cpp:1335
ofPixels_< PixelType > & operator=(const ofPixels_< SrcType > &mom)
Definition ofPixels.h:723
void setColor(size_t x, size_t y, const ofColor_< PixelType > &color)
Set the color of the pixel at the x,y location.
Definition ofPixels.cpp:708
void mirror(bool vertically, bool horizontal)
Mirror the pixels across the vertical and/or horizontal axis.
Definition ofPixels.cpp:1176
void rotate90To(ofPixels_< PixelType > &dst, int nClockwiseRotations) const
Definition ofPixels.cpp:1074
size_t getNumChannels() const
Get the number of channels that the ofPixels object contains. RGB is 3 channels, RGBA is 4,...
Definition ofPixels.cpp:834
bool blendInto(ofPixels_< PixelType > &dst, size_t x, size_t y) const
Definition ofPixels.cpp:1471
size_t getBitsPerPixel() const
Get number of bits per pixel.
Definition ofPixels.cpp:814
OF_DEPRECATED_MSG("Use getData instead", PixelType *getPixels())
PixelType * getData()
Retrieves pixel data from the ofPixel object.
Definition ofPixels.cpp:500
void clear()
Clear all the data from the ofPixels objects. After calling this you'll need to allocate() the ofPixe...
Definition ofPixels.cpp:584
size_t getWidth() const
Get the width of the pixel array.
Definition ofPixels.cpp:799
size_t getBytesPerChannel() const
Get how large each channel of a pixel is.
Definition ofPixels.cpp:819
static size_t bytesFromPixelFormat(size_t w, size_t h, ofPixelFormat format)
Definition ofPixels.cpp:132
size_t size() const
Get the number of values that the ofPixels object contains, so an RGB data 400x400 would be 480,...
Definition ofPixels.cpp:997
ofPixels_< PixelType > getChannel(size_t channel) const
Get all values of one channel.
Definition ofPixels.cpp:1002
void cropTo(ofPixels_< PixelType > &toPix, size_t x, size_t y, size_t width, size_t height) const
Crop the pixels into the ofPixels reference passed in by toPix. at thexandy` and width the new width ...
Definition ofPixels.cpp:1042
bool resize(size_t dstWidth, size_t dstHeight, ofInterpolationMethod interpMethod=OF_INTERPOLATE_NEAREST_NEIGHBOR)
Resize the ofPixels instance to the dstHeight and dstWidth.
Definition ofPixels.cpp:1262
OF_DEPRECATED_MSG("Use getData instead", const PixelType *getPixels() const)
void setFromAlignedPixels(const PixelType *newPixels, size_t width, size_t height, size_t channels, size_t stride)
Definition ofPixels.cpp:411
void swapRgb()
Swaps the R and B channels of an image, leaving the G and A channels as is.
Definition ofPixels.cpp:550
void setFromExternalPixels(PixelType *newPixels, size_t w, size_t h, size_t channels)
Definition ofPixels.cpp:392
ofImageType getImageType() const
Get the type of the image.
Definition ofPixels.cpp:952
bool isAllocated() const
Get whether memory has been allocated for an ofPixels object or not.
Definition ofPixels.cpp:794
size_t getPixelIndex(size_t x, size_t y) const
Get the pixel index at a x,y position.
Definition ofPixels.cpp:598
size_t getBitsPerChannel() const
Get how large each channel of a pixels is.
Definition ofPixels.cpp:824
void crop(size_t x, size_t y, size_t width, size_t height)
Crop the pixels to a new width and height.
Definition ofPixels.cpp:1032
void setChannel(size_t channel, const ofPixels_< PixelType > channelPixels)
Set all the pixel data for a single channel, for instance, the Red pixel values, from an ofPixels obj...
Definition ofPixels.cpp:1017
void allocate(size_t w, size_t h, size_t channels)
Allocates space for pixel data.
Definition ofPixels.cpp:510
ofColor_< PixelType > getColor(size_t x, size_t y) const
Get the color at a x,y position.
Definition ofPixels.cpp:651
static size_t pixelBitsFromPixelFormat(ofPixelFormat format)
Definition ofPixels.cpp:23
ofPixels_< PixelType > & operator=(const ofPixels_< PixelType > &mom)
Definition ofPixels.cpp:298
size_t getBytesPerPixel() const
Get the number of bytes per pixel.
Definition ofPixels.cpp:809
bool pasteInto(ofPixels_< PixelType > &dst, size_t x, size_t y) const
Paste the ofPixels object into another ofPixels object at the specified index, copying data from the ...
Definition ofPixels.cpp:1443
void mirrorTo(ofPixels_< PixelType > &dst, bool vertically, bool horizontal) const
Definition ofPixels.cpp:1215
Definition ofPixels.h:1522
ofImageType
Used to represent the available channel types in ofImage.
Definition ofGraphicsConstants.h:154
float ofClamp(float value, float min, float max)
Clamp a value between min and max.
Definition ofMath.cpp:120
#define c
#define swap(a, i, j)
@ OF_PIXELS_BGRA
A pixel used for color/transparency with a blue/green/red/alpha channel order.
Definition ofPixels.h:97
@ OF_PIXELS_I420
A 12-bit YUV format similar to OF_PIXELS_YV12, but with U & V reversed.
Definition ofPixels.h:127
@ OF_PIXELS_NV12
A 12-bit YUV 4:2:0 pixel with an interleaved U/V plane.
Definition ofPixels.h:109
@ OF_PIXELS_Y
A single channel pixel, typically used for the luma component of YUV.
Definition ofPixels.h:138
@ OF_PIXELS_NATIVE
This indicates an unknown, native pixel type.
Definition ofPixels.h:154
@ OF_PIXELS_NUM_FORMATS
This is a placeholder to indicate the last valid enum.
Definition ofPixels.h:149
@ OF_PIXELS_RGBA
An RGBA pixel. This is typically used for color with transparency.
Definition ofPixels.h:93
@ OF_PIXELS_GRAY
A single-channel pixel, typically used for greyscale images.
Definition ofPixels.h:72
@ OF_PIXELS_YV12
A 12-bit YUV NxM Y plane followed by (N/2)x(M/2) V and U planes.
Definition ofPixels.h:121
@ OF_PIXELS_BGR
A pixel used for color data with a blue/green/red channel order.
Definition ofPixels.h:87
@ OF_PIXELS_V
A single channel pixel, typically used (with U) for the chroma component of YUV.
Definition ofPixels.h:142
@ OF_PIXELS_NV21
A 12-bit YUV 4:2:0 pixel with an interleaved V/U plane.
Definition ofPixels.h:117
@ OF_PIXELS_GRAY_ALPHA
A single-channel pixel with an alpha channel.
Definition ofPixels.h:76
@ OF_PIXELS_UV
A two channel pixel, with U first, representing both chroma components of YUV.
Definition ofPixels.h:144
@ OF_PIXELS_VU
A two channel pixel, with V first, representing both chroma components of YUV.
Definition ofPixels.h:146
@ OF_PIXELS_U
A single channel pixel, typically used (with V) for the chroma component of YUV.
Definition ofPixels.h:140