These helper functions support image processing tasks like pixel manipulation, color conversion, memory allocation, and file I/O. You will find these useful if you decide to implement a new shape, a new effect or a new format. Here's what each one does:
Identifies the file format (BMP, PNG, or PPM) by checking the file extension. Relies on split() internally.
Safely deallocates a 2D pixel array.
Blends two colors based on the alpha channel of the second one. Returns the resulting color as a uint32_t.
Reads a single byte from a binary input stream. Handy for low-level file parsing.
This function returns the default handler for the FileType.
Combines RGBA values into a single 32-bit integer. This is the internal format used for storing pixel data.
Returns the brightness of a pixel by taking the maximum of its R, G, and B components.
Extracts the red, green, and blue components from a packed pixel value.
Converts a color from HSI (Hue, Saturation, Intensity) to RGB.
Converts HSV (Hue, Saturation, Value) to RGB. Similar to HSI but with a different approach to brightness.
Multiplies the RGB components of a pixel by a factor to make it brighter. Values are clamped to avoid overflow.
Returns a random number generator, useful in add_noise method.
Converts an RGB color to HSI.
Converts RGB to HSV.
Writes a single byte to a binary output stream. Used for saving raw image data.
Writes a color multiple times to a file, along with its repetition count. Useful for simple run-length encoding (RLE).
Checks if an element exists in a vector.
Returns the maximum of n values, works only on numerical types
Returns the minimum of n values. Same deal.
Reads a value of type T from a stream in big-endian order.
Writes a value of type T to a stream in big-endian format, regardless of system endianness.
Reads a value of type T from a stream in little-endian order.
Same but in little-endian format.