tinyimg 1.0.0
Lightweight image manipulation library for Cloudflare Workers
Loading...
Searching...
No Matches
color.h
Go to the documentation of this file.
1
11#pragma once
12
13#include <stddef.h>
14#include <stdint.h>
15
16#include "tinyimg/image.h"
17
18#ifdef __cplusplus
19extern "C" {
20#endif
21
22#pragma region color conversion
23
35int tiny_rgb_to_grayscale(uint8_t r, uint8_t g, uint8_t b);
36
49 uint8_t grayscale, uint8_t* r, uint8_t* g, uint8_t* b
50);
51
70 uint8_t r, uint8_t g, uint8_t b, float* h, float* s, float* v
71);
72
92 float h, float s, float v, uint8_t* r, uint8_t* g, uint8_t* b
93);
94
114 uint8_t r, uint8_t g, uint8_t b, float* h, float* s, float* l
115);
116
136 float h, float s, float l, uint8_t* r, uint8_t* g, uint8_t* b
137);
138
160 uint8_t r, uint8_t g, uint8_t b, float* c, float* m, float* y, float* k
161);
162
184 float c, float m, float y, float k, uint8_t* r, uint8_t* g, uint8_t* b
185);
186
187#pragma endregion
188
189#pragma region color interpolation
190
212 uint8_t r1, uint8_t g1, uint8_t b1, uint8_t r2, uint8_t g2, uint8_t b2,
213 float t, uint8_t* r_out, uint8_t* g_out, uint8_t* b_out
214);
215
237 float h1, float s1, float v1, float h2, float s2, float v2, float t,
238 float* h_out, float* s_out, float* v_out
239);
240
262 float h1, float s1, float l1, float h2, float s2, float l2, float t,
263 float* h_out, float* s_out, float* l_out
264);
265
266#pragma endregion
267
268#pragma region color palette generation
269
290 uint8_t r1, uint8_t g1, uint8_t b1, uint8_t r2, uint8_t g2, uint8_t b2,
291 size_t steps
292);
293
316 uint8_t r1, uint8_t g1, uint8_t b1, uint8_t a1, uint8_t r2, uint8_t g2,
317 uint8_t b2, uint8_t a2, size_t steps
318);
319
339 float h1, float s1, float v1, float h2, float s2, float v2, size_t steps
340);
341
361 float h1, float s1, float l1, float h2, float s2, float l2, size_t steps
362);
363
385 float c1, float m1, float y1, float k1, float c2, float m2, float y2,
386 float k2, size_t steps
387);
388
409int* tiny_multigradient_rgb(uint8_t* colors, size_t num_colors, size_t steps);
410
436 uint8_t* colors, size_t num_colors, size_t steps, float* color_distribution
437);
438
459int* tiny_multigradient_rgba(uint8_t* colors, size_t num_colors, size_t steps);
460
486 uint8_t* colors, size_t num_colors, size_t steps, float* color_distribution
487);
488
507float* tiny_multigradient_hsv(float* colors, size_t num_colors, size_t steps);
508
531 float* colors, size_t num_colors, size_t steps, float* color_distribution
532);
533
552float* tiny_multigradient_hsl(float* colors, size_t num_colors, size_t steps);
553
576 float* colors, size_t num_colors, size_t steps, float* color_distribution
577);
578
597float* tiny_multigradient_cmyk(float* colors, size_t num_colors, size_t steps);
598
621 float* colors, size_t num_colors, size_t steps, float* color_distribution
622);
623
624#pragma endregion
625
626#pragma region icc
627
638typedef struct {
645 float to_xyz[9];
647 float white[3];
649 float curve[3][256];
651 uint8_t linear;
653
664int tiny_icc_parse(TinyIccProfile* profile, const uint8_t* data, size_t size);
665
673
683 const TinyIccProfile* profile, const uint8_t* in, uint8_t* out
684);
685
695
706 float* out, const TinyIccProfile* from, const TinyIccProfile* to
707);
708
709#pragma endregion
710
711#ifdef __cplusplus
712}
713#endif
float * tiny_multigradient_hsv_sized(float *colors, size_t num_colors, size_t steps, float *color_distribution)
Generates a multi-gradient of HSV colors based on an array of input colors and a specified number of ...
float * tiny_gradient_cmyk(float c1, float m1, float y1, float k1, float c2, float m2, float y2, float k2, size_t steps)
Generates a gradient of CMYK colors between two specified colors over a given number of steps.
int tiny_rgb_to_grayscale(uint8_t r, uint8_t g, uint8_t b)
Converts RGB color values to a grayscale value using the luminosity method.
float * tiny_gradient_hsv(float h1, float s1, float v1, float h2, float s2, float v2, size_t steps)
Generates a gradient of HSV colors between two specified colors over a given number of steps.
int tiny_icc_parse(TinyIccProfile *profile, const uint8_t *data, size_t size)
Reads a matrix and TRC profile.
float * tiny_multigradient_hsv(float *colors, size_t num_colors, size_t steps)
Generates a multi-gradient of HSV colors based on an array of input colors and a specified number of ...
int tiny_interpolate_hsv(float h1, float s1, float v1, float h2, float s2, float v2, float t, float *h_out, float *s_out, float *v_out)
Interpolates between two HSV colors based on a given interpolation factor t.
int tiny_cmyk_to_rgb(float c, float m, float y, float k, uint8_t *r, uint8_t *g, uint8_t *b)
Converts CMYK (Cyan, Magenta, Yellow, Key/Black) color space values to RGB color values.
int tiny_icc_matrix_between(float *out, const TinyIccProfile *from, const TinyIccProfile *to)
The matrix taking one profile's RGB to another's.
float * tiny_multigradient_hsl(float *colors, size_t num_colors, size_t steps)
Generates a multi-gradient of HSL colors based on an array of input colors and a specified number of ...
float * tiny_gradient_hsl(float h1, float s1, float l1, float h2, float s2, float l2, size_t steps)
Generates a gradient of HSL colors between two specified colors over a given number of steps.
int tiny_icc_convert_image(TinyImage *image, const TinyIccProfile *profile)
Converts a whole image from a profile's space to sRGB.
int tiny_icc_srgb(TinyIccProfile *profile)
The sRGB profile, without needing a file for it.
int tiny_interpolate_rgb(uint8_t r1, uint8_t g1, uint8_t b1, uint8_t r2, uint8_t g2, uint8_t b2, float t, uint8_t *r_out, uint8_t *g_out, uint8_t *b_out)
Interpolates between two RGB colors based on a given interpolation factor t.
int tiny_icc_to_srgb(const TinyIccProfile *profile, const uint8_t *in, uint8_t *out)
Converts one color from a profile's space to sRGB.
int tiny_rgb_to_cmyk(uint8_t r, uint8_t g, uint8_t b, float *c, float *m, float *y, float *k)
Converts RGB color values to CMYK (Cyan, Magenta, Yellow, Key/Black) color space.
int * tiny_multigradient_rgb_sized(uint8_t *colors, size_t num_colors, size_t steps, float *color_distribution)
Generates a multi-gradient of RGB colors based on an array of input colors and a specified number of ...
int tiny_interpolate_hsl(float h1, float s1, float l1, float h2, float s2, float l2, float t, float *h_out, float *s_out, float *l_out)
Interpolates between two HSL colors based on a given interpolation factor t.
int * tiny_gradient_rgb(uint8_t r1, uint8_t g1, uint8_t b1, uint8_t r2, uint8_t g2, uint8_t b2, size_t steps)
Generates a gradient of RGB colors between two specified colors over a given number of steps.
float * tiny_multigradient_cmyk(float *colors, size_t num_colors, size_t steps)
Generates a multi-gradient of CMYK colors based on an array of input colors and a specified number of...
float * tiny_multigradient_hsl_sized(float *colors, size_t num_colors, size_t steps, float *color_distribution)
Generates a multi-gradient of HSL colors based on an array of input colors and a specified number of ...
int * tiny_multigradient_rgba(uint8_t *colors, size_t num_colors, size_t steps)
Generates a multi-gradient of RGBA colors based on an array of input colors and a specified number of...
int tiny_grayscale_to_rgb(uint8_t grayscale, uint8_t *r, uint8_t *g, uint8_t *b)
Converts a grayscale value to RGB color values.
int * tiny_gradient_rgba(uint8_t r1, uint8_t g1, uint8_t b1, uint8_t a1, uint8_t r2, uint8_t g2, uint8_t b2, uint8_t a2, size_t steps)
Generates a gradient of RGBA colors between two specified colors over a given number of steps.
float * tiny_multigradient_cmyk_sized(float *colors, size_t num_colors, size_t steps, float *color_distribution)
Generates a multi-gradient of CMYK colors based on an array of input colors and a specified number of...
int tiny_hsv_to_rgb(float h, float s, float v, uint8_t *r, uint8_t *g, uint8_t *b)
Converts HSV (Hue, Saturation, Value) color space values to RGB color values.
int tiny_hsl_to_rgb(float h, float s, float l, uint8_t *r, uint8_t *g, uint8_t *b)
Converts HSL (Hue, Saturation, Lightness) color space values to RGB color values.
int * tiny_multigradient_rgb(uint8_t *colors, size_t num_colors, size_t steps)
Generates a multi-gradient of RGB colors based on an array of input colors and a specified number of ...
int * tiny_multigradient_rgba_sized(uint8_t *colors, size_t num_colors, size_t steps, float *color_distribution)
Generates a multi-gradient of RGBA colors based on an array of input colors and a specified number of...
int tiny_rgb_to_hsv(uint8_t r, uint8_t g, uint8_t b, float *h, float *s, float *v)
Converts RGB color values to HSV (Hue, Saturation, Value) color space.
int tiny_rgb_to_hsl(uint8_t r, uint8_t g, uint8_t b, float *h, float *s, float *l)
Converts RGB color values to HSL (Hue, Saturation, Lightness) color space.
Image processing library utilities.
A parsed matrix and TRC profile.
Definition color.h:638
float white[3]
Definition color.h:647
uint8_t linear
Definition color.h:651
float curve[3][256]
Definition color.h:649
float to_xyz[9]
Columns of the RGB to XYZ matrix, row major.
Definition color.h:645
Represents an image with its width, height, and pixel data.
Definition image.h:90