class methods
- ofImage_()
- ~ofImage_()
- allocate()
- bind()
- clear()
- crop()
- cropFrom()
- draw()
- drawSubsection()
- getColor()
- getHeight()
- getImageType()
- getPixels()
- getTexture()
- getWidth()
- grabScreen()
- isAllocated()
- isUsingTexture()
- load()
- mirror()
- operator=()
- resetAnchor()
- resize()
- rotate90()
- save()
- setAnchorPercent()
- setAnchorPoint()
- setColor()
- setCompression()
- setFromPixels()
- setImageType()
- setUseTexture()
- unbind()
- update()
variables
global functions
The ofImage is a useful object for loading, saving and drawing images in openFrameworks. ofImage is a convenient class that lets you both draw images to the screen and manipulate their pixel data. The ofImage allows you to load an image from disk, manipulate the pixels, and create an OpenGL texture that you can display and manipulate on the graphics card. Loading a file into the ofImage allocates an ofPixels object and creates the ofTexture to display the pixels.
ofImage uses a library called "freeImage" under the hood.
Simple example to load & draw an image : In setup :
ofImage myImg; // declare a new ofImage image (rather in ofApp.h)
myImg.load("anImage.png"); // first load image, assuming it's in bin/data folder
In draw :
myImg.draw(0, 0); // draw the image in the draw loop
Documentation from code comments
A class representing an image using memory and gpu based pixels. \tparam PixelType The data type used to represent a single pixel value.
ofImage_()
ofImage_::ofImage_()
This creates an ofImage but doesn't allocate any memory for it, so you can't use the image immediately after creating it.
Documentation from code comments
\name Image Construction {
ofImage_(...)
ofImage_::ofImage_(const filesystem::path &fileName, const ofImageLoadSettings &settings)
This creates an ofImage from a file which can be a local string or a URL, allocating space for the pixels, and copying the pixels into the texture that the ofImage instance contains.
ofImage img("http://www.openframeworks.cc/wp-content/themes/ofw/images/ofw-logo.gif");
or
ofImage img("anImage.png"); // assumes this is in bin/data
ofImage_(...)
ofImage_::ofImage_(const ofImage_< PixelType > &mom)
ofImage_(...)
ofImage_::ofImage_(const ofImage_< SrcType > &mom)
ofImage_(...)
ofImage_::ofImage_(const ofPixels_< PixelType > &pix)
ofImage_(...)
ofImage_::ofImage_(ofImage_< PixelType > &&mom)
allocate(...)
void ofImage_::allocate(int w, int h, ofImageType type)
This allocates space in the ofImage, both the ofPixels and the ofTexture that the ofImage contains.
img.allocate(640, 480, OF_IMAGE_COLOR);
int i = 0;
while ( i < img.getPixels().size() ) {
img.getPixels()[i] = abs(sin( float(i) / 18.f)) * 255.f; // make some op-art
i++;
}
img.update();
It allocates an image of width (w) and height (h). The type can be of three types: OF_IMAGE_GRAYSCALE, OF_IMAGE_COLOR, OF_IMAGE_COLOR_ALPHA. 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.
Documentation from code comments
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_::bind(int textureLocation=0)
This binds the ofTexture instance that the ofImage contains so that it can be used for advanced drawing
void ofApp::setup() {
img.allocate(256, 256, OF_IMAGE_COLOR);
int i = 0;
while ( i < img.getPixels().size() ) {
img.getPixels()[i] = abs(sin( float(i) / 18.f )) * 255.f;
i++;
}
img.update();
mesh.setMode(OF_PRIMITIVE_TRIANGLE_STRIP);
mesh.addVertex(ofVec2f(10, 10));
mesh.addVertex(ofVec2f(410, 10));
mesh.addVertex(ofVec2f(410, 410));
mesh.addVertex(ofVec2f(10, 410));
mesh.addVertex(ofVec2f(10, 10));
mesh.addTexCoord(ofVec2f(0, 0));
mesh.addTexCoord(ofVec2f(256, 0));
mesh.addTexCoord(ofVec2f(256, 256));
mesh.addTexCoord(ofVec2f(0, 256));
mesh.addTexCoord(ofVec2f(0, 0));
}
void ofApp::draw(){
ofBackground(255, 255, 255); // background white
img.bind();
mesh.draw();
img.unbind();
}
Documentation from code comments
Binds the oftexture instance that the ofImage contains so that it can be used for advanced drawing.
crop(...)
void ofImage_::crop(int x, int y, int w, int h)
This crops the image to the w,h passed in from the x,y position. The image has to be loaded before it's cropped.
ofImage myImg;
myImg.load("anImage.png");
myImg.crop(0, 0, 1024, 1024); // crop a 1024px x 1024px square
Documentation from code comments
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_::cropFrom(const ofImage_< PixelType > &otherImage, int x, int y, int w, int h)
This crops another image into the image the cropFrom is being called on to the w,h passed in from the x,y position. 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.
ofImage img1, img2;
img1.loadImage("anImage.png");
img2.cropFrom(img1, 100, 100, 300, 300);
Documentation from code comments
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(...)
void ofImage_::draw(float x, float y)
Draws the ofImage into the x,y location using the default height and width of the image.
// in setup
ofImage myImg;
myImg.load("anImage.png"); // first load image, then draw it
// in draw
myImg.draw(0, 0); // draw at upper-left corner position (O px x 0 px)
Documentation from code comments
Draw the image at it's normal size.
Parameters:
x Draw position on the x axis.
y Draw position on the y axis.
draw(...)
void ofImage_::draw(float x, float y, float w, float h)
Draws the ofImage into the x,y location and with the width and height, with any attendant scaling that may occur from fitting the ofImage into the width and height.
// in setup
ofImage myImg;
myImg.load("anImage.png"); // first load image, then draw it
// in draw
myImg.draw(0, 0, 1024, 1024); // draw at upper-left corner position (O px x 0 px), 1024 px of width & height
Documentation from code comments
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.
draw(...)
void ofImage_::draw(float x, float y, float z)
Draws the ofImage into the x,y,z location with the default height and width. You should ensure that you turn on depth sorting using glEnable(GL_DEPTH) before trying to draw multiple objects into z-space.
// in setup
ofImage myImg;
myImg.load("anImage.png"); // first load image, then draw it
// in draw
myImg.draw(0, 0, 10); // x, y, z
Documentation from code comments
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(...)
void ofImage_::draw(float x, float y, float z, float w, float h)
Draws the ofImage into the x,y,z location and with the width and height, with any attendant scaling that may occur from fitting the ofImage into the width and height. You should ensure that you turn on depth sorting using glEnable(GL_DEPTH) before trying to draw multiple objects into z-space.
// in setup
ofImage myImg;
myImg.load("anImage.png"); // first load image, then draw it
// in draw
myImg.draw(0, 0, 10, 1024, 1024); // x, y, z, with, height
Documentation from code comments
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(...)
void ofImage_::drawSubsection(float x, float y, float w, float h, float sx, float sy)
Draws a subsection of the image (functions like a clipping mask) without altering any pixel data. (x,y) are the position to draw the cropped image at, (w,h) is the size of the subsection to draw and the size to crop (these can be different using the function below with sw,sh) and (sx,sy) are the source pixel positions in the image to begin cropping from.
// crop the image from the mouse position to 100x100 pixels and draw it at 0,0
img.drawSubsection(0, 0, 100, 100, mouseX, mouseY);
An example showing how to use drawSubsection can be found in of_release > examples > graphics > imageSubsectionExample
Documentation from code comments
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(...)
void ofImage_::drawSubsection(float x, float y, float w, float h, float sx, float sy, float sw, float sh)
(sw,sh) indicate the source width and height of the cropped area and the (w,h) indicate the size to draw the cropped area at.
Documentation from code comments
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(...)
void ofImage_::drawSubsection(float x, float y, float z, float w, float h, float sx, float sy)
Documentation from code comments
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(...)
void ofImage_::drawSubsection(float x, float y, float z, float w, float h, float sx, float sy, float sw, float sh)
Documentation from code comments
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(...)
ofColor_< PixelType > ofImage_::getColor(int index)
getColor(...)
ofColor_< PixelType > ofImage_::getColor(int x, int y)
This returns the ofColor representing the pixels at the x and y position passed in.
getHeight()
float ofImage_::getHeight()
Returns the height of the image in pixels.
Documentation from code comments
Get height of image as a float.
Returns: Height of image as float.
getPixels()
ofPixels_< PixelType > & ofImage_::getPixels()
This 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).
getTexture()
ofTexture & ofImage_::getTexture()
Documentation from code comments
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.
getTexture()
const ofTexture & ofImage_::getTexture()
getWidth()
float ofImage_::getWidth()
Returns the width of the image in pixels.
Documentation from code comments
Get width of image as a float.
Returns: Width of image as float.
grabScreen(...)
void ofImage_::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.
Documentation from code comments
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()
bool ofImage_::isAllocated()
Returns whether the image has been allocated either by a call to allocate or by loading pixel data into the image.
Documentation from code comments
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()
bool ofImage_::isUsingTexture()
Returns whether the ofImage has a texture or not. If not, nothing will be drawn to the screen if the draw() method is called.
load(...)
bool ofImage_::load(const filesystem::path &fileName, const ofImageLoadSettings &settings)
Loads an image given by file name, assuming it's in the bin/data folder. An image has to be loaded first, then you'll have to call draw() function to draw it on the screen.
ofImage myImg;
myImg.load("anImage.png"); // put your image in bin/data folder
The image can also be loaded with settings (JPG image only). For more information look at ofImageLoadSettings module documentation">ofImageLoadSettings documentation
ofImageLoadSettings settings;
settings.accurate = true;
// Then load the image with these settings
ofImage myImg;
myImg.load("anImage.png", settings);
Documentation from code comments
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(...)
bool ofImage_::load(const ofBuffer &buffer, const ofImageLoadSettings &settings)
mirror(...)
void ofImage_::mirror(bool vertical, bool horizontal)
This reflects the pixels of the image across the vertical and/or horizontal axis.
Documentation from code comments
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.
operator=(...)
ofImage_< PixelType > & ofImage_::operator=(const ofImage_< PixelType > &mom)
operator=(...)
ofImage_< PixelType > & ofImage_::operator=(const ofImage_< SrcType > &mom)
operator=(...)
ofImage_< PixelType > & ofImage_::operator=(ofPixels_< PixelType > &pixels)
Allows you to set an image to pixels. This resizes the image to the size of the ofPixels and reallocates all the of the data within the image.
Documentation from code comments
} \name Operators {
resetAnchor()
void ofImage_::resetAnchor()
This removes any anchor positioning, meaning that the ofImage will be draw with the upper left hand corner at the point passed into draw().
Documentation from code comments
Removes anchor positioning.
Resets the anchor to (0, 0) so the image will be drawn from its upper left hand corner.
resize(...)
void ofImage_::resize(int newWidth, int newHeight)
Resizes the image to a new size (w, h); Can be used to scale up or down an image.
ofImage myImg;
myImg.load("anImage.png");
myImg.resize(300, 300); // 300px width x 300px height
Documentation from code comments
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_::rotate90(int rotation)
Rotates the image by a multiple of 90 degrees, for instance, if you pass in 2, then the image will be rotated 180 degrees.
Documentation from code comments
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(...)
bool ofImage_::save(const filesystem::path &fileName, ofImageQualityType compressionLevel=OF_IMAGE_QUALITY_BEST)
Documentation from code comments
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(...)
bool ofImage_::save(ofBuffer &buffer, ofImageFormat imageFormat=OF_IMAGE_FORMAT_PNG, ofImageQualityType compressionLevel=OF_IMAGE_QUALITY_BEST)
setAnchorPercent(...)
void ofImage_::setAnchorPercent(float xPct, float 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.
For example to draw an image so that its center is at 100, 100:
myImage.setAnchorPercent(0.5, 0.5);
myImage.draw(100, 100);
To rotate an image around its center at 100, 100:
ofPushMatrix();
ofTranslate(100, 100, 0);
ofRotate(45);
myImage.setAnchorPercent(0.5, 0.5);
myImage.draw(0, 0);
ofPopMatrix();
To align the right side of an image with the right edge of the window:
myImage.setAnchorPercent(1.0, 0.0);
myImage.draw(ofGetWidth(), 0);
Documentation from code comments
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.
setAnchorPoint(...)
void ofImage_::setAnchorPoint(float x, float 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.
Note: see also setAnchorPercent() if you want to specify the anchor as a percentage of the image size.
For example to draw an image so that its center is at 100, 100:
myImage.setAnchorPoint(myImage.getWidth()/2, myImage.getHeight()/2);
myImage.draw(100, 100);
To rotate an image around its center at 100, 100:
ofPushMatrix();
ofTranslate(100, 100, 0);
ofRotate(45);
myImage.setAnchorPoint(myImage.getWidth()/2, myImage.getHeight()/2);
myImage.draw(0, 0);
ofPopMatrix();
To align the right side of an image with the right edge of the window:
myImage.setAnchorPoint(myImage.getWidth(), 0.0);
myImage.draw(ofGetWidth(), 0);
Documentation from code comments
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.
setColor(...)
void ofImage_::setColor(const ofColor_< PixelType > &color)
Documentation from code comments
Sets all pixels to a color.
Parameters:
color Color to set pixel to.
setColor(...)
void ofImage_::setColor(int index, const ofColor_< PixelType > &color)
Documentation from code comments
Sets the pixel at the given pixel buffer index
Parameters:
index Index of pixel to set.
color Color to set pixel to.
setColor(...)
void ofImage_::setColor(int x, int y, const ofColor_< PixelType > &color)
setCompression(...)
void ofImage_::setCompression(ofTexCompression compression)
This sets the compression level used when creating mipmaps for the ofTexture contained by the ofImage. This is quite different than the ofImageQualityType image quality parameter used in saveImage(). The different texture compression levels are: OF_COMPRESS_NONE, OF_COMPRESS_SRGB, OF_COMPRESS_ARB
Documentation from code comments
This sets the compression level used when creating mipmaps for the ofTexture contained by the ofImage.
Parameters:
compression The ofTexCompression to set.
setFromPixels(...)
void ofImage_::setFromPixels(const PixelType *pixels, int w, int h, ofImageType type, bool bOrderIsRGB=true)
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.
Copies in the pixel data from the 'pixels' array. Specify the corresponding width and height of the image you are passing in with 'w' and 'h'. The image type can be OF_IMAGE_GRAYSCALE, OF_IMAGE_COLOR, or OF_IMAGE_COLOR_ALPHA.
Note: that your array has to be at least as big as [ width * height * bytes per pixel ].
If you have a grayscale image, you will have (widthheight) number of pixels. Color images will have (widthheight3) number of pixels (interlaced R,G,B), and coloralpha images will have (widthheight*4) number of pixels (interlaced R,G,B,A).
Note: You do not need to call allocate() before calling setFromPixels() as setFromPixels() re-allocates itself if needed.
Documentation from code comments
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.
setFromPixels(...)
void ofImage_::setFromPixels(const ofPixels_< PixelType > &pixels)
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. 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.
setImageType(...)
void ofImage_::setImageType(ofImageType type)
Set the 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.
For example, you can load in a color image, and convert it to grayscale:
myImage.loadImage("somethingColor.jpg");
myImage.setImageType(OF_IMAGE_GRAYSCALE); // now I am grayscale;
Documentation from code comments
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(...)
void ofImage_::setUseTexture(bool bUse)
If you set the ofImage to not use a texture it will contain the pixels of the image but cannot be drawn to the screen without copying its data into an ofTexture instance.
This turns on or off the allocation and use of a texture. any time you change the image (loading, resizing, converting the type), ofImage will upload data to an opengl texture. It may not be necessary, though, and it could be that you need to save memory on the graphics card, or that you don't need to draw this image on the screen. You can call this even before you load an image in to OF:
myImage.setUseTexture(false);
myImage.loadImage("blah.gif");
Since in the majority of cases, ofImages will be loaded in and drawn onscreen, the default is set to use a texture.
Documentation from code comments
Turns on or off the allocation and use of a texture.
Parameters:
bUse Allocate and use a texture or not.
unbind(...)
void ofImage_::unbind(int textureLocation=0)
update()
void ofImage_::update()
This method should be called after you update the pixels of the image and want to ensure that the changes to the 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.
int bpp
int ofImage_::bpp
int type
int ofImage_::type
ofLoadImage(...)
bool ofLoadImage(ofShortPixels &pix, const ofBuffer &buffer, const ofImageLoadSettings &settings)
ofLoadImage(...)
bool ofLoadImage(ofFloatPixels &pix, const ofBuffer &buffer, const ofImageLoadSettings &settings)
ofLoadImage(...)
bool ofLoadImage(ofPixels &pix, const ofBuffer &buffer, const ofImageLoadSettings &settings)
ofLoadImage(...)
bool ofLoadImage(ofShortPixels &pix, const filesystem::path &path, const ofImageLoadSettings &settings)
ofLoadImage(...)
bool ofLoadImage(ofFloatPixels &pix, const filesystem::path &path, const ofImageLoadSettings &settings)
ofLoadImage(...)
bool ofLoadImage(ofPixels &pix, const filesystem::path &path, const ofImageLoadSettings &settings)
Documentation from code comments
\todo Needs documentation.
ofLoadImage(...)
bool ofLoadImage(ofTexture &tex, const ofBuffer &buffer, const ofImageLoadSettings &settings)
ofLoadImage(...)
bool ofLoadImage(ofTexture &tex, const filesystem::path &path, const ofImageLoadSettings &settings)
Documentation from code comments
\todo Needs documentation.
ofSaveImage(...)
bool ofSaveImage(const ofShortPixels &pix, ofBuffer &buffer, ofImageFormat format=OF_IMAGE_FORMAT_PNG, ofImageQualityType qualityLevel=OF_IMAGE_QUALITY_BEST)
ofSaveImage(...)
bool ofSaveImage(const ofFloatPixels &pix, ofBuffer &buffer, ofImageFormat format=OF_IMAGE_FORMAT_PNG, ofImageQualityType qualityLevel=OF_IMAGE_QUALITY_BEST)
ofSaveImage(...)
bool ofSaveImage(const ofPixels &pix, ofBuffer &buffer, ofImageFormat format=OF_IMAGE_FORMAT_PNG, ofImageQualityType qualityLevel=OF_IMAGE_QUALITY_BEST)
ofSaveImage(...)
bool ofSaveImage(const ofShortPixels &pix, const filesystem::path &path, ofImageQualityType qualityLevel=OF_IMAGE_QUALITY_BEST)
Documentation from code comments
\todo Needs documentation.
ofSaveImage(...)
bool ofSaveImage(const ofFloatPixels &pix, const filesystem::path &path, ofImageQualityType qualityLevel=OF_IMAGE_QUALITY_BEST)
Documentation from code comments
\todo Needs documentation.
ofSaveImage(...)
bool ofSaveImage(const ofPixels &pix, const filesystem::path &path, ofImageQualityType qualityLevel=OF_IMAGE_QUALITY_BEST)
Documentation from code comments
\todo Needs documentation.
ofToString(...)
string ofToString(const T &v)
Documentation from code comments
\section String Conversion Convert a value to a string.
ofToString does its best to convert any value to a string. If the data type implements a stream << operator, then it will be converted.
Example:
std::string str = "framerate is ";
str += ofToString(ofGetFrameRate()) + " fps";
// The string now containes something like "framerate is 60 fps".
\tparam T The data type of the value to convert to a string.
Parameters:
value The value to convert to a string.
Returns: A string representing the value or an empty string on failure.
Last updated Saturday, 17 August 2024 20:46:26 UTC - 99bfb4fd7929e233b87b05758efc36f91505592e
If you have any doubt about the usage of this module you can ask in the forum.
If you want to contribute better documentation or start documenting this section you can do so here
If you find anything wrong with this docs you can report any error by opening an issue