百科.dev
全部条目在线工具AI 编程趋势榜开源项目技术资讯提交条目
登录
< 返回工具列表
C

color

> 数据库
开源

这是一个实现了 color 类的 C++ 库。可用的模型包括: RGB、HSL、HSV、CMY、CMYK、YIQ、YUV 以及其他模型。

186 stars0 点赞4 次浏览
访问官网GitHub

工具介绍

这是一个实现了 color 类的 C++ 库。可用的模型包括: RGB、HSL、HSV、CMY、CMYK、YIQ、YUV 以及其他模型。

Yet another c++ library that implements color.

Description

  • Yet another c++ library that implements color conversion and manipulation.

Key features:

  • No virtual functions
  • Minimal memory footprint
  • Ability to copy array/vector of colors with memcpy, memmove and initialize with memset.
  • Conversions from/to different models ( and its formats ).
  • Headers only
    • One file to include to start the fun
    • By using del or rm it is reducible in to only two of them.
  • No third parties
  • No additional binaries
  • Out of the box ready
    • No need to recompile or start some install process.
  • Color models:
    • GRAY,
    • RGB, CMY, CMYK,
    • HSI, HSL, HSV, HWB, TSL
    • YIQ, YUV(BT.601, BT.709), YCgCo, YPbPr(BT.601, BT.709, BT.2020),
    • XYZ( sRGB, D65, 2° ), LAB( CIE, Hunter), LUV, LMS( von Kries D65, von Kries E, BFD, MCAT02 ), xyY, LabCH, LuvCH

Code sample - Initialization:

cpp
// Initialize with constant.
color::bgr  b( ::color::constant::aqua_t{} );

//!  y( ::color::constant::x11::green_t{} );

// Use intuitive/natural values for initialization.
// hue goes from 0 to 360, saturation and value from 0 to 100.
color::hsv        h( { 120.0, 50.0, 60.0 } );

// Lightens will goes from 0 to 100. a and b from -127 to 127.
color::lab         l( { 50.0, -10, 90 } );

// Well known rgb. Values are between 0 and 1.
color::rgb         r( { 0.5, 0, 0.9 } );

Code sample - Conversion:

cpp
// any model/format to any model/format by use of operator=

b = r; //! to hsv
h = y; //! to hsv
l = y; //! to lab

Code sample - Feature Extraction:

cpp
color::rgb  r = ::color::constant::aqua_t{};
::color::get::red( r ); //!  y = ::color::constant::orange_t{};
::color::get::red( y ); //!  r0 = aqua_t{};
rgb  r1 = turquoise_t{};
yiq  y  = orange_t{};

cout ( r0, r1 ) ( r0, y ) ( r0, y ) ( r0, y ) ( r0, y ) ( r0, y, 1, 2 ) ( r0, r1 )   y1 = ::color::constant::turquoise_t{};
color::yiq  y2 = ::color::constant::orange_t{};
color::yiq  yr;

::color::operation::blend(  y1, 0.1, y2 ); //!< Blend two colors for given alpha. Accumulation style.
yr = color::operation::mix( y2, 0.5, y2 ); //!< Blend two colors for given alpha. return style.

Install:

  1. Clone this Repository:
    Examples:
    • Windows : git clone https://github.com/dmilos/color.git c:\my-work-folder\my-git-folder\color
    • Linux : git clone https://github.com/dmilos/color.git /home/my-user-name/my-work-folder/my-git-folder/color
  2. Inform compiler where to find headers:
    Examples:
    • MSVC : /Ic:\my-work-folder\my-git-folder\color\src
    • gcc : -I/home/my-user-name/my-work-folder/my-git-folder/color/src

Want to see more:

  • HTML Documentation
  • Wiki page

Tested against:

  • GCC 13.4.0, C++11,14,17,20
  • MSVC 2022 17.14.9 C++11,14,17,20
  • MSVC 2022 17.14.9 CLang, C++11,14,17,20

(Links

  • ibireme
  • YUV, YCbCr, YPbPr color spaces
  • Bruce Justin Lindbloom
  • colorizer
  • Parameter values for ultra-high definition television systems for production and international programme exchange

License

Licensed under an Apache-2.0 license.

Issues· 0 开放

查看全部 Issues在 GitHub 打开

暂无开放 Issues,或尚未同步最近议题。

> 标签

C++c-plus-pluscolorcross-platformheader-only

暂无评论,来聊聊你的看法吧

> 工具信息

发布日期2026年8月1日
最后更新2026年9月18日
分类数据库
定价开源

> 相关工具

P
PostgreSQL
功能强大的开源关系型数据库
R
Redis
内存数据结构存储,常用作缓存与队列
M
MySQL
广泛使用的开源关系型数据库