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.h File Reference
#include "ofTexture.h"
#include "ofGLBaseTypes.h"
#include "ofGraphicsConstants.h"
#include "ofGLUtils.h"
#include "ofConstants.h"

Go to the source code of this file.

Classes

struct  ofImageLoadSettings
 
class  ofImage_< PixelType >
 A class representing an image using memory and gpu based pixels. More...
 

Typedefs

typedef ofPixels_< unsigned char > ofPixels
 
typedef ofPixels_< float > ofFloatPixels
 
typedef ofPixels_< unsigned short > ofShortPixels
 
Variants
typedef ofImage_< unsigned char > ofImage
 
typedef ofImage_< float > ofFloatImage
 
typedef ofImage_< unsigned short > ofShortImage
 

Enumerations

enum  ofImageQualityType {
  OF_IMAGE_QUALITY_BEST , OF_IMAGE_QUALITY_HIGH , OF_IMAGE_QUALITY_MEDIUM , OF_IMAGE_QUALITY_LOW ,
  OF_IMAGE_QUALITY_WORST
}
 Used for controlling the save quality of JPEGs. More...
 
enum  ofImageFormat {
  OF_IMAGE_FORMAT_BMP = 0 , OF_IMAGE_FORMAT_ICO = 1 , OF_IMAGE_FORMAT_JPEG = 2 , OF_IMAGE_FORMAT_JNG = 3 ,
  OF_IMAGE_FORMAT_KOALA = 4 , OF_IMAGE_FORMAT_LBM = 5 , OF_IMAGE_FORMAT_IFF = OF_IMAGE_FORMAT_LBM , OF_IMAGE_FORMAT_MNG = 6 ,
  OF_IMAGE_FORMAT_PBM = 7 , OF_IMAGE_FORMAT_PBMRAW = 8 , OF_IMAGE_FORMAT_PCD = 9 , OF_IMAGE_FORMAT_PCX = 10 ,
  OF_IMAGE_FORMAT_PGM = 11 , OF_IMAGE_FORMAT_PGMRAW = 12 , OF_IMAGE_FORMAT_PNG = 13 , OF_IMAGE_FORMAT_PPM = 14 ,
  OF_IMAGE_FORMAT_PPMRAW = 15 , OF_IMAGE_FORMAT_RAS = 16 , OF_IMAGE_FORMAT_TARGA = 17 , OF_IMAGE_FORMAT_TIFF = 18 ,
  OF_IMAGE_FORMAT_WBMP = 19 , OF_IMAGE_FORMAT_PSD = 20 , OF_IMAGE_FORMAT_CUT = 21 , OF_IMAGE_FORMAT_XBM = 22 ,
  OF_IMAGE_FORMAT_XPM = 23 , OF_IMAGE_FORMAT_DDS = 24 , OF_IMAGE_FORMAT_GIF = 25 , OF_IMAGE_FORMAT_HDR = 26 ,
  OF_IMAGE_FORMAT_FAXG3 = 27 , OF_IMAGE_FORMAT_SGI = 28 , OF_IMAGE_FORMAT_EXR = 29 , OF_IMAGE_FORMAT_J2K = 30 ,
  OF_IMAGE_FORMAT_JP2 = 31 , OF_IMAGE_FORMAT_PFM = 32 , OF_IMAGE_FORMAT_PICT = 33 , OF_IMAGE_FORMAT_RAW = 34
}
 

Functions

std::string ofImageFormatExtension (ofImageFormat format)
 
bool ofLoadImage (ofPixels &pix, const of::filesystem::path &path, const ofImageLoadSettings &settings=ofImageLoadSettings())
 
bool ofLoadImage (ofPixels &pix, const ofBuffer &buffer, const ofImageLoadSettings &settings=ofImageLoadSettings())
 
bool ofLoadImage (ofFloatPixels &pix, const of::filesystem::path &path, const ofImageLoadSettings &settings=ofImageLoadSettings())
 
bool ofLoadImage (ofFloatPixels &pix, const ofBuffer &buffer, const ofImageLoadSettings &settings=ofImageLoadSettings())
 
bool ofLoadImage (ofShortPixels &pix, const of::filesystem::path &path, const ofImageLoadSettings &settings=ofImageLoadSettings())
 
bool ofLoadImage (ofShortPixels &pix, const ofBuffer &buffer, const ofImageLoadSettings &settings=ofImageLoadSettings())
 
bool ofLoadImage (ofTexture &tex, const of::filesystem::path &path, const ofImageLoadSettings &settings=ofImageLoadSettings())
 
bool ofLoadImage (ofTexture &tex, const ofBuffer &buffer, const ofImageLoadSettings &settings=ofImageLoadSettings())
 
bool ofSaveImage (const ofPixels &pix, const of::filesystem::path &path, ofImageQualityType qualityLevel=OF_IMAGE_QUALITY_BEST)
 
bool ofSaveImage (const ofPixels &pix, ofBuffer &buffer, ofImageFormat format=OF_IMAGE_FORMAT_PNG, ofImageQualityType qualityLevel=OF_IMAGE_QUALITY_BEST)
 
bool ofSaveImage (const ofFloatPixels &pix, const of::filesystem::path &path, ofImageQualityType qualityLevel=OF_IMAGE_QUALITY_BEST)
 
bool ofSaveImage (const ofFloatPixels &pix, ofBuffer &buffer, ofImageFormat format=OF_IMAGE_FORMAT_PNG, ofImageQualityType qualityLevel=OF_IMAGE_QUALITY_BEST)
 
bool ofSaveImage (const ofShortPixels &pix, const of::filesystem::path &path, ofImageQualityType qualityLevel=OF_IMAGE_QUALITY_BEST)
 
bool ofSaveImage (const ofShortPixels &pix, ofBuffer &buffer, ofImageFormat format=OF_IMAGE_FORMAT_PNG, ofImageQualityType qualityLevel=OF_IMAGE_QUALITY_BEST)
 
void ofCloseFreeImage ()
 Deallocates FreeImage resources.
 
template<typename T >
std::string ofToString (const T &v)
 Convert a value to a string.
 
template<>
std::string ofToString (const ofImageType &imgType)
 

Detailed Description

ofImage is used 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.

Typedef Documentation

◆ ofFloatImage

typedef ofImage_<float> ofFloatImage

◆ ofFloatPixels

typedef ofPixels_<float> ofFloatPixels

◆ ofImage

typedef ofImage_<unsigned char> ofImage

◆ ofPixels

typedef ofPixels_<unsigned char> ofPixels

◆ ofShortImage

typedef ofImage_<unsigned short> ofShortImage

◆ ofShortPixels

typedef ofPixels_<unsigned short> ofShortPixels

Enumeration Type Documentation

◆ ofImageFormat

Todo:
Needs documentation.
Enumerator
OF_IMAGE_FORMAT_BMP 
OF_IMAGE_FORMAT_ICO 
OF_IMAGE_FORMAT_JPEG 
OF_IMAGE_FORMAT_JNG 
OF_IMAGE_FORMAT_KOALA 
OF_IMAGE_FORMAT_LBM 
OF_IMAGE_FORMAT_IFF 
OF_IMAGE_FORMAT_MNG 
OF_IMAGE_FORMAT_PBM 
OF_IMAGE_FORMAT_PBMRAW 
OF_IMAGE_FORMAT_PCD 
OF_IMAGE_FORMAT_PCX 
OF_IMAGE_FORMAT_PGM 
OF_IMAGE_FORMAT_PGMRAW 
OF_IMAGE_FORMAT_PNG 
OF_IMAGE_FORMAT_PPM 
OF_IMAGE_FORMAT_PPMRAW 
OF_IMAGE_FORMAT_RAS 
OF_IMAGE_FORMAT_TARGA 
OF_IMAGE_FORMAT_TIFF 
OF_IMAGE_FORMAT_WBMP 
OF_IMAGE_FORMAT_PSD 
OF_IMAGE_FORMAT_CUT 
OF_IMAGE_FORMAT_XBM 
OF_IMAGE_FORMAT_XPM 
OF_IMAGE_FORMAT_DDS 
OF_IMAGE_FORMAT_GIF 
OF_IMAGE_FORMAT_HDR 
OF_IMAGE_FORMAT_FAXG3 
OF_IMAGE_FORMAT_SGI 
OF_IMAGE_FORMAT_EXR 
OF_IMAGE_FORMAT_J2K 
OF_IMAGE_FORMAT_JP2 
OF_IMAGE_FORMAT_PFM 
OF_IMAGE_FORMAT_PICT 
OF_IMAGE_FORMAT_RAW 

◆ ofImageQualityType

Used for controlling the save quality of JPEGs.

These values are directly mapped to FreeImage's JPEG quality flags.

See also
http://freeimage.sourceforge.net/fnet/html/E77CD483.htm
Enumerator
OF_IMAGE_QUALITY_BEST 

Equivalent to FreeImage's JPEG_QUALITYSUPERB (100:1 ratio)

OF_IMAGE_QUALITY_HIGH 

Equivalent to FreeImage's JPEG_QUALITYGOOD (75:1 ratio)

OF_IMAGE_QUALITY_MEDIUM 

Equivalent to FreeImage's JPEG_QUALITYNORMAL (50:1 ratio)

OF_IMAGE_QUALITY_LOW 

Equivalent to FreeImage's JPEG_QUALITYAVERAGE (25:1 ratio)

OF_IMAGE_QUALITY_WORST 

Equivalent to FreeImage's JPEG_QUALITYBAD (10:1 ratio)

Function Documentation

◆ ofCloseFreeImage()

void ofCloseFreeImage ( )

Deallocates FreeImage resources.

Used internally during shutdown.

◆ ofImageFormatExtension()

std::string ofImageFormatExtension ( ofImageFormat  format)
inline

◆ ofLoadImage() [1/8]

bool ofLoadImage ( ofFloatPixels pix,
const of::filesystem::path &  path,
const ofImageLoadSettings settings = ofImageLoadSettings() 
)

◆ ofLoadImage() [2/8]

bool ofLoadImage ( ofFloatPixels pix,
const ofBuffer buffer,
const ofImageLoadSettings settings = ofImageLoadSettings() 
)

◆ ofLoadImage() [3/8]

bool ofLoadImage ( ofPixels pix,
const of::filesystem::path &  path,
const ofImageLoadSettings settings = ofImageLoadSettings() 
)
Todo:
Needs documentation.

◆ ofLoadImage() [4/8]

bool ofLoadImage ( ofPixels pix,
const ofBuffer buffer,
const ofImageLoadSettings settings = ofImageLoadSettings() 
)

◆ ofLoadImage() [5/8]

bool ofLoadImage ( ofShortPixels pix,
const of::filesystem::path &  path,
const ofImageLoadSettings settings = ofImageLoadSettings() 
)

◆ ofLoadImage() [6/8]

bool ofLoadImage ( ofShortPixels pix,
const ofBuffer buffer,
const ofImageLoadSettings settings = ofImageLoadSettings() 
)

◆ ofLoadImage() [7/8]

bool ofLoadImage ( ofTexture tex,
const of::filesystem::path &  path,
const ofImageLoadSettings settings = ofImageLoadSettings() 
)
Todo:
Needs documentation.

◆ ofLoadImage() [8/8]

bool ofLoadImage ( ofTexture tex,
const ofBuffer buffer,
const ofImageLoadSettings settings = ofImageLoadSettings() 
)

◆ ofSaveImage() [1/6]

bool ofSaveImage ( const ofFloatPixels pix,
const of::filesystem::path &  path,
ofImageQualityType  qualityLevel = OF_IMAGE_QUALITY_BEST 
)
Todo:
Needs documentation.

◆ ofSaveImage() [2/6]

bool ofSaveImage ( const ofFloatPixels pix,
ofBuffer buffer,
ofImageFormat  format = OF_IMAGE_FORMAT_PNG,
ofImageQualityType  qualityLevel = OF_IMAGE_QUALITY_BEST 
)

◆ ofSaveImage() [3/6]

bool ofSaveImage ( const ofPixels pix,
const of::filesystem::path &  path,
ofImageQualityType  qualityLevel = OF_IMAGE_QUALITY_BEST 
)
Todo:
Needs documentation.

◆ ofSaveImage() [4/6]

bool ofSaveImage ( const ofPixels pix,
ofBuffer buffer,
ofImageFormat  format = OF_IMAGE_FORMAT_PNG,
ofImageQualityType  qualityLevel = OF_IMAGE_QUALITY_BEST 
)

◆ ofSaveImage() [5/6]

bool ofSaveImage ( const ofShortPixels pix,
const of::filesystem::path &  path,
ofImageQualityType  qualityLevel = OF_IMAGE_QUALITY_BEST 
)
Todo:
Needs documentation.

◆ ofSaveImage() [6/6]

bool ofSaveImage ( const ofShortPixels pix,
ofBuffer buffer,
ofImageFormat  format = OF_IMAGE_FORMAT_PNG,
ofImageQualityType  qualityLevel = OF_IMAGE_QUALITY_BEST 
)

◆ ofToString() [1/2]

template<>
std::string ofToString ( const ofImageType imgType)

◆ ofToString() [2/2]

template<typename T >
std::string ofToString ( const T &  value)

Convert a value to a string.

Manipulation

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 contains something like "framerate is 60 fps".
float ofGetFrameRate()
Definition ofEvents.cpp:20
std::string ofToString(const T &)
Convert a value to a string.
Definition ofUtils.h:657
Template Parameters
TThe data type of the value to convert to a string.
Parameters
valueThe value to convert to a string.
Returns
A string representing the value or an empty string on failure.