|
Visual Computing Library
devel
|
A class for representing and manipulating 2D images. More...
#include <vclib/space/core/image.h>
Public Types | |
| enum class | ColorSpace { UNKNOWN , LINEAR , SRGB } |
Public Member Functions | |
| ColorSpace & | colorSpace () |
| Gets a reference to the image's color space property. | |
| ColorSpace | colorSpace () const |
| Gets the color space of the image. | |
| const unsigned char * | data () const |
| Provides direct, read-only access to the raw pixel data. | |
| void | deserialize (std::istream &is) |
| Deserializes image data from an input stream. | |
| int | height () const |
| Gets the height of the image in pixels. | |
| Image () | |
| Default constructor. Creates an empty, null image. | |
| Image (Array2< uint > &&img) | |
| Constructs an Image by moving an existing Array2 of pixels. | |
| Image (const Array2< uint > &img) | |
| Constructs an Image by copying an existing Array2 of pixels. | |
| Image (const void *data, uint w, uint h, bool yFlip=false, Color::Format format=Color::Format::ABGR) | |
| Constructs an Image from a raw pixel buffer. | |
| bool | isNull () const |
| Checks if the image is null or empty. | |
| void | mirror (bool horizontal=false, bool vertical=true) |
| Flips the image horizontally and/or vertically in-place. | |
| Color | pixel (uint i, uint j) const |
| Retrieves the color of a specific pixel. | |
| void | serialize (std::ostream &os) const |
| Serializes the image data to an output stream. | |
| std::size_t | sizeInBytes () const |
| Calculates the total size of the image data in bytes. | |
| int | width () const |
| Gets the width of the image in pixels. | |
Private Attributes | |
| ColorSpace | mColorSpace = ColorSpace::UNKNOWN |
| Array2< uint > | mImg |
A class for representing and manipulating 2D images.
The Image class stores pixel data in a 2D array of 32-bit unsigned integers. Each pixel is internally stored in ABGR (Alpha, Blue, Green, Red) format, with 8 bits per channel.
The class provides constructors to load images from raw data buffers with various pixel formats, automatically converting them to the internal ABGR representation. It also includes functionalities for color space management, transformations like mirroring, and serialization.
|
inline |
Constructs an Image from a raw pixel buffer.
This constructor initializes the image with data from a provided buffer. It can handle various input pixel formats and optionally flip the image vertically.
| [in] | data | A pointer to the raw pixel data. |
| [in] | w | The width of the image in pixels. |
| [in] | h | The height of the image in pixels. |
| [in] | yFlip | If true, the image is flipped vertically after loading. This is often needed for compatibility with graphics APIs like OpenGL where the origin is at the bottom-left. |
| [in] | format | The pixel format of the input data buffer. The data will be converted from this format to the internal ABGR format. |
Constructs an Image by copying an existing Array2 of pixels.
| [in] | img | The Array2 containing pixel data in ABGR format. |
|
inline |
Constructs an Image by moving an existing Array2 of pixels.
| [in] | img | The Array2 to move, containing pixel data in ABGR format. |
|
inline |
Gets a reference to the image's color space property.
|
inline |
Gets the color space of the image.
Provides direct, read-only access to the raw pixel data.
|
inline |
Deserializes image data from an input stream.
| [in] | is | The input stream to read from. |
|
inline |
Gets the height of the image in pixels.
|
inline |
Checks if the image is null or empty.
Flips the image horizontally and/or vertically in-place.
| [in] | horizontal | If true, flips the image along the vertical axis (mirror). |
| [in] | vertical | If true, flips the image along the horizontal axis (upside-down). Defaults to true. |
|
inline |
Retrieves the color of a specific pixel.
| [in] | i | The row index (Y-coordinate) of the pixel. |
| [in] | j | The column index (X-coordinate) of the pixel. |
|
inline |
Serializes the image data to an output stream.
| [in] | os | The output stream to write to. |
|
inline |
Calculates the total size of the image data in bytes.
|
inline |
Gets the width of the image in pixels.