1 Star 0 Fork 0

MerlotRain/m2

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
tinycolor.h 3.70 KB
一键复制 编辑 原始数据 按行查看 历史
MerlotRain 提交于 2024-05-14 08:35 . update tinycolor.h.
#ifndef __TINYCOLOR_H__
#define __TINYCOLOR_H__
#include <stdint.h>
#ifndef COLOR_WITH_ALPHA
#warning "the color data struct will not contain alpha channel"
#endif
#define COLOR_SPACE_RGB 0
#define COLOR_SPACE_CMY 1
#define COLOR_SPACE_CMYK 2
#define COLOR_SPACE_GRAY 3
#define COLOR_SPACE_HSI 4
#define COLOR_SPACE_HSL 5
#define COLOR_SPACE_HSV 6
#define COLOR_SPACE_HWB 7
#define COLOR_SPACE_Lab 8
#define COLOR_SPACE_LabCH 9
#define COLOR_SPACE_LMS 10
#define COLOR_SPACE_Luv 11
#define COLOR_SPACE_LuvCH 12
#define COLOR_SPACE_TSL 13
#define COLOR_SPACE_XYY 14
#define COLOR_SPACE_XYZ 15
#define COLOR_SPACE_YCgCo 16
#define COLOR_SPACE_YDbDr 17
#define COLOR_SPACE_YIQ 18
#define COLOR_SPACE_YPdPr 19
#define COLOR_SPACE_YUV 20
typedef struct _tinyColor tinyColor;
#define COLOR_CONVERT_(from, to) \
extern int color_convert_##from##_##to(tinyColor *color); \
extern int color_convert_##to##_##from(tinyColor *color);
COLOR_CONVERT_(RGB, CMYK)
COLOR_CONVERT_(RGB, GRAY)
COLOR_CONVERT_(RGB, HSI)
COLOR_CONVERT_(RGB, HSL)
COLOR_CONVERT_(RGB, HSV)
COLOR_CONVERT_(RGB, HWB)
COLOR_CONVERT_(RGB, Lab)
COLOR_CONVERT_(RGB, LabCH)
COLOR_CONVERT_(RGB, LMS)
COLOR_CONVERT_(RGB, Luv)
COLOR_CONVERT_(RGB, LuvCH)
COLOR_CONVERT_(RGB, TSL)
COLOR_CONVERT_(RGB, XYY)
COLOR_CONVERT_(RGB, XYZ)
COLOR_CONVERT_(RGB, YCgCo)
COLOR_CONVERT_(RGB, YDbDr)
COLOR_CONVERT_(RGB, YIQ)
COLOR_CONVERT_(RGB, YPdPr)
COLOR_CONVERT_(RGB, YUV)
#define COLOR_JOIN(a, b) a##b
#define COLOR_GLUE(a, b) COLOR_JOIN(a, b)
#define COLOR_SUFFIX(a) COLOR_GLUE(a, COLOR_COMPONENT_WIDTH)
#define COLOR_CATEGORY_PACK(n) COLOR_COMPONENT_TYPE n;
#define COLOR_CATEGORY_PACK_3(n1, n2, n3) \
typedef struct { \
COLOR_CATEGORY_PACK(A) \
COLOR_CATEGORY_PACK(n1) \
COLOR_CATEGORY_PACK(n2) \
COLOR_CATEGORY_PACK(n3) \
} COLOR_SUFFIX(color##n1##n2##n3##_); \
extern int COLOR_SUFFIX(color_component##n1##n2##n3##_)( \
tinyColor * color, COLOR_SUFFIX(color##n1##n2##n3##_) * data); \
extern tinyColor *COLOR_SUFFIX(color_createFrom##n1##n2##n3##_)( \
const COLOR_SUFFIX(color##n1##n2##n3##_) data);
#define COLOR_CATEGORY_PACK_4(n1, n2, n3, n4) \
typedef struct { \
COLOR_CATEGORY_PACK(A) \
COLOR_CATEGORY_PACK(n1) \
COLOR_CATEGORY_PACK(n2) \
COLOR_CATEGORY_PACK(n3) \
COLOR_CATEGORY_PACK(n4) \
} COLOR_SUFFIX(color##n1##n2##n3##n4_);
#define GEN_COLOR_STRUCT \
COLOR_CATEGORY_PACK_3(R, G, B) \
COLOR_CATEGORY_PACK_3(H, S, L)
#define COLOR_COMPONENT_WIDTH 8
#define COLOR_COMPONENT_TYPE int8_t
GEN_COLOR_STRUCT
#undef COLOR_COMPONENT_TYPE
#undef COLOR_COMPONENT_WIDTH
#define COLOR_COMPONENT_WIDTH 16
#define COLOR_COMPONENT_TYPE int16_t
GEN_COLOR_STRUCT
#undef COLOR_COMPONENT_TYPE
#undef COLOR_COMPONENT_WIDTH
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
C++
1
https://gitee.com/merlotrain/m2.git
git@gitee.com:merlotrain/m2.git
merlotrain
m2
m2
master

搜索帮助