reference

This documentation is automatically generated from the openFrameworks source code using doxygen and refers to the most recent release, version 0.12.0.

ofImage_< PixelType > Class Template Reference

A class representing an image using memory and gpu based pixels. More...

#include <ofImage.h>

Inheritance diagram for ofImage_< PixelType >:
ofBaseImage_< PixelType > ofAbstractImage ofBaseHasPixels_< T > ofBaseDraws ofBaseHasTexture ofAbstractHasPixels

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.
 
ofTexturegetTexture ()
 Returns a reference to the texture that the ofImage contains.
 
const ofTexturegetTexture () 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)
 
- Public Member Functions inherited from ofBaseImage_< PixelType >
virtual ~ofBaseImage_ ()
 Destroy the ofBaseImage_.
 
- Public Member Functions inherited from ofAbstractImage
virtual ~ofAbstractImage ()
 Destroy the ofAbstractImage.
 
- Public Member Functions inherited from ofBaseDraws
virtual ~ofBaseDraws ()
 Destroy the abstract object.
 
- Public Member Functions inherited from ofBaseHasTexture
virtual ~ofBaseHasTexture ()
 Destroy the ofBaseHasTexture.
 
- Public Member Functions inherited from ofBaseHasPixels_< T >
virtual ~ofBaseHasPixels_ ()
 Destroy the ofAbstractHasPixels.
 
- Public Member Functions inherited from ofAbstractHasPixels
virtual ~ofAbstractHasPixels ()
 Destroy the ofAbstractHasPixels.
 

Detailed Description

template<typename PixelType>
class ofImage_< PixelType >

A class representing an image using memory and gpu based pixels.

Template Parameters
PixelTypeThe data type used to represent a single pixel value.

Constructor & Destructor Documentation

◆ ofImage_() [1/6]

template<typename PixelType >
ofImage_< PixelType >::ofImage_ ( )

◆ ofImage_() [2/6]

template<typename PixelType >
ofImage_< PixelType >::ofImage_ ( const ofPixels_< PixelType > &  pix)

◆ ofImage_() [3/6]

template<typename PixelType >
ofImage_< PixelType >::ofImage_ ( const of::filesystem::path &  fileName,
const ofImageLoadSettings settings = ofImageLoadSettings() 
)

◆ ofImage_() [4/6]

template<typename PixelType >
ofImage_< PixelType >::ofImage_ ( const ofImage_< PixelType > &  mom)

◆ ofImage_() [5/6]

template<typename PixelType >
ofImage_< PixelType >::ofImage_ ( ofImage_< PixelType > &&  mom)

◆ ofImage_() [6/6]

template<typename PixelType >
template<typename SrcType >
ofImage_< PixelType >::ofImage_ ( const ofImage_< SrcType > &  mom)

◆ ~ofImage_()

template<typename PixelType >
ofImage_< PixelType >::~ofImage_ ( )
virtual

Member Function Documentation

◆ allocate()

template<typename PixelType >
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
wWidth of image to allocate.
hHeight of image to allocate.
typeThe ofImageType.

◆ bind()

template<typename PixelType >
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()

template<typename PixelType >
void ofImage_< PixelType >::clear ( )

This clears the texture and pixels contained within the ofImage.

◆ crop()

template<typename PixelType >
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
xx position of upper-left corner of region to crop.
yy position of upper-left corner of region to crop.
wWidth of region to crop.
hHeight of region to crop.

◆ cropFrom()

template<typename PixelType >
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
otherImageImage to crop from.
xx position of upper-left corner of region to crop.
yy position of upper-left corner of region to crop.
wWidth of region to crop.
hHeight of region to crop.

◆ draw() [1/11]

template<typename PixelType >
void ofBaseDraws::draw ( const glm::vec2 &  point) const
virtual

Draw at a position at the native size.

Native size is determined by getWidth() and getHeight().

Parameters
pointDraw position.

Reimplemented from ofBaseDraws.

◆ draw() [2/11]

template<typename PixelType >
void ofBaseDraws::draw ( const glm::vec2 &  point,
float  w,
float  h 
) const
virtual

Draw at a position.

Parameters
pointDraw position.
wDraw width.
hDraw height.

Reimplemented from ofBaseDraws.

◆ draw() [3/11]

template<typename PixelType >
void ofImage_< PixelType >::draw ( const glm::vec3 &  pos) const

◆ draw() [4/11]

template<typename PixelType >
void ofImage_< PixelType >::draw ( const glm::vec3 &  pos,
float  w,
float  h 
) const

◆ draw() [5/11]

template<typename PixelType >
void ofBaseDraws::draw ( const ofRectangle rect) const
virtual

Draw at a position and size specified by a rectangle.

Parameters
rectDraw position and size.

Reimplemented from ofBaseDraws.

◆ draw() [6/11]

template<typename PixelType >
virtual void ofBaseDraws::draw ( float  x,
float  y 
) const
inlinevirtual

Draw at a position at the native size.

Native size is determined by getWidth() and getHeight().

Parameters
xDraw position on the x axis.
yDraw position on the y axis.

Reimplemented from ofBaseDraws.

◆ draw() [7/11]

template<typename PixelType >
void ofImage_< PixelType >::draw ( float  x,
float  y 
) const
virtual

Draw the image at it's normal size.

Parameters
xDraw position on the x axis.
yDraw position on the y axis.

Reimplemented from ofBaseDraws.

◆ draw() [8/11]

template<typename PixelType >
void ofImage_< PixelType >::draw ( float  x,
float  y,
float  w,
float  h 
) const
virtual

Draw the image at a given size.

Parameters
xDraw position on the x axis.
yDraw position on the y axis.
wDraw width.
hDraw height.

Implements ofBaseDraws.

◆ draw() [9/11]

template<typename PixelType >
virtual void ofBaseDraws::draw ( float  x,
float  y,
float  w,
float  h 
) const
virtual

Draw at a position with the specified size.

Parameters
xDraw position on the x axis.
yDraw position on the y axis.
wDraw width.
hDraw height.

Implements ofBaseDraws.

◆ draw() [10/11]

template<typename PixelType >
void ofImage_< PixelType >::draw ( float  x,
float  y,
float  z 
) const

Draw the texture at it's normal size with depth.

Parameters
xDraw position on the x axis.
yDraw position on the y axis.
zDraw position on the z axis.

◆ draw() [11/11]

template<typename PixelType >
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
xDraw position on the x axis.
yDraw position on the y axis.
zDraw position on the z axis.
wDraw width.
hDraw height.

◆ drawSubsection() [1/4]

template<typename PixelType >
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
xX position to draw cropped image at.
yY position to draw cropped image at.
wWidth of subsection to draw.
hHeight of subsection to draw.
sxX position in image to begin cropping from.
syY position in image to begin cropping from.

◆ drawSubsection() [2/4]

template<typename PixelType >
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
xX position to draw cropped image at.
yY position to draw cropped image at.
wWidth of subsection to draw.
hHeight of subsection to draw.
sxX position in image to begin cropping from.
syY position in image to begin cropping from.
swSource width of cropped area.
shSource height of cropped area.

◆ drawSubsection() [3/4]

template<typename PixelType >
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
xX position to draw cropped image at.
yY position to draw cropped image at.
zZ position to draw cropped image at.
wWidth of subsection to draw.
hHeight of subsection to draw.
sxX position in image to begin cropping from.
syY position in image to begin cropping from.

◆ drawSubsection() [4/4]

template<typename PixelType >
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
xX position to draw cropped image at.
yY position to draw cropped image at.
zZ position to draw cropped image at.
wWidth of subsection to draw.
hHeight of subsection to draw.
sxX position in image to begin cropping from.
syY position in image to begin cropping from.
swSource width of cropped area.
shSource height of cropped area.

◆ getColor() [1/2]

template<typename PixelType >
ofColor_< PixelType > ofImage_< PixelType >::getColor ( int  index) const

This returns the ofColor representing the pixels at the index passed in.

Parameters
indexindex into pixel data
Returns
The ofColor representing the pixels at the index position passed in.

◆ getColor() [2/2]

template<typename PixelType >
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
xx position of pixel
yy position of pixel
Returns
The ofColor representing the pixels at the x and y position passed in.

◆ getHeight()

template<typename PixelType >
float ofImage_< PixelType >::getHeight ( ) const
virtual

Get height of image as a float.

Returns
Height of image as float.

Implements ofBaseDraws.

◆ getImageType()

template<typename PixelType >
ofImageType ofImage_< PixelType >::getImageType ( ) const

◆ getPixels() [1/2]

template<typename PixelType >
ofPixels_< PixelType > & ofImage_< PixelType >::getPixels ( )
virtual

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]

template<typename PixelType >
const ofPixels_< PixelType > & ofImage_< PixelType >::getPixels ( ) const
virtual

Get a const reference to the underlying ofPixels.

Returns
a const reference the underlying ofPixels.

Implements ofBaseHasPixels_< T >.

◆ getTexture() [1/2]

template<typename PixelType >
ofTexture & ofImage_< PixelType >::getTexture ( )
virtual

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]

template<typename PixelType >
const ofTexture & ofImage_< PixelType >::getTexture ( ) const
virtual

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()

template<typename PixelType >
float ofImage_< PixelType >::getWidth ( ) const
virtual

Get width of image as a float.

Returns
Width of image as float.

Implements ofBaseDraws.

◆ grabScreen() [1/2]

void ofImage_< unsignedchar >::grabScreen ( int  x,
int  y,
int  w,
int  h 
)

◆ grabScreen() [2/2]

template<typename PixelType >
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
xx position of upper-left corner of region.
yy position of upper-left corner of region.
wWidth of region.
hHeight of region.

◆ isAllocated()

template<typename PixelType >
bool ofImage_< PixelType >::isAllocated ( ) const
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()

template<typename PixelType >
bool ofImage_< PixelType >::isUsingTexture ( ) const
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]

template<typename PixelType >
bool ofImage_< PixelType >::load ( const of::filesystem::path &  fileName,
const ofImageLoadSettings settings = ofImageLoadSettings() 
)

Loads an image given by fileName.

Parameters
fileNameProgram looks for image given by fileName, relative to the data folder.
settingsLoad options
Returns
true if image loaded correctly.

◆ load() [2/2]

template<typename PixelType >
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()

template<typename PixelType >
void ofImage_< PixelType >::mirror ( bool  vertical,
bool  horizontal 
)

This reflects the pixels of the image across the vertical and/or horizontal axis.

Parameters
verticalSet to true to reflect image across vertical axis.
horizontalSet to true to reflect image across horizontal axis.

◆ OF_DEPRECATED_MSG() [1/11]

template<typename PixelType >
ofImage_< PixelType >::OF_DEPRECATED_MSG ( "Use getPixels() instead "  ,
const ofPixels_< PixelType > &getPixelsRef() const   
)

◆ OF_DEPRECATED_MSG() [2/11]

template<typename PixelType >
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]

template<typename PixelType >
ofImage_< PixelType >::OF_DEPRECATED_MSG ( "Use getTexture"  ,
const ofTexture &getTextureReference() const   
)

◆ OF_DEPRECATED_MSG() [4/11]

template<typename PixelType >
ofImage_< PixelType >::OF_DEPRECATED_MSG ( "Use getTexture"  ,
ofTexture getTextureReference() 
)

◆ OF_DEPRECATED_MSG() [5/11]

template<typename PixelType >
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]

template<typename PixelType >
ofImage_< PixelType >::OF_DEPRECATED_MSG ( "Use load instead"  ,
bool   loadImageconst ofBuffer &buffer 
)

◆ OF_DEPRECATED_MSG() [7/11]

template<typename PixelType >
ofImage_< PixelType >::OF_DEPRECATED_MSG ( "Use load instead"  ,
bool   loadImageconst ofFile &file 
)

◆ OF_DEPRECATED_MSG() [8/11]

template<typename PixelType >
ofImage_< PixelType >::OF_DEPRECATED_MSG ( "Use load instead"  ,
bool   loadImageconst std::string &fileName 
)

◆ OF_DEPRECATED_MSG() [9/11]

template<typename PixelType >
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]

template<typename PixelType >
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]

template<typename PixelType >
ofImage_< PixelType >::OF_DEPRECATED_MSG ( "Use save instead"  ,
void saveImage(ofBuffer &buffer, ofImageQualityType compressionLevel=OF_IMAGE_QUALITY_BEST) const   
)

◆ operator ofPixels_< PixelType > &()

template<typename PixelType >
ofImage_< PixelType >::operator ofPixels_< PixelType > & ( )

◆ operator=() [1/4]

template<typename PixelType >
ofImage_< PixelType > & ofImage_< PixelType >::operator= ( const ofImage_< PixelType > &  mom)

◆ operator=() [2/4]

template<typename PixelType >
template<typename SrcType >
ofImage_< PixelType > & ofImage_< PixelType >::operator= ( const ofImage_< SrcType > &  mom)

◆ operator=() [3/4]

template<typename PixelType >
ofImage_< PixelType > & ofImage_< PixelType >::operator= ( ofImage_< PixelType > &&  mom)

◆ operator=() [4/4]

template<typename PixelType >
ofImage_< PixelType > & ofImage_< PixelType >::operator= ( ofPixels_< PixelType > &  pixels)

◆ resetAnchor()

template<typename PixelType >
void ofImage_< PixelType >::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()

template<typename PixelType >
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
newWidthNew width of image.
newHeightNew height of image.

◆ rotate90()

template<typename PixelType >
void ofImage_< PixelType >::rotate90 ( int  rotation)

Rotates the image by a multiple of 90 degrees.

Parameters
rotationAmount to rotate in multiples of 90. For instance, if you pass in 2, then the image will be rotated 180 degrees.

◆ save() [1/2]

template<typename PixelType >
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
fileNameSaves image to this path, relative to the data folder.
compressionLevelThe ofImageQualityType.

◆ save() [2/2]

template<typename PixelType >
bool ofImage_< PixelType >::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.

Parameters
bufferofBuffer to save image to.
compressionLevelThe ofImageQualityType.

◆ setAnchorPercent()

template<typename PixelType >
void ofImage_< PixelType >::setAnchorPercent ( float  xPct,
float  yPct 
)
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
xPctX position of the new anchor, specified as a percent of the width of the image.
yPctY position of the new anchor, specified as a percent of the height of the image.

Reimplemented from ofBaseDraws.

◆ setAnchorPoint()

template<typename PixelType >
void ofImage_< PixelType >::setAnchorPoint ( float  x,
float  y 
)
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
xX position of the new anchor.
yY position of the new anchor.

Reimplemented from ofBaseDraws.

◆ setColor() [1/3]

template<typename PixelType >
void ofImage_< PixelType >::setColor ( const ofColor_< PixelType > &  color)

Sets all pixels to a color.

Parameters
colorColor to set pixel to.

◆ setColor() [2/3]

template<typename PixelType >
void ofImage_< PixelType >::setColor ( int  index,
const ofColor_< PixelType > &  color 
)

Sets the pixel at the given pixel buffer index.

Parameters
indexIndex of pixel to set.
colorColor to set pixel to.

◆ setColor() [3/3]

template<typename PixelType >
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
xx position of pixel.
yy position of pixel.
colorColor to set pixel to.

◆ setCompression()

template<typename PixelType >
void ofImage_< PixelType >::setCompression ( ofTexCompression  compression)

This sets the compression level used when creating mipmaps for the ofTexture contained by the ofImage.

Parameters
compressionThe ofTexCompression to set.

◆ setFromPixels() [1/2]

template<typename PixelType >
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]

template<typename PixelType >
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
pixelsArray of pixel values.
wWidth of image being passed in.
hHeight of image being passed in.
typeThe image type can be OF_IMAGE_GRAYSCALE, OF_IMAGE_COLOR, or OF_IMAGE_COLOR_ALPHA.
bOrderIsRGBPass in pixel data that is BGR by setting bOrderIsRGB=false.

◆ setImageType()

template<typename PixelType >
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
typeThe type of image, one of the following: OF_IMAGE_GRAYSCALE, OF_IMAGE_COLOR, OF_IMAGE_COLOR_ALPHA

◆ setUseTexture()

template<typename PixelType >
void ofImage_< PixelType >::setUseTexture ( bool  bUse)
virtual

Turns on or off the allocation and use of a texture.

Parameters
bUseAllocate and use a texture or not.

Implements ofBaseHasTexture.

◆ unbind()

template<typename PixelType >
void ofImage_< PixelType >::unbind ( int  textureLocation = 0) const

Unbinds the ofTexture instance that the ofImage contains.

Call this after you call bind().

◆ update()

template<typename PixelType >
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