116 void set_pixel(
int x,
int y, uint8_t r, uint8_t g, uint8_t b, uint8_t a);
125 void get_pixel(
int x,
int y, uint8_t &r, uint8_t &g, uint8_t &b, uint8_t &a)
const;
132 void clear(uint8_t r, uint8_t g, uint8_t b, uint8_t a);
142 void clear_float(
float r,
float g,
float b,
float a);
188 void crop(
int x,
int y,
int w,
int h);
224 void grow(
int top,
int bottom,
int left,
int right,
const Color &background);
249 void scale(
int new_width,
int new_height);
294 bool write_ppm(
const std::string &filename)
const;
304 bool write_bmp(
const std::string &filename)
const;
320 bool write_tga(
const std::string &filename,
bool use24bit =
false)
const;
337 bool write_png(
const std::string &filename)
const;
411 int ncol = 0,
int nrow = 0,
413 const Color &background =
Color(1.0f, 1.0f, 1.0f, 1.0f));
429 const Color &background =
Color(1.0f, 1.0f, 1.0f, 1.0f)) {
430 return grid_arrange(images,
static_cast<int>(images.size()), 1,
431 fit_mode, background);
448 const Color &background =
Color(1.0f, 1.0f, 1.0f, 1.0f)) {
449 return grid_arrange(images, 1,
static_cast<int>(images.size()),
450 fit_mode, background);
CropContentDirection
Direction(s) for the crop_to_content() operation.
@ VERTICAL
Crop both top and bottom edges.
@ ALL
Crop all four edges.
@ HORIZONTAL
Crop both left and right edges.
Image grid_arrange(const std::vector< Image > &images, int ncol, int nrow, FitMode fit_mode, const Color &background)
Arrange a list of images into a grid layout.
MergeDirection
Direction for the merge() operation.
@ BOTTOM
Attach other below.
@ RIGHT
Attach other to the right side.
@ LEFT
Attach other to the left side.
Image stack_horizontal(const std::vector< Image > &images, FitMode fit_mode=FitMode::PAD, const Color &background=Color(1.0f, 1.0f, 1.0f, 1.0f))
Stack images horizontally in a single row.
Image stack_vertical(const std::vector< Image > &images, FitMode fit_mode=FitMode::PAD, const Color &background=Color(1.0f, 1.0f, 1.0f, 1.0f))
Stack images vertically in a single column.
FitMode
Strategy for normalizing images to a common cell size in grid_arrange().
@ SCALE
Scale all images to match the largest cell dimensions.
@ PAD
Pad smaller images with background color (content stays pixel-perfect).
An RGBA color with floating-point components.
void apply_contrast(float contrast)
Apply a contrast adjustment to the image.
int height
Image height in pixels.
bool write_tga(const std::string &filename, bool use24bit=false) const
Write the image as a TGA file (Truevision Targa).
bool write_ppm(const std::string &filename) const
Write the image as a PPM file (Portable Pixmap).
void scale(int new_width, int new_height)
Scale (resize) the image to new dimensions in-place.
int width
Image width in pixels.
void crop(int x, int y, int w, int h)
Crop the image to a sub-rectangle.
Image()=default
Construct an empty (0×0) image.
void set_pixel(int x, int y, uint8_t r, uint8_t g, uint8_t b, uint8_t a)
Set a single pixel's RGBA value.
std::vector< uint8_t > pixels
Raw pixel data: RGBA bytes, row-major, bottom-left origin.
void grow(int top, int bottom, int left, int right, const Color &background)
Grow (pad) the image by adding borders.
void rotate_90(bool clockwise=true)
Rotate the image by 90 degrees in-place.
void clear_float(float r, float g, float b, float a)
Fill the entire image with an RGBA color (float values 0.0–1.0).
void get_pixel(int x, int y, uint8_t &r, uint8_t &g, uint8_t &b, uint8_t &a) const
Get a single pixel's RGBA value.
void merge(const Image &other, MergeDirection direction)
Merge (concatenate) another image onto this one.
Image downsample_box(int factor) const
Downsample the image by a factor using box filtering.
void pad_to_size(int target_w, int target_h, const Color &background)
Pad the image to a target size, centering the content.
bool write_png(const std::string &filename) const
Write the image as a PNG file.
void clear(uint8_t r, uint8_t g, uint8_t b, uint8_t a)
Fill the entire image with an RGBA color (byte values 0–255).
void crop_to_content(CropContentDirection direction, const Color &background)
Crop away uniform borders of a given background color.
Color sample_bilinear(float u, float v) const
Sample the image at texture coordinates (u, v) using bilinear interpolation.
static Image read_image(const std::string &path)
Read an image from a file (PNG, BMP, TGA, JPEG, etc.).
bool write_bmp(const std::string &filename) const
Write the image as a BMP file (Windows Bitmap).
Fundamental types used throughout the scimesh rendering engine.