Euphoria
image.h
Go to the documentation of this file.
1#pragma once
2
3namespace eu::core
4{
5
6
9struct PixelColor {
10 unsigned char r;
11 unsigned char g;
12 unsigned char b;
13 unsigned char a;
14};
15
17struct Image
18{
19 int width = 0;
20 int height = 0;
21 std::vector<unsigned char> data;
22
25
27 bool is_valid() const;
28
32 void setup_with_alpha_support(int w, int h);
33
36
44 void set_pixel(int x, int y, int r, unsigned char g, unsigned char b, unsigned char a);
45
47 void set_pixel(int x, int y, const PixelColor& color);
48
53 PixelColor get_pixel(int x, int y) const;
54};
55
62void paste_image(Image* dst, int dst_x, int dst_y, const Image& src);
63
64}
void paste_image(Image *dst, int dst_x, int dst_y, const Image &src)
Copies pixel data from a source image to a destination image at specified coordinates.
A (inclusive) range between two values.
Definition range.h:19
A simple sRGB(A) image.
Definition image.h:18
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.
PixelColor get_pixel(int x, int y) const
Gets the color of a pixel at the specified coordinates.
std::vector< unsigned char > data
The data is stored in row-major order, with 4 bytes per pixel RGB(A)
Definition image.h:21
void setup_with_alpha_support(int w, int h)
Initializes the image with the specified dimensions and alpha support.
bool is_valid() const
Returns true if the image has valid dimensions and data.
void set_pixel(int x, int y, const PixelColor &color)
Overload: Sets the color of a pixel using a PixelColor struct.
Image()
Default constructor initializes an empty (invalid) image.
void make_invalid()
Marks the image as invalid by resetting its dimensions and clearing its data.
A simple integer sRGBA color.
Definition image.h:9
unsigned char b
Definition image.h:12
unsigned char a
Definition image.h:13
unsigned char g
Definition image.h:11
unsigned char r
Definition image.h:10