color.h

来自「这是VCF框架的代码」· C头文件 代码 · 共 1,803 行 · 第 1/5 页

H
1,803
字号
inline void Color::setRGB16( const uint16& r, const uint16& g, const uint16& b ) {	r_ = ((double)r) / xFFFF;	g_ = ((double)g) / xFFFF;	b_ = ((double)b) / xFFFF;}inline Color& Color::setRGBPack8( const uint32& rgb, const ColorPackScheme& cps ) {	switch ( cps ) {		case cpsARGB : {			r_ = (double)((uint8*)&rgb)[2] / xFF;			g_ = (double)((uint8*)&rgb)[1] / xFF;			b_ = (double)((uint8*)&rgb)[0] / xFF;		}		break;		case cpsABGR : {			r_ = (double)((uint8*)&rgb)[0] / xFF;			g_ = (double)((uint8*)&rgb)[1] / xFF;			b_ = (double)((uint8*)&rgb)[2] / xFF;		}		break;	}	return *this;}inline Color& Color::setRGBPack16( const ulong64& rgb, const ColorPackScheme& cps ) {	switch ( cps ) {		case cpsARGB : {			r_ = (double)((uint16*)&rgb.data_)[2] / xFFFF;			g_ = (double)((uint16*)&rgb.data_)[1] / xFFFF;			b_ = (double)((uint16*)&rgb.data_)[0] / xFFFF;		}		break;		case cpsABGR : {			r_ = (double)((uint16*)&rgb.data_)[0] / xFFFF;			g_ = (double)((uint16*)&rgb.data_)[1] / xFFFF;			b_ = (double)((uint16*)&rgb.data_)[2] / xFFFF;		}		break;	}	return *this;}inline Color& Color::setColorRef32( const uint32& rgb ) {	return setRGBPack8( rgb, cpsABGR );}inline Color& Color::setColorRef64( const ulong64& rgb ) {	return setRGBPack16( rgb, cpsABGR );}inline void Color::getHSV( double& h, double& s, double& v ) const {	ColorSpace::HSVtype hsv;	ColorSpace::RGBtype rgb;	rgb.R = r_;	rgb.G = g_;	rgb.B = b_;	hsv = ColorSpace::RGBToHSV( rgb );	h = hsv.H;	s = hsv.S;	v = hsv.V;}inline void Color::setHSV( const double& h, const double& s, const double& v ) {	ColorSpace::HSVtype hsv;	hsv.H = h;	hsv.S = s;	hsv.V = v;	ColorSpace::RGBtype rgb = ColorSpace::HSVToRGB( hsv );	r_ = rgb.R;	g_ = rgb.G;	b_ = rgb.B;}inline void Color::getHSL( double& h, double& l, double& s ) const {	ColorSpace::HSLtype hsl;	ColorSpace::RGBtype rgb;	rgb.R = r_;	rgb.G = g_;	rgb.B = b_;	hsl = ColorSpace::RGBToHSL( rgb );	h = hsl.H;	l = hsl.L;	s = hsl.S;}inline void Color::setHSL( const double& h, const double& l, const double& s ) {	ColorSpace::HSLtype hsl;	hsl.H = h;	hsl.L = l;	hsl.S = s;	ColorSpace::RGBtype rgb = ColorSpace::HSLToRGB( hsl );	r_ = rgb.R;	g_ = rgb.G;	b_ = rgb.B;}inline void Color::getCMYK( double& c, double& m, double& y, double& k ) const {	throw NotImplementedException();}inline void Color::setCMYK( const double& c, const double& m, const double& y, const double& k ) {	throw NotImplementedException();}inline void Color::getLab() const {	throw NotImplementedException();}inline void Color::setLab() {	throw NotImplementedException();}inline void Color::getYUV() const {	throw NotImplementedException();}inline void Color::setYUV() {	throw NotImplementedException();}inline void Color::copyColor( const Color* color ) {	if ( NULL != color ){		r_ = color->getRed();		g_ = color->getGreen();		b_ = color->getBlue();	}}inline void Color::copyColor( const Color& color ) {	r_ = color.getRed();	g_ = color.getGreen();	b_ = color.getBlue();}inline void Color::changeHSV ( const double& percentH, const double& percentS, const double& percentV ) {	ColorSpace::changeHWB( *this, percentH, percentS, percentV );}inline void Color::changeHSL ( const double& percentH, const double& percentS, const double& percentL ) {	ColorSpace::changeHWB( *this, percentH, percentS, percentL );}inline void Color::changeHWB ( const double& percentH, const double& percentW, const double& percentB ) {	ColorSpace::changeHWB( *this, percentH, percentW, percentB );}inline void Color::changeHue ( const double& deltaH ) {	ColorSpace::changeHue( *this, deltaH );}inline int Color::getLuminosity() const {	return ColorSpace::getLuminosity( *this );}inline void Color::setLuminosity( const int& luminosity ) {	ColorSpace::setLuminosity( *this, luminosity );}inline Color& Color::invert() {	// change the color to its complement	r_ =  ( 1.0 - r_ );	g_ =  ( 1.0 - g_ );	b_ =  ( 1.0 - b_ );	return *this;}inline Color Color::getInverted() const {	// get the complement color	Color color;	color.r_ =  ( 1.0 - r_ );	color.g_ =  ( 1.0 - g_ );	color.b_ =  ( 1.0 - b_ );	return color;}inline void Color::getInvertedRGB( double& r, double& g, double& b ) const {	r =  ( 1.0 - r_ );	g =  ( 1.0 - g_ );	b =  ( 1.0 - b_ );}inline void Color::getInvertedRGB8( uint8& r, uint8& g, uint8& b ) const {	r = (uint8)( (1.0 - r_ ) * xFF + 0.5);	g = (uint8)( (1.0 - g_ ) * xFF + 0.5);	b = (uint8)( (1.0 - b_ ) * xFF + 0.5);}inline void Color::getInvertedRGB16( uint16& r, uint16& g, uint16& b ) const {	r = (uint16)( (1.0 - r_ ) * xFFFF + 0.5);	g = (uint16)( (1.0 - g_ ) * xFFFF + 0.5);	b = (uint16)( (1.0 - b_ ) * xFFFF + 0.5);}///////////////////////////////////////////////////////////////////////////////// class ColorNames/**\class ColorNames Color.h "vcf/GraphicsKit/Color.h"struct with all color names not included by VCF:they are essentially grayswe need to instantiate it somewhere: unfortunately non-integer constant have no externallinkage otherwise ColorName would be replaced by a namespace with the same Stringconstants and put in the VCF library*/class GRAPHICSKIT_API ColorNames {public:	enum ColorID  {				//		NAMES					RGB (0x00RRGGBB)#ifdef  VCF_LARGE_COLOR_LIST			// long list ( 548 names )			//from http://www.winvideo.net/colori.htm			//shades of gray			//color name r/g/b hex bg/fg color sample			black                   ,   //  0;0;0           // 0x00000000			grey                    ,   //  190;190;190     // 0x00BEBEBE			dimgray                 ,   //  105;105;105     // 0x00696969   // frequently mispelled as dimgrey			lightgray               ,   //  211;211;211     // 0x00D3D3D3			lightslategrey          ,   //  119;136;153     // 0x00778899			slategray               ,   //  112;128;144     // 0x00708090			slategray1              ,   //  198;226;255     // 0x00C6E2FF			slategray2              ,   //  185;211;238     // 0x00B9D3EE			slategray3              ,   //  159;182;205     // 0x009FB6CD			slategray4              ,   //  108;123;139     // 0x006C7B8B			slategrey               ,   //  112;128;144     // 0x00708090			grey0                   ,   //  0;0;0           // 0x00000000			grey1                   ,   //  3;3;3           // 0x00030303			grey2                   ,   //  5;5;5           // 0x00050505			grey3                   ,   //  8;8;8           // 0x00080808			grey4                   ,   //  10;10;10        // 0x000A0A0A			grey5                   ,   //  13;13;13        // 0x000D0D0D			grey6                   ,   //  15;15;15        // 0x000F0F0F			grey7                   ,   //  18;18;18        // 0x00121212			grey8                   ,   //  20;20;20        // 0x00141414			grey98                  ,   //  23;23;23        // 0x00171717			grey10                  ,   //  26;26;26        // 0x001A1A1A			grey11                  ,   //  28;28;28        // 0x001C1C1C			grey12                  ,   //  31;31;31        // 0x001F1F1F			grey13                  ,   //  33;33;33        // 0x00212121			grey14                  ,   //  36;36;36        // 0x00242424			grey15                  ,   //  38;38;38        // 0x00262626			grey16                  ,   //  41;41;41        // 0x00292929			grey17                  ,   //  43;43;43        // 0x002B2B2B			grey18                  ,   //  46;46;46        // 0x002E2E2E			grey19                  ,   //  48;48;48        // 0x00303030			grey20                  ,   //  51;51;51        // 0x00333333			grey21                  ,   //  54;54;54        // 0x00363636			grey22                  ,   //  56;56;56        // 0x00383838			grey23                  ,   //  59;59;59        // 0x003B3B3B			grey24                  ,   //  61;61;61        // 0x003D3D3D			grey25                  ,   //  64;64;64        // 0x00404040			grey26                  ,   //  66;66;66        // 0x00424242			grey27                  ,   //  69;69;69        // 0x00454545			grey28                  ,   //  71;71;71        // 0x00474747			grey29                  ,   //  74;74;74        // 0x004A4A4A			grey30                  ,   //  77;77;77        // 0x004D4D4D			grey31                  ,   //  79;79;79        // 0x004F4F4F			grey32                  ,   //  82;82;82        // 0x00525252			grey33                  ,   //  84;84;84        // 0x00545454			grey34                  ,   //  87;87;87        // 0x00575757			grey35                  ,   //  89;89;89        // 0x00595959			grey36                  ,   //  92;92;92        // 0x005C5C5C			grey37                  ,   //  94;94;94        // 0x005E5E5E			grey38                  ,   //  97;97;97        // 0x00616161			grey39                  ,   //  99;99;99        // 0x00636363			grey40                  ,   //  102;102;102     // 0x00666666			grey41                  ,   //  105;105;105     // 0x00696969			grey42                  ,   //  107;107;107     // 0x006B6B6B			grey43                  ,   //  110;110;110     // 0x006E6E6E			grey44                  ,   //  112;112;112     // 0x00707070			grey45                  ,   //  115;115;115     // 0x00737373			grey46                  ,   //  117;117;117     // 0x00757575			grey47                  ,   //  120;120;120     // 0x00787878			grey48                  ,   //  122;122;122     // 0x007A7A7A			grey49                  ,   //  125;125;125     // 0x007D7D7D			grey50                  ,   //  127;127;127     // 0x007F7F7F			grey51                  ,   //  130;130;130     // 0x00828282			grey52                  ,   //  133;133;133     // 0x00858585			grey53                  ,   //  135;135;135     // 0x00878787			grey54                  ,   //  138;138;138     // 0x008A8A8A			grey55                  ,   //  140;140;140     // 0x008C8C8C			grey56                  ,   //  143;143;143     // 0x008F8F8F			grey57                  ,   //  145;145;145     // 0x00919191			grey58                  ,   //  148;148;148     // 0x00949494			grey59                  ,   //  150;150;150     // 0x00969696			grey60                  ,   //  153;153;153     // 0x00999999			grey61                  ,   //  156;156;156     // 0x009C9C9C			grey62                  ,   //  158;158;158     // 0x009E9E9E			grey63                  ,   //  161;161;161     // 0x00A1A1A1			grey64                  ,   //  163;163;163     // 0x00A3A3A3			grey65                  ,   //  166;166;166     // 0x00A6A6A6			grey66                  ,   //  168;168;168     // 0x00A8A8A8			grey67                  ,   //  171;171;171     // 0x00ABABAB			grey68                  ,   //  173;173;173     // 0x00ADADAD			grey69                  ,   //  176;176;176     // 0x00B0B0B0			grey70                  ,   //  179;179;179     // 0x00B3B3B3			grey71                  ,   //  181;181;181     // 0x00B5B5B5			grey72                  ,   //  184;184;184     // 0x00B8B8B8			grey73                  ,   //  186;186;186     // 0x00BABABA			grey74                  ,   //  189;189;189     // 0x00BDBDBD			grey75                  ,   //  191;191;191     // 0x00BFBFBF			grey76                  ,   //  194;194;194     // 0x00C2C2C2			grey77                  ,   //  196;196;196     // 0x00C4C4C4			grey78                  ,   //  199;199;199     // 0x00C7C7C7			grey79                  ,   //  201;201;201     // 0x00C9C9C9			grey80                  ,   //  204;204;204     // 0x00CCCCCC			grey81                  ,   //  207;207;207     // 0x00CFCFCF			grey82                  ,   //  209;209;209     // 0x00D1D1D1			grey83                  ,   //  212;212;212     // 0x00D4D4D4			grey84                  ,   //  214;214;214     // 0x00D6D6D6			grey85                  ,   //  217;217;217     // 0x00D9D9D9			grey86                  ,   //  219;219;219     // 0x00DBDBDB			grey87                  ,   //  222;222;222     // 0x00DEDEDE			grey88                  ,   //  224;224;224     // 0x00E0E0E0			grey89                  ,   //  227;227;227     // 0x00E3E3E3			grey90                  ,   //  229;229;229     // 0x00E5E5E5			grey91                  ,   //  232;232;232     // 0x00E8E8E8			grey92                  ,   //  235;235;235     // 0x00EBEBEB			grey93                  ,   //  237;237;237     // 0x00EDEDED			grey94                  ,   //  240;240;240     // 0x00F0F0F0			grey95                  ,   //  242;242;242     // 0x00F2F2F2			grey96                  ,   //  245;245;245     // 0x00F5F5F5			grey97                  ,   //  247;247;247     // 0x00F7F7F7			grey98                  ,   //  250;250;250     // 0x00FAFAFA			grey99                  ,   //  252;252;252     // 0x00FCFCFC			grey100                 ,   //  255;255;255     // 0x00FFFFFF			//shades of blue			//color name r/g/b hex bg/fg color sample			aliceblue               ,   //  240;248;255     // 0x00F0F8FF			blueviolet              ,   //  138;43;226      // 0x008A2BE2			cadetblue               ,   //  95;158;160      // 0x005F9EA0			cadetblue1              ,   //  152;245;255     // 0x0098F5FF			cadetblue2              ,   //  142;229;238     // 0x008EE5EE			cadetblue3              ,   //  122;197;205     // 0x007AC5CD			cadetblue4              ,   //  83;134;139      // 0x0053868B			cornflowerblue          ,   //  100;149;237     // 0x006495ED			darkslateblue           ,   //  72;61;139       // 0x00483D8B			darkturquoise           ,   //  0;206;209       // 0x0000CED1

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?