Class image#
Defined in File image.h
Nested Relationships#
Nested Types#
Class Documentation#
-
class image#
Class used to represent an image.
A class to represent an image, which can be created from a file, a buffer and provided by a window. It provides tools to save and compare images.
Constructors
-
image()#
Default/copy/move constructors/operators.
-
~image()#
Default/copy/move constructors/operators.
Operators
-
bool operator==(const image &reference) const#
Comparison operators, uses image::compare with a threshold of 0.
-
bool operator!=(const image &reference) const#
Comparison operators, uses image::compare with a threshold of 0.
Resolution
-
unsigned int getWidth() const#
Set/Get image resolution.
- Deprecated:
{ setResolution is deprecated, use the appropriate constructor }
-
unsigned int getHeight() const#
Set/Get image resolution.
- Deprecated:
{ setResolution is deprecated, use the appropriate constructor }
- F3D_DEPRECATED image & setResolution (unsigned int width, unsigned int height)
Set/Get image resolution.
- Deprecated:
{ setResolution is deprecated, use the appropriate constructor }
Channel Count
-
unsigned int getChannelCount() const#
Set/Get image channel count.
- Deprecated:
{ setChannelCount is deprecated, use the appropriate constructor }
- F3D_DEPRECATED image & setChannelCount (unsigned int dim)
Set/Get image channel count.
- Deprecated:
{ setChannelCount is deprecated, use the appropriate constructor }
Buffer Data
-
image &setContent(void *buffer)#
Set/Get image buffer data. Its size is expected to be
width * height * channelCount * typeSize
.- Deprecated:
{ setData and getData are deprecated, use setContent and getContent instead }
-
void *getContent() const#
Set/Get image buffer data. Its size is expected to be
width * height * channelCount * typeSize
.- Deprecated:
{ setData and getData are deprecated, use setContent and getContent instead }
- F3D_DEPRECATED image & setData (unsigned char *buffer)
Set/Get image buffer data. Its size is expected to be
width * height * channelCount * typeSize
.- Deprecated:
{ setData and getData are deprecated, use setContent and getContent instead }
- F3D_DEPRECATED unsigned char * getData () const
Set/Get image buffer data. Its size is expected to be
width * height * channelCount * typeSize
.- Deprecated:
{ setData and getData are deprecated, use setContent and getContent instead }
Public Types
-
enum class SaveFormat : unsigned char#
Enumeration of supported export formats#
PNG: Supports channel size up to 2 bytes JPG: Supports channel size of 1 byte TIF: Supports channel size up to 4 bytes BMP: Supports channel size of 1 byte
Values:
-
enumerator PNG#
-
enumerator JPG#
-
enumerator TIF#
-
enumerator BMP#
-
enumerator PNG#
Public Functions
-
explicit image(const std::string &path)#
Create an image from file, the following formats are supported: PNG, PNM, TIFF, BMP, HDR, JPEG, GESigna, MetaImage, TGA. EXR files are also supported if the associated module is built. Throw an image::read_exception in case of failure.
-
image(unsigned int width, unsigned int height, unsigned int channelCount, ChannelType type = ChannelType::BYTE)#
Create an image from a given width, height, and channel count. A channel type can also be given. Default is BYTE.
-
ChannelType getChannelType() const#
Get image channel type. throw an image::read_exception if the type is unknown.
-
unsigned int getChannelTypeSize() const#
Get image channel type size in bytes.
-
bool compare(const image &reference, double threshold, image &diff, double &error) const#
Compare current image to a reference using the provided threshold. If the comparison fails, ie. error is higher than the threshold, this outputs the resulting diff and error and return false, return true otherwise. The error is based on the pixel value and accumulated over neighbors pixels. 0: Pixel perfect comparison. 50: Visually indistinguishable. 100: Small visible difference. 300: Comparable images.
-
void save(const std::string &path, SaveFormat format = SaveFormat::PNG) const#
Save an image to a file in the specified format. Default format is PNG if not specified.
-
image()#