This documentation is automatically generated from the openFrameworks source code using doxygen and refers to the most recent release, version 0.12.0.
A class representing a collection of pixels. More...
#include <ofPixels.h>
Public Member Functions | |
Construction And Allocation | |
ofPixels_ () | |
~ofPixels_ () | |
ofPixels_ (const ofPixels_< PixelType > &mom) | |
ofPixels_ (ofPixels_< PixelType > &&mom) | |
template<typename SrcType > | |
ofPixels_ (const ofPixels_< SrcType > &mom) | |
void | allocate (size_t w, size_t h, size_t channels) |
Allocates space for pixel data. | |
void | allocate (size_t w, size_t h, ofPixelFormat pixelFormat) |
Allocates space for pixel data. | |
void | allocate (size_t w, size_t h, ofImageType imageType) |
Allocates space for pixel data. | |
bool | isAllocated () const |
Get whether memory has been allocated for an ofPixels object or not. | |
void | clear () |
Clear all the data from the ofPixels objects. After calling this you'll need to allocate() the ofPixels object again to use it. | |
ofPixels_< PixelType > & | operator= (const ofPixels_< PixelType > &mom) |
ofPixels_< PixelType > & | operator= (ofPixels_< PixelType > &&mom) |
template<typename SrcType > | |
ofPixels_< PixelType > & | operator= (const ofPixels_< SrcType > &mom) |
Set Pixel Data | |
void | set (PixelType val) |
void | set (size_t channel, PixelType val) |
void | setFromPixels (const PixelType *newPixels, size_t w, size_t h, size_t channels) |
void | setFromPixels (const PixelType *newPixels, size_t w, size_t h, ofPixelFormat pixelFormat) |
void | setFromPixels (const PixelType *newPixels, size_t w, size_t h, ofImageType type) |
void | setFromExternalPixels (PixelType *newPixels, size_t w, size_t h, size_t channels) |
void | setFromExternalPixels (PixelType *newPixels, size_t w, size_t h, ofPixelFormat pixelFormat) |
void | setFromAlignedPixels (const PixelType *newPixels, size_t width, size_t height, size_t channels, size_t stride) |
void | setFromAlignedPixels (const PixelType *newPixels, size_t width, size_t height, ofPixelFormat pixelFormat, size_t stride) |
void | setFromAlignedPixels (const PixelType *newPixels, size_t width, size_t height, ofPixelFormat pixelFormat, std::vector< size_t > strides) |
used to copy i420 pixels from gstreamer when (width % 4) != 0 | |
void | swap (ofPixels_< PixelType > &pix) |
Modify Existing Data | |
void | crop (size_t x, size_t y, size_t width, size_t height) |
Crop the pixels to a new width and height. | |
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 the xand y` and width the new width and height. | |
void | rotate90 (int nClockwiseRotations) |
void | rotate90To (ofPixels_< PixelType > &dst, int nClockwiseRotations) const |
void | mirrorTo (ofPixels_< PixelType > &dst, bool vertically, bool horizontal) const |
void | mirror (bool vertically, bool horizontal) |
Mirror the pixels across the vertical and/or horizontal axis. | |
bool | resize (size_t dstWidth, size_t dstHeight, ofInterpolationMethod interpMethod=OF_INTERPOLATE_NEAREST_NEIGHBOR) |
Resize the ofPixels instance to the dstHeight and dstWidth. | |
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. | |
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 ofPixels that the method is being called on to the ofPixels object at &dst . If the data being copied doesn't fit into the destination then the image is cropped. | |
bool | blendInto (ofPixels_< PixelType > &dst, size_t x, size_t y) const |
void | swapRgb () |
Swaps the R and B channels of an image, leaving the G and A channels as is. | |
Pixels Access | |
PixelType * | getData () |
Retrieves pixel data from the ofPixel object. | |
const PixelType * | getData () const |
OF_DEPRECATED_MSG ("Use getData instead", PixelType *getPixels()) | |
OF_DEPRECATED_MSG ("Use getData instead", const PixelType *getPixels() const) | |
size_t | getPixelIndex (size_t x, size_t y) const |
Get the pixel index at a x,y position. | |
ofColor_< PixelType > | getColor (size_t x, size_t y) const |
Get the color at a x,y position. | |
ofColor_< PixelType > | getColor (size_t index) const |
Get the color at a specific index. | |
void | setColor (size_t x, size_t y, const ofColor_< PixelType > &color) |
Set the color of the pixel at the x,y location. | |
void | setColor (size_t index, const ofColor_< PixelType > &color) |
Set the color of the pixel at a specific index. | |
void | setColor (const ofColor_< PixelType > &color) |
Set the color of all pixels. | |
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 for each pixel, if you have RGBA, you'll have 4. | |
PixelType & | operator[] (size_t pos) |
Getters | |
size_t | getWidth () const |
Get the width of the pixel array. | |
size_t | getHeight () const |
Get the height of the pixel array. | |
size_t | getBytesPerPixel () const |
Get the number of bytes per pixel. | |
size_t | getBitsPerPixel () const |
Get number of bits per pixel. | |
size_t | getBytesPerChannel () const |
Get how large each channel of a pixel is. | |
size_t | getBitsPerChannel () const |
Get how large each channel of a pixels is. | |
size_t | getBytesStride () const |
size_t | getNumChannels () const |
Get the number of channels that the ofPixels object contains. RGB is 3 channels, RGBA is 4, and grayscale is 1. | |
size_t | getTotalBytes () const |
size_t | getNumPlanes () const |
ofPixels_< PixelType > | getPlane (size_t plane) |
ofPixels_< PixelType > | getChannel (size_t channel) const |
Get all values of one channel. | |
ofPixelFormat | getPixelFormat () const |
size_t | size () const |
Get the number of values that the ofPixels object contains, so an RGB data 400x400 would be 480,000, whereas RGBA data of the same dimensions would be 640,000. | |
ofImageType | getImageType () const |
Get the type of the image. | |
Iterator | |
typedef PixelType * | iterator |
typedef const PixelType * | const_iterator |
typedef PixelType * | reverse_iterator |
typedef const PixelType * | const_reverse_iterator |
iterator | begin () |
iterator | end () |
const_iterator | begin () const |
const_iterator | end () const |
reverse_iterator | rbegin () |
reverse_iterator | rend () |
const_reverse_iterator | rbegin () const |
const_reverse_iterator | rend () const |
Setters | |
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 object assumed to be a grayscale representation of the data that should go into that one channel. | |
void | setImageType (ofImageType imageType) |
Changes the image type for the ofPixels object. | |
void | setNumChannels (size_t numChannels) |
static size_t | pixelBitsFromPixelFormat (ofPixelFormat format) |
static size_t | bytesFromPixelFormat (size_t w, size_t h, ofPixelFormat format) |
Detailed Description
class ofPixels_< PixelType >
A class representing a collection of pixels.
Member Typedef Documentation
◆ const_iterator
typedef const PixelType* ofPixels_< PixelType >::const_iterator |
◆ const_reverse_iterator
typedef const PixelType* ofPixels_< PixelType >::const_reverse_iterator |
◆ iterator
typedef PixelType* ofPixels_< PixelType >::iterator |
◆ reverse_iterator
typedef PixelType* ofPixels_< PixelType >::reverse_iterator |
Constructor & Destructor Documentation
◆ ofPixels_() [1/4]
ofPixels_< PixelType >::ofPixels_ | ( | ) |
◆ ~ofPixels_()
◆ ofPixels_() [2/4]
ofPixels_< PixelType >::ofPixels_ | ( | const ofPixels_< PixelType > & | mom | ) |
◆ ofPixels_() [3/4]
ofPixels_< PixelType >::ofPixels_ | ( | ofPixels_< PixelType > && | mom | ) |
◆ ofPixels_() [4/4]
ofPixels_< PixelType >::ofPixels_ | ( | const ofPixels_< SrcType > & | mom | ) |
Member Function Documentation
◆ allocate() [1/3]
void ofPixels_< PixelType >::allocate | ( | size_t | w, |
size_t | h, | ||
ofImageType | imageType | ||
) |
Allocates space for pixel data.
The imageType can be one of the following:
OF_IMAGE_GRAYSCALE OF_IMAGE_COLOR OF_IMAGE_COLOR_ALPHA
- Parameters
-
w Width of pixel array h Height of pixel array imageType ofImageType defining number of channels per pixel
◆ allocate() [2/3]
void ofPixels_< PixelType >::allocate | ( | size_t | w, |
size_t | h, | ||
ofPixelFormat | pixelFormat | ||
) |
Allocates space for pixel data.
The pixelFormat can be one of the following:
OF_PIXELS_RGB OF_PIXELS_RGBA OF_PIXELS_BGRA OF_PIXELS_MONO
- Parameters
-
w Width of pixel array h Height of pixel array pixelFormat ofPixelFormat defining number of channels per pixel
◆ allocate() [3/3]
void ofPixels_< PixelType >::allocate | ( | size_t | w, |
size_t | h, | ||
size_t | channels | ||
) |
Allocates space for pixel data.
- Parameters
-
w Width of pixel array h Height of pixel array channels Number of channels per pixel
◆ begin() [1/2]
|
inline |
◆ begin() [2/2]
|
inline |
◆ blendInto()
bool ofPixels_< PixelType >::blendInto | ( | ofPixels_< PixelType > & | dst, |
size_t | x, | ||
size_t | y | ||
) | const |
◆ bytesFromPixelFormat()
|
static |
◆ clear()
void ofPixels_< PixelType >::clear | ( | ) |
Clear all the data from the ofPixels objects. After calling this you'll need to allocate() the ofPixels object again to use it.
◆ crop()
void ofPixels_< PixelType >::crop | ( | size_t | x, |
size_t | y, | ||
size_t | width, | ||
size_t | height | ||
) |
Crop the pixels to a new width and height.
As a word of caution this reallocates memory and can be a bit expensive if done a lot.
◆ cropTo()
void ofPixels_< PixelType >::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 the
xand
y` and width the new width and height.
As a word of caution this reallocates memory and can be a bit expensive if done a lot.
◆ end() [1/2]
|
inline |
◆ end() [2/2]
|
inline |
◆ getBitsPerChannel()
size_t ofPixels_< PixelType >::getBitsPerChannel | ( | ) | const |
Get how large each channel of a pixels is.
ofPixels objects that store pixel data as unsigned char
are smaller than ofPixels objects that store pixel data as 'float`.
- Note
- This returns bits, not bytes, so you should see ofPixels<float> return 32 and ofPixels<unsigned char> return 8.
◆ getBitsPerPixel()
size_t ofPixels_< PixelType >::getBitsPerPixel | ( | ) | const |
Get number of bits per pixel.
If you have RGB pixel data, this will return 24, if you have RGBA, you'll have 32, if you have grayscale, this will return 8.
◆ getBytesPerChannel()
size_t ofPixels_< PixelType >::getBytesPerChannel | ( | ) | const |
Get how large each channel of a pixel is.
ofPixels objects that store pixel data as unsigned char are smaller than ofPixels objects that store pixel data as floats.
- Note
- This returns bytes, not bits, so you should see ofPixels<float> return 4 and ofPixels<unsigned char> return 1.
◆ getBytesPerPixel()
size_t ofPixels_< PixelType >::getBytesPerPixel | ( | ) | const |
Get the number of bytes per pixel.
◆ getBytesStride()
size_t ofPixels_< PixelType >::getBytesStride | ( | ) | const |
◆ getChannel()
ofPixels_< PixelType > ofPixels_< PixelType >::getChannel | ( | size_t | channel | ) | const |
Get all values of one channel.
For instance, the Red pixel values, from the ofPixels object, this gives you a grayscale representation of the specific channel
◆ getColor() [1/2]
ofColor_< PixelType > ofPixels_< PixelType >::getColor | ( | size_t | index | ) | const |
Get the color at a specific index.
◆ getColor() [2/2]
ofColor_< PixelType > ofPixels_< PixelType >::getColor | ( | size_t | x, |
size_t | y | ||
) | const |
Get the color at a x,y position.
◆ getData() [1/2]
PixelType * ofPixels_< PixelType >::getData | ( | ) |
Retrieves pixel data from the ofPixel object.
- Returns
- A raw pointer to the pixel data.
◆ getData() [2/2]
const PixelType * ofPixels_< PixelType >::getData | ( | ) | const |
◆ getHeight()
size_t ofPixels_< PixelType >::getHeight | ( | ) | const |
Get the height of the pixel array.
◆ getImageType()
ofImageType ofPixels_< PixelType >::getImageType | ( | ) | const |
Get the type of the image.
- Returns
- One of the following types:
OF_IMAGE_GRAYSCALE
,OF_IMAGE_COLOR
,OF_IMAGE_COLOR_ALPHA
◆ getNumChannels()
size_t ofPixels_< PixelType >::getNumChannels | ( | ) | const |
Get the number of channels that the ofPixels object contains. RGB is 3 channels, RGBA is 4, and grayscale is 1.
◆ getNumPlanes()
size_t ofPixels_< PixelType >::getNumPlanes | ( | ) | const |
◆ getPixelFormat()
ofPixelFormat ofPixels_< PixelType >::getPixelFormat | ( | ) | const |
◆ getPixelIndex()
size_t ofPixels_< PixelType >::getPixelIndex | ( | size_t | x, |
size_t | y | ||
) | const |
Get the pixel index at a x,y position.
◆ getPlane()
ofPixels_< PixelType > ofPixels_< PixelType >::getPlane | ( | size_t | plane | ) |
◆ getTotalBytes()
size_t ofPixels_< PixelType >::getTotalBytes | ( | ) | const |
◆ getWidth()
size_t ofPixels_< PixelType >::getWidth | ( | ) | const |
Get the width of the pixel array.
◆ isAllocated()
bool ofPixels_< PixelType >::isAllocated | ( | ) | const |
Get whether memory has been allocated for an ofPixels object or not.
Many operations like copying pixels, etc, automatically allocate the memory needed, but it's sometimes good to check.
◆ mirror()
void ofPixels_< PixelType >::mirror | ( | bool | vertically, |
bool | horizontal | ||
) |
Mirror the pixels across the vertical and/or horizontal axis.
- Parameters
-
vertically Set to true to mirror vertically horizontal Set to true to mirror horizontal
◆ mirrorTo()
void ofPixels_< PixelType >::mirrorTo | ( | ofPixels_< PixelType > & | dst, |
bool | vertically, | ||
bool | horizontal | ||
) | const |
◆ OF_DEPRECATED_MSG() [1/2]
ofPixels_< PixelType >::OF_DEPRECATED_MSG | ( | "Use getData instead" | , |
const PixelType *getPixels() const | |||
) |
◆ OF_DEPRECATED_MSG() [2/2]
ofPixels_< PixelType >::OF_DEPRECATED_MSG | ( | "Use getData instead" | , |
PixelType * | getPixels() | ||
) |
◆ operator=() [1/3]
ofPixels_< PixelType > & ofPixels_< PixelType >::operator= | ( | const ofPixels_< PixelType > & | mom | ) |
◆ operator=() [2/3]
ofPixels_< PixelType > & ofPixels_< PixelType >::operator= | ( | const ofPixels_< SrcType > & | mom | ) |
◆ operator=() [3/3]
ofPixels_< PixelType > & ofPixels_< PixelType >::operator= | ( | ofPixels_< PixelType > && | mom | ) |
◆ operator[]() [1/2]
PixelType & ofPixels_< PixelType >::operator[] | ( | size_t | pos | ) |
◆ operator[]() [2/2]
const PixelType & ofPixels_< 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 for each pixel, if you have RGBA, you'll have 4.
◆ pasteInto()
bool ofPixels_< PixelType >::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 ofPixels that the method is being called on to the ofPixels object at &dst
. If the data being copied doesn't fit into the destination then the image is cropped.
◆ pixelBitsFromPixelFormat()
|
static |
◆ rbegin() [1/2]
|
inline |
◆ rbegin() [2/2]
|
inline |
◆ rend() [1/2]
|
inline |
◆ rend() [2/2]
|
inline |
◆ resize()
bool ofPixels_< PixelType >::resize | ( | size_t | dstWidth, |
size_t | dstHeight, | ||
ofInterpolationMethod | interpMethod = OF_INTERPOLATE_NEAREST_NEIGHBOR |
||
) |
Resize the ofPixels instance to the dstHeight and dstWidth.
The options for the interpolation methods are as follows:
OF_INTERPOLATE_NEAREST_NEIGHBOR OF_INTERPOLATE_BILINEAR OF_INTERPOLATE_BICUBIC
◆ resizeTo()
bool ofPixels_< PixelType >::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.
The options for the interpolation methods are as follows:
OF_INTERPOLATE_NEAREST_NEIGHBOR OF_INTERPOLATE_BILINEAR OF_INTERPOLATE_BICUBIC
◆ rotate90()
void ofPixels_< PixelType >::rotate90 | ( | int | nClockwiseRotations | ) |
◆ rotate90To()
void ofPixels_< PixelType >::rotate90To | ( | ofPixels_< PixelType > & | dst, |
int | nClockwiseRotations | ||
) | const |
◆ set() [1/2]
void ofPixels_< PixelType >::set | ( | PixelType | val | ) |
◆ set() [2/2]
void ofPixels_< PixelType >::set | ( | size_t | channel, |
PixelType | val | ||
) |
◆ setChannel()
void ofPixels_< PixelType >::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 object assumed to be a grayscale representation of the data that should go into that one channel.
◆ setColor() [1/3]
void ofPixels_< PixelType >::setColor | ( | const ofColor_< PixelType > & | color | ) |
Set the color of all pixels.
◆ setColor() [2/3]
void ofPixels_< PixelType >::setColor | ( | size_t | index, |
const ofColor_< PixelType > & | color | ||
) |
Set the color of the pixel at a specific index.
◆ setColor() [3/3]
void ofPixels_< PixelType >::setColor | ( | size_t | x, |
size_t | y, | ||
const ofColor_< PixelType > & | color | ||
) |
Set the color of the pixel at the x,y location.
◆ setFromAlignedPixels() [1/3]
void ofPixels_< PixelType >::setFromAlignedPixels | ( | const PixelType * | newPixels, |
size_t | width, | ||
size_t | height, | ||
ofPixelFormat | pixelFormat, | ||
size_t | stride | ||
) |
◆ setFromAlignedPixels() [2/3]
void ofPixels_< PixelType >::setFromAlignedPixels | ( | const PixelType * | newPixels, |
size_t | width, | ||
size_t | height, | ||
ofPixelFormat | pixelFormat, | ||
std::vector< size_t > | strides | ||
) |
used to copy i420 pixels from gstreamer when (width % 4) != 0
◆ setFromAlignedPixels() [3/3]
void ofPixels_< PixelType >::setFromAlignedPixels | ( | const PixelType * | newPixels, |
size_t | width, | ||
size_t | height, | ||
size_t | channels, | ||
size_t | stride | ||
) |
◆ setFromExternalPixels() [1/2]
void ofPixels_< PixelType >::setFromExternalPixels | ( | PixelType * | newPixels, |
size_t | w, | ||
size_t | h, | ||
ofPixelFormat | pixelFormat | ||
) |
◆ setFromExternalPixels() [2/2]
void ofPixels_< PixelType >::setFromExternalPixels | ( | PixelType * | newPixels, |
size_t | w, | ||
size_t | h, | ||
size_t | channels | ||
) |
◆ setFromPixels() [1/3]
void ofPixels_< PixelType >::setFromPixels | ( | const PixelType * | newPixels, |
size_t | w, | ||
size_t | h, | ||
ofImageType | type | ||
) |
◆ setFromPixels() [2/3]
void ofPixels_< PixelType >::setFromPixels | ( | const PixelType * | newPixels, |
size_t | w, | ||
size_t | h, | ||
ofPixelFormat | pixelFormat | ||
) |
◆ setFromPixels() [3/3]
void ofPixels_< PixelType >::setFromPixels | ( | const PixelType * | newPixels, |
size_t | w, | ||
size_t | h, | ||
size_t | channels | ||
) |
◆ setImageType()
void ofPixels_< PixelType >::setImageType | ( | ofImageType | imageType | ) |
Changes the image type for the ofPixels object.
- Parameters
-
imageType Can be one of the following: OF_IMAGE_GRAYSCALE, OF_IMAGE_COLOR, OF_IMAGE_COLOR_ALPHA
◆ setNumChannels()
void ofPixels_< PixelType >::setNumChannels | ( | size_t | numChannels | ) |
◆ size()
size_t ofPixels_< PixelType >::size | ( | ) | const |
Get the number of values that the ofPixels object contains, so an RGB data 400x400 would be 480,000, whereas RGBA data of the same dimensions would be 640,000.
◆ swap()
◆ swapRgb()
void ofPixels_< PixelType >::swapRgb | ( | ) |
Swaps the R and B channels of an image, leaving the G and A channels as is.
The documentation for this class was generated from the following files:
- /Users/icq4ever/Desktop/oF0120/libs/openFrameworks/app/ofAppGLFWWindow.h
- /Users/icq4ever/Desktop/oF0120/libs/openFrameworks/graphics/ofPixels.h
- /Users/icq4ever/Desktop/oF0120/libs/openFrameworks/graphics/ofPixels.cpp