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 an image using memory and gpu based pixels. More...
#include <ofImage.h>

Public Member Functions | |
void | grabScreen (int x, int y, int w, int h) |
Image Construction | |
ofImage_ () | |
ofImage_ (const ofPixels_< PixelType > &pix) | |
ofImage_ (const of::filesystem::path &fileName, const ofImageLoadSettings &settings=ofImageLoadSettings()) | |
ofImage_ (const ofImage_< PixelType > &mom) | |
ofImage_ (ofImage_< PixelType > &&mom) | |
template<typename SrcType > | |
ofImage_ (const ofImage_< SrcType > &mom) | |
void | allocate (int w, int h, ofImageType type) |
bool | isAllocated () const |
Whether the image has been allocated either by a call to allocate or by loading pixel data into the image. | |
OF_DEPRECATED_MSG ("Use isAllocated()", bool bAllocated()) | |
Whether the image has been allocated either by a call to allocate or by loading pixel data into the image. | |
void | clear () |
This clears the texture and pixels contained within the ofImage. | |
bool | load (const of::filesystem::path &fileName, const ofImageLoadSettings &settings=ofImageLoadSettings()) |
Loads an image given by fileName. | |
bool | load (const ofBuffer &buffer, const ofImageLoadSettings &settings=ofImageLoadSettings()) |
Loads an image from an ofBuffer instance created by, for instance, ofFile::readToBuffer(). | |
OF_DEPRECATED_MSG ("Use load instead", bool loadImage(const std::string &fileName)) | |
OF_DEPRECATED_MSG ("Use load instead", bool loadImage(const ofBuffer &buffer)) | |
OF_DEPRECATED_MSG ("Use load instead", bool loadImage(const ofFile &file)) | |
virtual | ~ofImage_ () |
Drawing | |
void | draw (float x, float y) const |
Draw the image at it's normal size. | |
void | draw (float x, float y, float z) const |
Draw the texture at it's normal size with depth. | |
void | draw (const glm::vec3 &pos) const |
void | draw (float x, float y, float w, float h) const |
Draw the image at a given size. | |
void | draw (float x, float y, float z, float w, float h) const |
Draw the image at a given size with depth. | |
void | draw (const glm::vec3 &pos, float w, float h) const |
void | drawSubsection (float x, float y, float w, float h, float sx, float sy) const |
Draws a subsection of the image. | |
void | drawSubsection (float x, float y, float z, float w, float h, float sx, float sy) const |
Draws a subsection of the image. | |
void | drawSubsection (float x, float y, float w, float h, float sx, float sy, float sw, float sh) const |
Draws a subsection of the image. | |
void | drawSubsection (float x, float y, float z, float w, float h, float sx, float sy, float sw, float sh) const |
Draws a subsection of the image. | |
virtual void | draw (float x, float y) const |
Draw at a position at the native size. | |
virtual void | draw (float x, float y, float w, float h) const=0 |
Draw at a position with the specified size. | |
virtual void | draw (const glm::vec2 &point) const |
Draw at a position at the native size. | |
virtual void | draw (const ofRectangle &rect) const |
Draw at a position and size specified by a rectangle. | |
virtual void | draw (const glm::vec2 &point, float w, float h) const |
Draw at a position. | |
Texture | |
void | update () |
Call to ensure that changes to pixels are reflected in the ofTexture of the image. | |
void | setUseTexture (bool bUse) |
Turns on or off the allocation and use of a texture. | |
bool | isUsingTexture () const |
Returns whether the ofImage has a texture or not. | |
ofTexture & | getTexture () |
Returns a reference to the texture that the ofImage contains. | |
const ofTexture & | getTexture () const |
Returns a const reference to the texture that the ofImage contains. | |
OF_DEPRECATED_MSG ("Use getTexture", ofTexture &getTextureReference()) | |
OF_DEPRECATED_MSG ("Use getTexture", const ofTexture &getTextureReference() const) | |
void | bind (int textureLocation=0) const |
Binds the oftexture instance that the ofImage contains so that it can be used for advanced drawing. | |
void | unbind (int textureLocation=0) const |
Unbinds the ofTexture instance that the ofImage contains. | |
void | setCompression (ofTexCompression compression) |
This sets the compression level used when creating mipmaps for the ofTexture contained by the ofImage. | |
Pixel Getters | |
ofPixels_< PixelType > & | getPixels () |
Returns a raw pointer to the pixel data. | |
const ofPixels_< PixelType > & | getPixels () const |
Get a const reference to the underlying ofPixels. | |
OF_DEPRECATED_MSG ("Use getPixels() instead ", ofPixels_< PixelType > &getPixelsRef()) | |
This returns an ofPixels reference that you can use to manipulate the raw pixel data of the ofImage. | |
OF_DEPRECATED_MSG ("Use getPixels() instead ", const ofPixels_< PixelType > &getPixelsRef() const) | |
operator ofPixels_< PixelType > & () | |
ofColor_< PixelType > | getColor (int x, int y) const |
This returns the ofColor representing the pixels at the x and y position passed in. | |
ofColor_< PixelType > | getColor (int index) const |
This returns the ofColor representing the pixels at the index passed in. | |
float | getHeight () const |
Get height of image as a float. | |
float | getWidth () const |
Get width of image as a float. | |
Pixel Setters | |
void | setColor (int x, int y, const ofColor_< PixelType > &color) |
Sets the pixel at the x,y position passed in. | |
void | setColor (int index, const ofColor_< PixelType > &color) |
Sets the pixel at the given pixel buffer index. | |
void | setColor (const ofColor_< PixelType > &color) |
Sets all pixels to a color. | |
void | setFromPixels (const PixelType *pixels, int w, int h, ofImageType type, bool bOrderIsRGB=true) |
Sets the pixels of the image from an array of values. | |
void | setFromPixels (const ofPixels_< PixelType > &pixels) |
Set the pixels of the image from an ofPixels instance. | |
void | grabScreen (int x, int y, int w, int h) |
Grabs pixels from the opengl window specified by the region (x, y, w, h) and turns them into an image. | |
void | setImageType (ofImageType type) |
Set type of image to one of the following: OF_IMAGE_GRAYSCALE, OF_IMAGE_COLOR, OF_IMAGE_COLOR_ALPHA. | |
ofImageType | getImageType () const |
Modifiers | |
void | resize (int newWidth, int newHeight) |
Resizes the image to a new size (w, h); Can be used to scale up or down an image. | |
void | crop (int x, int y, int w, int h) |
This crops the image to the w,h passed in from the x,y position. | |
void | cropFrom (const ofImage_< PixelType > &otherImage, int x, int y, int w, int h) |
Replaces region in caller image specified by w,h,x,y with pixels from otherImage. | |
void | rotate90 (int rotation) |
Rotates the image by a multiple of 90 degrees. | |
void | mirror (bool vertical, bool horizontal) |
This reflects the pixels of the image across the vertical and/or horizontal axis. | |
Anchor | |
void | setAnchorPercent (float xPct, float yPct) |
Change the drawing anchor from top-left corner to a position specified by xPct and yPct. | |
void | setAnchorPoint (float x, float y) |
Changes drawing position from top-left corner to position specified by x,y. | |
void | resetAnchor () |
Removes anchor positioning. | |
Saving | |
bool | save (const of::filesystem::path &fileName, ofImageQualityType compressionLevel=OF_IMAGE_QUALITY_BEST) const |
Saves the image to the file path in fileName with the image quality specified by compressionLevel. | |
bool | save (ofBuffer &buffer, ofImageFormat imageFormat=OF_IMAGE_FORMAT_PNG, ofImageQualityType compressionLevel=OF_IMAGE_QUALITY_BEST) const |
This saves the image to the ofBuffer passed with the image quality specified by compressionLevel. | |
OF_DEPRECATED_MSG ("Use save instead", void saveImage(const std::string &fileName, ofImageQualityType compressionLevel=OF_IMAGE_QUALITY_BEST) const) | |
OF_DEPRECATED_MSG ("Use save instead", void saveImage(ofBuffer &buffer, ofImageQualityType compressionLevel=OF_IMAGE_QUALITY_BEST) const) | |
OF_DEPRECATED_MSG ("Use save instead", void saveImage(const ofFile &file, ofImageQualityType compressionLevel=OF_IMAGE_QUALITY_BEST) const) | |
Operators | |
ofImage_< PixelType > & | operator= (ofPixels_< PixelType > &pixels) |
ofImage_< PixelType > & | operator= (const ofImage_< PixelType > &mom) |
template<typename SrcType > | |
ofImage_< PixelType > & | operator= (const ofImage_< SrcType > &mom) |
ofImage_< PixelType > & | operator= (ofImage_< PixelType > &&mom) |
![]() | |
virtual | ~ofBaseImage_ () |
Destroy the ofBaseImage_. | |
![]() | |
virtual | ~ofAbstractImage () |
Destroy the ofAbstractImage. | |
![]() | |
virtual | ~ofBaseDraws () |
Destroy the abstract object. | |
![]() | |
virtual | ~ofBaseHasTexture () |
Destroy the ofBaseHasTexture. | |
![]() | |
virtual | ~ofBaseHasPixels_ () |
Destroy the ofAbstractHasPixels. | |
![]() | |
virtual | ~ofAbstractHasPixels () |
Destroy the ofAbstractHasPixels. | |
Detailed Description
class ofImage_< PixelType >
A class representing an image using memory and gpu based pixels.
- Template Parameters
-
PixelType The data type used to represent a single pixel value.
Constructor & Destructor Documentation
◆ ofImage_() [1/6]
ofImage_< PixelType >::ofImage_ | ( | ) |
◆ ofImage_() [2/6]
ofImage_< PixelType >::ofImage_ | ( | const ofPixels_< PixelType > & | pix | ) |
◆ ofImage_() [3/6]
ofImage_< PixelType >::ofImage_ | ( | const of::filesystem::path & | fileName, |
const ofImageLoadSettings & | settings = ofImageLoadSettings() |
||
) |
◆ ofImage_() [4/6]
ofImage_< PixelType >::ofImage_ | ( | const ofImage_< PixelType > & | mom | ) |
◆ ofImage_() [5/6]
ofImage_< PixelType >::ofImage_ | ( | ofImage_< PixelType > && | mom | ) |
◆ ofImage_() [6/6]
ofImage_< PixelType >::ofImage_ | ( | const ofImage_< SrcType > & | mom | ) |
◆ ~ofImage_()
Member Function Documentation
◆ allocate()
void ofImage_< PixelType >::allocate | ( | int | w, |
int | h, | ||
ofImageType | type | ||
) |
This allocates space in the ofImage, both the ofPixels and the ofTexture that the ofImage contains.
You don't need to call this before loading an image, but for when you want to allocate. space ahead of when you are going to use the image.
The types of images can be OF_IMAGE_COLOR
, OF_IMAGE_COLOR_ALPHA
or OF_IMAGE_GRAYSCALE
.
You need to call update() to update the texture after updating the pixels manually.
- Parameters
-
w Width of image to allocate. h Height of image to allocate. type The ofImageType.
◆ bind()
void ofImage_< PixelType >::bind | ( | int | textureLocation = 0 | ) | const |
Binds the oftexture instance that the ofImage contains so that it can be used for advanced drawing.
◆ clear()
void ofImage_< PixelType >::clear | ( | ) |
This clears the texture and pixels contained within the ofImage.
◆ crop()
void ofImage_< PixelType >::crop | ( | int | x, |
int | y, | ||
int | w, | ||
int | h | ||
) |
This crops the image to the w,h passed in from the x,y position.
This does an in place crop and allocates memory.
- Parameters
-
x x position of upper-left corner of region to crop. y y position of upper-left corner of region to crop. w Width of region to crop. h Height of region to crop.
◆ cropFrom()
void ofImage_< PixelType >::cropFrom | ( | const ofImage_< PixelType > & | otherImage, |
int | x, | ||
int | y, | ||
int | w, | ||
int | h | ||
) |
Replaces region in caller image specified by w,h,x,y with pixels from otherImage.
The w,h are measured from the x,y, so passing 100, 100, 300, 300 will grab a 300x300 pixel block of data starting from 100, 100.
- Parameters
-
otherImage Image to crop from. x x position of upper-left corner of region to crop. y y position of upper-left corner of region to crop. w Width of region to crop. h Height of region to crop.
◆ draw() [1/11]
|
virtual |
Draw at a position at the native size.
Native size is determined by getWidth() and getHeight().
- Parameters
-
point Draw position.
Reimplemented from ofBaseDraws.
◆ draw() [2/11]
|
virtual |
Draw at a position.
- Parameters
-
point Draw position. w Draw width. h Draw height.
Reimplemented from ofBaseDraws.
◆ draw() [3/11]
void ofImage_< PixelType >::draw | ( | const glm::vec3 & | pos | ) | const |
◆ draw() [4/11]
void ofImage_< PixelType >::draw | ( | const glm::vec3 & | pos, |
float | w, | ||
float | h | ||
) | const |
◆ draw() [5/11]
|
virtual |
Draw at a position and size specified by a rectangle.
- Parameters
-
rect Draw position and size.
Reimplemented from ofBaseDraws.
◆ draw() [6/11]
|
inlinevirtual |
Draw at a position at the native size.
Native size is determined by getWidth() and getHeight().
- Parameters
-
x Draw position on the x axis. y Draw position on the y axis.
Reimplemented from ofBaseDraws.
◆ draw() [7/11]
|
virtual |
Draw the image at it's normal size.
- Parameters
-
x Draw position on the x axis. y Draw position on the y axis.
Reimplemented from ofBaseDraws.
◆ draw() [8/11]
|
virtual |
Draw the image at a given size.
- Parameters
-
x Draw position on the x axis. y Draw position on the y axis. w Draw width. h Draw height.
Implements ofBaseDraws.
◆ draw() [9/11]
|
virtual |
Draw at a position with the specified size.
- Parameters
-
x Draw position on the x axis. y Draw position on the y axis. w Draw width. h Draw height.
Implements ofBaseDraws.
◆ draw() [10/11]
void ofImage_< PixelType >::draw | ( | float | x, |
float | y, | ||
float | z | ||
) | const |
Draw the texture at it's normal size with depth.
- Parameters
-
x Draw position on the x axis. y Draw position on the y axis. z Draw position on the z axis.
◆ draw() [11/11]
void ofImage_< PixelType >::draw | ( | float | x, |
float | y, | ||
float | z, | ||
float | w, | ||
float | h | ||
) | const |
Draw the image at a given size with depth.
- Parameters
-
x Draw position on the x axis. y Draw position on the y axis. z Draw position on the z axis. w Draw width. h Draw height.
◆ drawSubsection() [1/4]
void ofImage_< PixelType >::drawSubsection | ( | float | x, |
float | y, | ||
float | w, | ||
float | h, | ||
float | sx, | ||
float | sy | ||
) | const |
Draws a subsection of the image.
This functions like a clipping mask. Does not altering any pixel data.
- Parameters
-
x X position to draw cropped image at. y Y position to draw cropped image at. w Width of subsection to draw. h Height of subsection to draw. sx X position in image to begin cropping from. sy Y position in image to begin cropping from.
◆ drawSubsection() [2/4]
void ofImage_< PixelType >::drawSubsection | ( | float | x, |
float | y, | ||
float | w, | ||
float | h, | ||
float | sx, | ||
float | sy, | ||
float | sw, | ||
float | sh | ||
) | const |
Draws a subsection of the image.
This functions like a clipping mask. Does not altering any pixel data.
- Parameters
-
x X position to draw cropped image at. y Y position to draw cropped image at. w Width of subsection to draw. h Height of subsection to draw. sx X position in image to begin cropping from. sy Y position in image to begin cropping from. sw Source width of cropped area. sh Source height of cropped area.
◆ drawSubsection() [3/4]
void ofImage_< PixelType >::drawSubsection | ( | float | x, |
float | y, | ||
float | z, | ||
float | w, | ||
float | h, | ||
float | sx, | ||
float | sy | ||
) | const |
Draws a subsection of the image.
This functions like a clipping mask. Does not altering any pixel data.
- Parameters
-
x X position to draw cropped image at. y Y position to draw cropped image at. z Z position to draw cropped image at. w Width of subsection to draw. h Height of subsection to draw. sx X position in image to begin cropping from. sy Y position in image to begin cropping from.
◆ drawSubsection() [4/4]
void ofImage_< PixelType >::drawSubsection | ( | float | x, |
float | y, | ||
float | z, | ||
float | w, | ||
float | h, | ||
float | sx, | ||
float | sy, | ||
float | sw, | ||
float | sh | ||
) | const |
Draws a subsection of the image.
This functions like a clipping mask. Does not altering any pixel data.
- Parameters
-
x X position to draw cropped image at. y Y position to draw cropped image at. z Z position to draw cropped image at. w Width of subsection to draw. h Height of subsection to draw. sx X position in image to begin cropping from. sy Y position in image to begin cropping from. sw Source width of cropped area. sh Source height of cropped area.
◆ getColor() [1/2]
ofColor_< PixelType > ofImage_< PixelType >::getColor | ( | int | index | ) | const |
This returns the ofColor representing the pixels at the index passed in.
- Parameters
-
index index into pixel data
- Returns
- The ofColor representing the pixels at the index position passed in.
◆ getColor() [2/2]
ofColor_< PixelType > ofImage_< PixelType >::getColor | ( | int | x, |
int | y | ||
) | const |
This returns the ofColor representing the pixels at the x and y position passed in.
- Parameters
-
x x position of pixel y y position of pixel
- Returns
- The ofColor representing the pixels at the x and y position passed in.
◆ getHeight()
|
virtual |
◆ getImageType()
ofImageType ofImage_< PixelType >::getImageType | ( | ) | const |
◆ getPixels() [1/2]
Returns a raw pointer to the pixel data.
This function will give you access to a continuous block of pixels. you can grab the data and do what you like with it. If you have a grayscale image, you will have (width*height) number of pixels. Color images will have (width*height*3) number of pixels (interlaced R,G,B), and coloralpha images will have (width*height*4) number of pixels (interlaced R,G,B,A).
- Warning
- This is a raw pointer. It's up to you to get this right.
- Returns
- A raw pointer to the pixel data.
Implements ofBaseHasPixels_< T >.
◆ getPixels() [2/2]
|
virtual |
Get a const reference to the underlying ofPixels.
- Returns
- a const reference the underlying ofPixels.
Implements ofBaseHasPixels_< T >.
◆ getTexture() [1/2]
Returns a reference to the texture that the ofImage contains.
You can use this to directly manipulate the texture itself, but keep in mind that if you manipulate the texture directly, there is no simple way to copy the data from the texture back to the pixels and keep the ofImage in sync.
- Returns
- A reference to the texture that the ofImage contains.
Implements ofBaseHasTexture.
◆ getTexture() [2/2]
Returns a const reference to the texture that the ofImage contains.
- Returns
- A const reference to the texture that the ofImage contains.
Implements ofBaseHasTexture.
◆ getWidth()
|
virtual |
◆ grabScreen() [1/2]
void ofImage_< unsignedchar >::grabScreen | ( | int | x, |
int | y, | ||
int | w, | ||
int | h | ||
) |
◆ grabScreen() [2/2]
void ofImage_< PixelType >::grabScreen | ( | int | x, |
int | y, | ||
int | w, | ||
int | h | ||
) |
Grabs pixels from the opengl window specified by the region (x, y, w, h) and turns them into an image.
It resizes or allocates the ofImage if it's necessary.
- Warning
- Uses glReadPixels() which can be slow.
- Parameters
-
x x position of upper-left corner of region. y y position of upper-left corner of region. w Width of region. h Height of region.
◆ isAllocated()
|
inline |
Whether the image has been allocated either by a call to allocate or by loading pixel data into the image.
- Returns
- true if the image has been allocated.
◆ isUsingTexture()
|
virtual |
Returns whether the ofImage has a texture or not.
If the ofImage doesn't have a texture, nothing will be drawn to the screen.
- Returns
- true if the ofImage is using a texture.
Implements ofBaseHasTexture.
◆ load() [1/2]
bool ofImage_< PixelType >::load | ( | const of::filesystem::path & | fileName, |
const ofImageLoadSettings & | settings = ofImageLoadSettings() |
||
) |
Loads an image given by fileName.
- Parameters
-
fileName Program looks for image given by fileName, relative to the data folder. settings Load options
- Returns
- true if image loaded correctly.
◆ load() [2/2]
bool ofImage_< PixelType >::load | ( | const ofBuffer & | buffer, |
const ofImageLoadSettings & | settings = ofImageLoadSettings() |
||
) |
Loads an image from an ofBuffer instance created by, for instance, ofFile::readToBuffer().
This actually loads the image data into an ofPixels object and then into the texture.
◆ mirror()
void ofImage_< PixelType >::mirror | ( | bool | vertical, |
bool | horizontal | ||
) |
This reflects the pixels of the image across the vertical and/or horizontal axis.
- Parameters
-
vertical Set to true to reflect image across vertical axis. horizontal Set to true to reflect image across horizontal axis.
◆ OF_DEPRECATED_MSG() [1/11]
ofImage_< PixelType >::OF_DEPRECATED_MSG | ( | "Use getPixels() instead " | , |
const ofPixels_< PixelType > &getPixelsRef() const | |||
) |
◆ OF_DEPRECATED_MSG() [2/11]
ofImage_< PixelType >::OF_DEPRECATED_MSG | ( | "Use getPixels() instead " | , |
ofPixels_< PixelType > & | getPixelsRef() | ||
) |
This returns an ofPixels reference that you can use to manipulate the raw pixel data of the ofImage.
Make sure you call either update() after making changes to the ofPixels.
- Returns
- An ofPixels reference that you can use to manipulate the raw pixel data of the ofImage.
◆ OF_DEPRECATED_MSG() [3/11]
ofImage_< PixelType >::OF_DEPRECATED_MSG | ( | "Use getTexture" | , |
const ofTexture &getTextureReference() const | |||
) |
◆ OF_DEPRECATED_MSG() [4/11]
ofImage_< PixelType >::OF_DEPRECATED_MSG | ( | "Use getTexture" | , |
ofTexture & | getTextureReference() | ||
) |
◆ OF_DEPRECATED_MSG() [5/11]
ofImage_< PixelType >::OF_DEPRECATED_MSG | ( | "Use isAllocated()" | , |
bool | bAllocated() | ||
) |
Whether the image has been allocated either by a call to allocate or by loading pixel data into the image.
- Deprecated:
- Use isAllocated() instead
- Returns
- true if the image has been allocated.
◆ OF_DEPRECATED_MSG() [6/11]
ofImage_< PixelType >::OF_DEPRECATED_MSG | ( | "Use load instead" | , |
bool | loadImageconst ofBuffer &buffer | ||
) |
◆ OF_DEPRECATED_MSG() [7/11]
ofImage_< PixelType >::OF_DEPRECATED_MSG | ( | "Use load instead" | , |
bool | loadImageconst ofFile &file | ||
) |
◆ OF_DEPRECATED_MSG() [8/11]
ofImage_< PixelType >::OF_DEPRECATED_MSG | ( | "Use load instead" | , |
bool | loadImageconst std::string &fileName | ||
) |
◆ OF_DEPRECATED_MSG() [9/11]
ofImage_< PixelType >::OF_DEPRECATED_MSG | ( | "Use save instead" | , |
void saveImage(const ofFile &file, ofImageQualityType compressionLevel=OF_IMAGE_QUALITY_BEST) const | |||
) |
◆ OF_DEPRECATED_MSG() [10/11]
ofImage_< PixelType >::OF_DEPRECATED_MSG | ( | "Use save instead" | , |
void saveImage(const std::string &fileName, ofImageQualityType compressionLevel=OF_IMAGE_QUALITY_BEST) const | |||
) |
◆ OF_DEPRECATED_MSG() [11/11]
ofImage_< PixelType >::OF_DEPRECATED_MSG | ( | "Use save instead" | , |
void saveImage(ofBuffer &buffer, ofImageQualityType compressionLevel=OF_IMAGE_QUALITY_BEST) const | |||
) |
◆ operator ofPixels_< PixelType > &()
◆ operator=() [1/4]
ofImage_< PixelType > & ofImage_< PixelType >::operator= | ( | const ofImage_< PixelType > & | mom | ) |
◆ operator=() [2/4]
ofImage_< PixelType > & ofImage_< PixelType >::operator= | ( | const ofImage_< SrcType > & | mom | ) |
◆ operator=() [3/4]
ofImage_< PixelType > & ofImage_< PixelType >::operator= | ( | ofImage_< PixelType > && | mom | ) |
◆ operator=() [4/4]
ofImage_< PixelType > & ofImage_< PixelType >::operator= | ( | ofPixels_< PixelType > & | pixels | ) |
◆ resetAnchor()
|
virtual |
Removes anchor positioning.
Resets the anchor to (0, 0) so the image will be drawn from its upper left hand corner.
Reimplemented from ofBaseDraws.
◆ resize()
void ofImage_< PixelType >::resize | ( | int | newWidth, |
int | newHeight | ||
) |
Resizes the image to a new size (w, h); Can be used to scale up or down an image.
- Parameters
-
newWidth New width of image. newHeight New height of image.
◆ rotate90()
void ofImage_< PixelType >::rotate90 | ( | int | rotation | ) |
Rotates the image by a multiple of 90 degrees.
- Parameters
-
rotation Amount to rotate in multiples of 90. For instance, if you pass in 2, then the image will be rotated 180 degrees.
◆ save() [1/2]
bool ofImage_< PixelType >::save | ( | const of::filesystem::path & | fileName, |
ofImageQualityType | compressionLevel = OF_IMAGE_QUALITY_BEST |
||
) | const |
Saves the image to the file path in fileName with the image quality specified by compressionLevel.
- Parameters
-
fileName Saves image to this path, relative to the data folder. compressionLevel The ofImageQualityType.
◆ save() [2/2]
bool ofImage_< PixelType >::save | ( | ofBuffer & | buffer, |
ofImageFormat | imageFormat = OF_IMAGE_FORMAT_PNG , |
||
ofImageQualityType | compressionLevel = OF_IMAGE_QUALITY_BEST |
||
) | const |
◆ setAnchorPercent()
|
virtual |
Change the drawing anchor from top-left corner to a position specified by xPct and yPct.
Changes the drawing position specified by draw() from the normal top- left corner of the image to a position specified by xPct and yPct in relation to the dimensions of the image. This can be useful for aligning and centering images as well as rotating an image around its center. Note: range of xPct and yPct is 0.0 to 1.0. For xPct, 1.0 represents the width of the image. For yPct, 1.0 represents the height of the image. These values are not capped.
- Parameters
-
xPct X position of the new anchor, specified as a percent of the width of the image. yPct Y position of the new anchor, specified as a percent of the height of the image.
Reimplemented from ofBaseDraws.
◆ setAnchorPoint()
|
virtual |
Changes drawing position from top-left corner to position specified by x,y.
Changes the drawing position specified by draw() from the normal top- left corner of the image to a position specified by x and y, measured in pixels. This can be useful for aligning and centering images as well as rotating an image around its center.
- Parameters
-
x X position of the new anchor. y Y position of the new anchor.
Reimplemented from ofBaseDraws.
◆ setColor() [1/3]
void ofImage_< PixelType >::setColor | ( | const ofColor_< PixelType > & | color | ) |
Sets all pixels to a color.
- Parameters
-
color Color to set pixel to.
◆ setColor() [2/3]
void ofImage_< PixelType >::setColor | ( | int | index, |
const ofColor_< PixelType > & | color | ||
) |
Sets the pixel at the given pixel buffer index.
- Parameters
-
index Index of pixel to set. color Color to set pixel to.
◆ setColor() [3/3]
void ofImage_< PixelType >::setColor | ( | int | x, |
int | y, | ||
const ofColor_< PixelType > & | color | ||
) |
Sets the pixel at the x,y position passed in.
The ofColor type needs to match the ofImage type, i.e. ofFloatImage requires that you use ofFloatPixels.
- Parameters
-
x x position of pixel. y y position of pixel. color Color to set pixel to.
◆ setCompression()
void ofImage_< PixelType >::setCompression | ( | ofTexCompression | compression | ) |
This sets the compression level used when creating mipmaps for the ofTexture contained by the ofImage.
- Parameters
-
compression The ofTexCompression to set.
◆ setFromPixels() [1/2]
void ofImage_< PixelType >::setFromPixels | ( | const ofPixels_< PixelType > & | pixels | ) |
Set the pixels of the image from an ofPixels instance.
Set the pixels of the image from an ofPixels instance, for an ofFloatImage these need to be ofFloatPixels, for an ofImage these need to be unsigned chars.
◆ setFromPixels() [2/2]
void ofImage_< PixelType >::setFromPixels | ( | const PixelType * | pixels, |
int | w, | ||
int | h, | ||
ofImageType | type, | ||
bool | bOrderIsRGB = true |
||
) |
Sets the pixels of the image from an array of values.
Set the pixels of the image from an array of values, for an ofFloatImage these need to be floats, for an ofImage these need to be unsigned chars. The w and h values are important so that the correct dimensions are set in the image. This assumes that you're setting the pixels from 0,0 or the upper left hand corner of the image. The bOrderIsRGB flag allows you pass in pixel data that is BGR by setting bOrderIsRGB=false.
- Parameters
-
pixels Array of pixel values. w Width of image being passed in. h Height of image being passed in. type The image type can be OF_IMAGE_GRAYSCALE, OF_IMAGE_COLOR, or OF_IMAGE_COLOR_ALPHA. bOrderIsRGB Pass in pixel data that is BGR by setting bOrderIsRGB=false.
◆ setImageType()
void ofImage_< PixelType >::setImageType | ( | ofImageType | type | ) |
Set type of image to one of the following: OF_IMAGE_GRAYSCALE, OF_IMAGE_COLOR, OF_IMAGE_COLOR_ALPHA.
This does cause the image to be reallocated and the texture to be updated, so it can be an expensive operation if done frequently. Converting down, for example from color to grayscale, loses information and is a destructive change.
- Parameters
-
type The type of image, one of the following: OF_IMAGE_GRAYSCALE
,OF_IMAGE_COLOR
,OF_IMAGE_COLOR_ALPHA
◆ setUseTexture()
|
virtual |
Turns on or off the allocation and use of a texture.
- Parameters
-
bUse Allocate and use a texture or not.
Implements ofBaseHasTexture.
◆ unbind()
void ofImage_< PixelType >::unbind | ( | int | textureLocation = 0 | ) | const |
◆ update()
void ofImage_< PixelType >::update | ( | ) |
Call to ensure that changes to pixels are reflected in the ofTexture of the image.
Many of the ofImage methods call this after they change the pixels, but if you directly manipulate the pixels of the ofImage, then you should make sure to call update() before trying to draw the texture of the image to the screen.
The documentation for this class was generated from the following files:
- /Users/icq4ever/Desktop/oF0120/libs/openFrameworks/graphics/ofGraphicsBaseTypes.h
- /Users/icq4ever/Desktop/oF0120/libs/openFrameworks/graphics/ofImage.h
- /Users/icq4ever/Desktop/oF0120/libs/openFrameworks/graphics/ofImage.cpp