Represents an image composed of pixels with values in [0,1]. Provide image loading/saving utilities, for both LDR and HDR images.
More...
#include <Image.hpp>
|
| Image ()=default |
|
| Image (unsigned int awidth, unsigned int aheight, unsigned int acomponents, float value=0.0f) |
|
glm::vec4 & | rgba (int x, int y) |
|
glm::vec3 & | rgb (int x, int y) |
|
float & | r (int x, int y) |
|
const glm::vec4 & | rgba (int x, int y) const |
|
const glm::vec3 & | rgb (int x, int y) const |
|
const float & | r (int x, int y) const |
|
glm::vec3 | rgbl (float x, float y) const |
|
glm::vec3 | rgbn (float x, float y) const |
|
glm::vec4 | rgbal (float x, float y) const |
|
int | load (const std::string &path, unsigned int channels, bool flip, bool externalFile) |
|
int | save (const std::string &path, Save options) const |
|
Image & | operator= (const Image &)=delete |
|
| Image (const Image &)=delete |
|
Image & | operator= (Image &&)=default |
|
| Image (Image &&)=default |
|
|
static bool | isFloat (const std::string &path) |
|
|
unsigned int | width = 0 |
| The width of the image.
|
|
unsigned int | height = 0 |
| The height of the image.
|
|
unsigned int | components = 0 |
| Number of components/channels.
|
|
std::vector< float > | pixels |
| The pixels values of the image.
|
|
|
int | saveAsLDR (const std::string &path, Save options) const |
|
int | saveAsHDR (const std::string &path, Save options) const |
|
int | loadLDR (const std::string &path, unsigned int channels, bool flip, bool externalFile) |
|
int | loadHDR (const std::string &path, unsigned int channels, bool flip, bool externalFile) |
|
Represents an image composed of pixels with values in [0,1]. Provide image loading/saving utilities, for both LDR and HDR images.
◆ Save
Options for saving an image to disk.
Enumerator |
---|
NONE | No specific options.
|
FLIP | Flip the image vertically.
|
IGNORE_ALPHA | Force alpha to 1.
|
SRGB_LDR | Apply gamma sRGB correction before saving, ignored for HDR images.
|
◆ Image() [1/4]
◆ Image() [2/4]
Image::Image |
( |
unsigned int |
awidth, |
|
|
unsigned int |
aheight, |
|
|
unsigned int |
acomponents, |
|
|
float |
value = 0.0f |
|
) |
| |
Constructor that allocates an empty image with the given dimensions.
- Parameters
-
awidth | the width of the image |
aheight | the height of the image |
acomponents | the number of components of the image |
value | the default value to use |
◆ Image() [3/4]
Image::Image |
( |
const Image & |
| ) |
|
|
delete |
Copy constructor (disabled).
◆ Image() [4/4]
Image::Image |
( |
Image && |
| ) |
|
|
default |
◆ isFloat()
bool Image::isFloat |
( |
const std::string & |
path | ) |
|
|
static |
Query if a path points to an image loaded in floating point, based on the extension.
- Parameters
-
path | the path to the image |
- Returns
- true if the file is loaded as a floating point numbers image
- Note
- Extensions checked: .exr
◆ load()
int Image::load |
( |
const std::string & |
path, |
|
|
unsigned int |
channels, |
|
|
bool |
flip, |
|
|
bool |
externalFile |
|
) |
| |
Load an image from disk. Will contain the image raw data as [0,1] floats.
- Parameters
-
path | the path to the image |
channels | the number of channels to load from the image |
flip | should the image be vertically flipped |
externalFile | if true, skip the resources manager and load directly from disk |
- Returns
- a success/error flag
◆ loadHDR()
int Image::loadHDR |
( |
const std::string & |
path, |
|
|
unsigned int |
channels, |
|
|
bool |
flip, |
|
|
bool |
externalFile |
|
) |
| |
|
private |
Load a HDR image from disk using tiny_exr, assuming 3-channels.
- Parameters
-
path | the path to the image |
channels | will contain the number of channels of the loaded image |
flip | should the image be vertically flipped |
externalFile | if true, skip the resources manager and load directly from disk |
- Returns
- a success/error flag
◆ loadLDR()
int Image::loadLDR |
( |
const std::string & |
path, |
|
|
unsigned int |
channels, |
|
|
bool |
flip, |
|
|
bool |
externalFile |
|
) |
| |
|
private |
Load a LDR image from disk using stb_image.
- Parameters
-
path | the path to the image |
channels | the number of channels to load from the image |
flip | should the image be vertically flipped |
externalFile | if true, skip the resources manager and load directly from disk |
- Returns
- a success/error flag
◆ operator=() [1/2]
Copy assignment operator (disabled).
- Returns
- a reference to the object assigned to
◆ operator=() [2/2]
Move assignment operator .
- Returns
- a reference to the object assigned to
◆ r() [1/2]
float & Image::r |
( |
int |
x, |
|
|
int |
y |
|
) |
| |
Accessor to the red/first component of a pixel
- Parameters
-
x | horizontal coordinate |
y | vertical coordinate |
- Returns
- reference to the given pixel first component
- Warning
- no access or component check is done
◆ r() [2/2]
const float & Image::r |
( |
int |
x, |
|
|
int |
y |
|
) |
| const |
Const accessor to the red/first component of a pixel
- Parameters
-
x | horizontal coordinate |
y | vertical coordinate |
- Returns
- reference to the given pixel first component
- Warning
- no access or component check is done
◆ rgb() [1/2]
glm::vec3 & Image::rgb |
( |
int |
x, |
|
|
int |
y |
|
) |
| |
Accessor to the RGB part of a pixel
- Parameters
-
x | horizontal coordinate |
y | vertical coordinate |
- Returns
- reference to the given pixel
- Warning
- no access or component check is done
◆ rgb() [2/2]
const glm::vec3 & Image::rgb |
( |
int |
x, |
|
|
int |
y |
|
) |
| const |
Const accessor to the RGB part of a pixel
- Parameters
-
x | horizontal coordinate |
y | vertical coordinate |
- Returns
- reference to the given pixel
- Warning
- no access or component check is done
◆ rgba() [1/2]
glm::vec4 & Image::rgba |
( |
int |
x, |
|
|
int |
y |
|
) |
| |
Accessor to a RGBA pixel
- Parameters
-
x | horizontal coordinate |
y | vertical coordinate |
- Returns
- reference to the given pixel
- Warning
- no access or component check is done
◆ rgba() [2/2]
const glm::vec4 & Image::rgba |
( |
int |
x, |
|
|
int |
y |
|
) |
| const |
Const accessor to a RGBA pixel
- Parameters
-
x | horizontal coordinate |
y | vertical coordinate |
- Returns
- reference to the given pixel
- Warning
- no access or component check is done
◆ rgbal()
glm::vec4 Image::rgbal |
( |
float |
x, |
|
|
float |
y |
|
) |
| const |
Bilinear UV image read.
- Parameters
-
x | horizontal unit float coordinate |
y | vertical unit float coordinate |
- Returns
- the bilinearly interpolated color value
- Note
- Wrapping is applied on both axis.
◆ rgbl()
glm::vec3 Image::rgbl |
( |
float |
x, |
|
|
float |
y |
|
) |
| const |
Bilinear UV image read.
- Parameters
-
x | horizontal unit float coordinate |
y | vertical unit float coordinate |
- Returns
- the bilinearly interpolated color value
- Note
- Wrapping is applied on both axis.
◆ rgbn()
glm::vec3 Image::rgbn |
( |
float |
x, |
|
|
float |
y |
|
) |
| const |
Nearest-neighbour UV image read.
- Parameters
-
x | horizontal unit float coordinate |
y | vertical unit float coordinate |
- Returns
- the color of the nearest pixel
- Note
- Wrapping is applied on both axis.
◆ save()
int Image::save |
( |
const std::string & |
path, |
|
|
Image::Save |
options |
|
) |
| const |
Save an image to disk, either in HDR (when using "exr" extension) or in LDR (any other extension).
- Parameters
-
path | the path to the image |
options | options to use when writing the image on disk |
- Returns
- a success/error flag
◆ saveAsHDR()
int Image::saveAsHDR |
( |
const std::string & |
path, |
|
|
Image::Save |
options |
|
) |
| const |
|
private |
Save a HDR image to disk using tiny_exr.
- Parameters
-
path | the path to the image |
options | options to use when writing the image on disk |
- Returns
- a success/error flag
◆ saveAsLDR()
int Image::saveAsLDR |
( |
const std::string & |
path, |
|
|
Image::Save |
options |
|
) |
| const |
|
private |
Save a LDR image to disk using stb_image.
- Parameters
-
path | the path to the image |
options | options to use when writing the image on disk |
- Returns
- a success/error flag
The documentation for this class was generated from the following files:
- src/engine/resources/Image.hpp
- src/engine/resources/Image.cpp