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
Go to the documentation of this file.
43};
83};
141bool ofLoadImage(ofPixels & pix, const of::filesystem::path& path, const ofImageLoadSettings &settings = ofImageLoadSettings());
142bool ofLoadImage(ofPixels & pix, const ofBuffer & buffer, const ofImageLoadSettings &settings = ofImageLoadSettings());
143bool ofLoadImage(ofFloatPixels & pix, const of::filesystem::path& path, const ofImageLoadSettings &settings = ofImageLoadSettings());
144bool ofLoadImage(ofFloatPixels & pix, const ofBuffer & buffer, const ofImageLoadSettings &settings = ofImageLoadSettings());
145bool ofLoadImage(ofShortPixels & pix, const of::filesystem::path& path, const ofImageLoadSettings &settings = ofImageLoadSettings());
146bool ofLoadImage(ofShortPixels & pix, const ofBuffer & buffer, const ofImageLoadSettings &settings = ofImageLoadSettings());
149bool ofLoadImage(ofTexture & tex, const of::filesystem::path& path, const ofImageLoadSettings &settings = ofImageLoadSettings());
150bool ofLoadImage(ofTexture & tex, const ofBuffer & buffer, const ofImageLoadSettings &settings = ofImageLoadSettings());
153bool ofSaveImage(const ofPixels & pix, const of::filesystem::path& path, ofImageQualityType qualityLevel = OF_IMAGE_QUALITY_BEST);
154bool ofSaveImage(const ofPixels & pix, ofBuffer & buffer, ofImageFormat format = OF_IMAGE_FORMAT_PNG, ofImageQualityType qualityLevel = OF_IMAGE_QUALITY_BEST);
157bool ofSaveImage(const ofFloatPixels & pix, const of::filesystem::path& path, ofImageQualityType qualityLevel = OF_IMAGE_QUALITY_BEST);
158bool ofSaveImage(const ofFloatPixels & pix, ofBuffer & buffer, ofImageFormat format = OF_IMAGE_FORMAT_PNG, ofImageQualityType qualityLevel = OF_IMAGE_QUALITY_BEST);
161bool ofSaveImage(const ofShortPixels & pix, const of::filesystem::path& path, ofImageQualityType qualityLevel = OF_IMAGE_QUALITY_BEST);
162bool ofSaveImage(const ofShortPixels & pix, ofBuffer & buffer, ofImageFormat format = OF_IMAGE_FORMAT_PNG, ofImageQualityType qualityLevel = OF_IMAGE_QUALITY_BEST);
180 ofImage_(const of::filesystem::path & fileName, const ofImageLoadSettings &settings = ofImageLoadSettings());
224 bool load(const of::filesystem::path& fileName, const ofImageLoadSettings &settings = ofImageLoadSettings());
231 bool load(const ofBuffer & buffer, const ofImageLoadSettings &settings = ofImageLoadSettings());
319 void drawSubsection(float x, float y, float w, float h, float sx, float sy, float sw, float sh) const;
335 void drawSubsection(float x, float y, float z, float w, float h, float sx, float sy, float sw, float sh) const;
417 OF_DEPRECATED_MSG("Use getPixels() instead ", const ofPixels_<PixelType> & getPixelsRef() const);
481 void setFromPixels(const PixelType * pixels, int w, int h, ofImageType type, bool bOrderIsRGB = true);
606 bool save(const of::filesystem::path & fileName, ofImageQualityType compressionLevel = OF_IMAGE_QUALITY_BEST) const;
613 bool save(ofBuffer & buffer, ofImageFormat imageFormat = OF_IMAGE_FORMAT_PNG, ofImageQualityType compressionLevel = OF_IMAGE_QUALITY_BEST) const;
615 OF_DEPRECATED_MSG("Use save instead",void saveImage(const std::string& fileName, ofImageQualityType compressionLevel = OF_IMAGE_QUALITY_BEST) const);
616 OF_DEPRECATED_MSG("Use save instead",void saveImage(ofBuffer & buffer, ofImageQualityType compressionLevel = OF_IMAGE_QUALITY_BEST) const);
617 OF_DEPRECATED_MSG("Use save instead",void saveImage(const ofFile & file, ofImageQualityType compressionLevel = OF_IMAGE_QUALITY_BEST) const);
virtual void draw(float x, float y) const
Draw at a position at the native size.
Definition ofGraphicsBaseTypes.h:150
Definition ofFileUtils.h:15
Definition ofFileUtils.h:472
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.
Definition ofImage.cpp:1127
void drawSubsection(float x, float y, float w, float h, float sx, float sy) const
Draws a subsection of the image.
Definition ofImage.cpp:840
void rotate90(int rotation)
Rotates the image by a multiple of 90 degrees.
Definition ofImage.cpp:1147
bool isAllocated() const
Whether the image has been allocated either by a call to allocate or by loading pixel data into the i...
Definition ofImage.h:208
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.
Definition ofImage.cpp:751
OF_DEPRECATED_MSG("Use getPixels() instead ", const ofPixels_< PixelType > &getPixelsRef() const)
OF_DEPRECATED_MSG("Use getTexture", const ofTexture &getTextureReference() const)
void setColor(int x, int y, const ofColor_< PixelType > &color)
Sets the pixel at the x,y position passed in.
Definition ofImage.cpp:993
bool isUsingTexture() const
Returns whether the ofImage has a texture or not.
Definition ofImage.cpp:1061
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.
Definition ofImage.cpp:1137
OF_DEPRECATED_MSG("Use load instead", bool loadImage(const std::string &fileName))
OF_DEPRECATED_MSG("Use save instead", void saveImage(const std::string &fileName, ofImageQualityType compressionLevel=OF_IMAGE_QUALITY_BEST) const)
void clear()
This clears the texture and pixels contained within the ofImage.
Definition ofImage.cpp:895
ofColor_< PixelType > getColor(int x, int y) const
This returns the ofColor representing the pixels at the x and y position passed in.
Definition ofImage.cpp:981
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.
Definition ofImage.cpp:1011
void unbind(int textureLocation=0) const
Unbinds the ofTexture instance that the ofImage contains.
Definition ofImage.cpp:974
void draw(float x, float y) const
Draw the image at it's normal size.
Definition ofImage.cpp:802
void mirror(bool vertical, bool horizontal)
This reflects the pixels of the image across the vertical and/or horizontal axis.
Definition ofImage.cpp:1154
ofPixels_< PixelType > & getPixels()
Returns a raw pointer to the pixel data.
Definition ofImage.cpp:912
float getHeight() const
Get height of image as a float.
Definition ofImage.cpp:1244
ofImage_< PixelType > & operator=(ofPixels_< PixelType > &pixels)
Definition ofImage.cpp:1031
OF_DEPRECATED_MSG("Use load instead", bool loadImage(const ofBuffer &buffer))
void setAnchorPercent(float xPct, float yPct)
Change the drawing anchor from top-left corner to a position specified by xPct and yPct.
Definition ofImage.cpp:784
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.
void setUseTexture(bool bUse)
Turns on or off the allocation and use of a texture.
Definition ofImage.cpp:1055
OF_DEPRECATED_MSG("Use getTexture", ofTexture &getTextureReference())
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 i...
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.
Definition ofImage.cpp:1117
OF_DEPRECATED_MSG("Use save instead", void saveImage(const ofFile &file, ofImageQualityType compressionLevel=OF_IMAGE_QUALITY_BEST) const)
ofTexture & getTexture()
Returns a reference to the texture that the ofImage contains.
Definition ofImage.cpp:942
void bind(int textureLocation=0) const
Binds the oftexture instance that the ofImage contains so that it can be used for advanced drawing.
Definition ofImage.cpp:967
void setImageType(ofImageType type)
Set type of image to one of the following: OF_IMAGE_GRAYSCALE, OF_IMAGE_COLOR, OF_IMAGE_COLOR_ALPHA.
Definition ofImage.cpp:1104
void setCompression(ofTexCompression compression)
This sets the compression level used when creating mipmaps for the ofTexture contained by the ofImage...
Definition ofImage.cpp:1258
void update()
Call to ensure that changes to pixels are reflected in the ofTexture of the image.
Definition ofImage.cpp:1038
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...
Definition ofImage.cpp:1097
OF_DEPRECATED_MSG("Use save instead", void saveImage(ofBuffer &buffer, ofImageQualityType compressionLevel=OF_IMAGE_QUALITY_BEST) const)
bool load(const of::filesystem::path &fileName, const ofImageLoadSettings &settings=ofImageLoadSettings())
Loads an image given by fileName.
Definition ofImage.cpp:705
OF_DEPRECATED_MSG("Use load instead", bool loadImage(const ofFile &file))
void setAnchorPoint(float x, float y)
Changes drawing position from top-left corner to position specified by x,y.
Definition ofImage.cpp:790
virtual void allocate(const ofTextureData &textureData)
Allocate the texture using the given settings.
Definition ofTexture.cpp:408
bool isAllocated() const
Determine whether the texture has been allocated.
Definition ofTexture.cpp:256
ofImageType
Used to represent the available channel types in ofImage.
Definition ofGraphicsConstants.h:154
bool ofSaveImage(const ofPixels &pix, const of::filesystem::path &path, ofImageQualityType qualityLevel=OF_IMAGE_QUALITY_BEST)
Definition ofImage.cpp:440
bool ofLoadImage(ofPixels &pix, const of::filesystem::path &path, const ofImageLoadSettings &settings=ofImageLoadSettings())
Definition ofImage.cpp:302
ofImageQualityType
Used for controlling the save quality of JPEGs.
Definition ofImage.h:32
@ OF_IMAGE_QUALITY_HIGH
Equivalent to FreeImage's JPEG_QUALITYGOOD (75:1 ratio)
Definition ofImage.h:36
@ OF_IMAGE_QUALITY_BEST
Equivalent to FreeImage's JPEG_QUALITYSUPERB (100:1 ratio)
Definition ofImage.h:34
@ OF_IMAGE_QUALITY_MEDIUM
Equivalent to FreeImage's JPEG_QUALITYNORMAL (50:1 ratio)
Definition ofImage.h:38
@ OF_IMAGE_QUALITY_LOW
Equivalent to FreeImage's JPEG_QUALITYAVERAGE (25:1 ratio)
Definition ofImage.h:40
@ OF_IMAGE_QUALITY_WORST
Equivalent to FreeImage's JPEG_QUALITYBAD (10:1 ratio)
Definition ofImage.h:42
std::string ofImageFormatExtension(ofImageFormat format)
Definition ofImage.h:85
Definition ofImage.h:128