Euphoria
Public Member Functions | Public Attributes | List of all members
eu::core::Image Struct Reference

A simple sRGB(A) image. More...

Public Member Functions

 Image ()
 Default constructor initializes an empty (invalid) image.
 
bool is_valid () const
 Returns true if the image has valid dimensions and data.
 
void setup_with_alpha_support (int w, int h)
 Initializes the image with the specified dimensions and alpha support.
 
void make_invalid ()
 Marks the image as invalid by resetting its dimensions and clearing its data.
 
void set_pixel (int x, int y, int r, unsigned char g, unsigned char b, unsigned char a)
 Sets the color of a pixel at the specified coordinates in an image buffer.
 
void set_pixel (int x, int y, const PixelColor &color)
 Overload: Sets the color of a pixel using a PixelColor struct.
 
PixelColor get_pixel (int x, int y) const
 Gets the color of a pixel at the specified coordinates.
 

Public Attributes

int width = 0
 
int height = 0
 
std::vector< unsigned chardata
 The data is stored in row-major order, with 4 bytes per pixel RGB(A)
 

Detailed Description

A simple sRGB(A) image.

Definition at line 17 of file image.h.

Constructor & Destructor Documentation

◆ Image()

eu::core::Image::Image ( )

Default constructor initializes an empty (invalid) image.

Member Function Documentation

◆ get_pixel()

PixelColor eu::core::Image::get_pixel ( int  x,
int  y 
) const

Gets the color of a pixel at the specified coordinates.

Parameters
xThe x-coordinate of the pixel.
yThe y-coordinate of the pixel.
Returns
The color at the pixel as a PixelColor struct. If out of bounds, returns {0,0,0,0}.

◆ is_valid()

bool eu::core::Image::is_valid ( ) const

Returns true if the image has valid dimensions and data.

◆ make_invalid()

void eu::core::Image::make_invalid ( )

Marks the image as invalid by resetting its dimensions and clearing its data.

◆ set_pixel() [1/2]

void eu::core::Image::set_pixel ( int  x,
int  y,
const PixelColor color 
)

Overload: Sets the color of a pixel using a PixelColor struct.

◆ set_pixel() [2/2]

void eu::core::Image::set_pixel ( int  x,
int  y,
int  r,
unsigned char  g,
unsigned char  b,
unsigned char  a 
)

Sets the color of a pixel at the specified coordinates in an image buffer.

Parameters
xThe x-coordinate of the pixel.
yThe y-coordinate of the pixel.
rThe red color component (0-255).
gThe green color component (0-255).
bThe blue color component (0-255).
aThe alpha (transparency) component (0-255).

◆ setup_with_alpha_support()

void eu::core::Image::setup_with_alpha_support ( int  w,
int  h 
)

Initializes the image with the specified dimensions and alpha support.

Parameters
wThe width of the image.
hThe height of the image.

Member Data Documentation

◆ data

std::vector<unsigned char> eu::core::Image::data

The data is stored in row-major order, with 4 bytes per pixel RGB(A)

Definition at line 21 of file image.h.

◆ height

int eu::core::Image::height = 0

Definition at line 20 of file image.h.

◆ width

int eu::core::Image::width = 0

Definition at line 19 of file image.h.


The documentation for this struct was generated from the following file: