#include "scbcolor.h"#include "scblog.h"#include <stdio.h>#include "scbtype.h"#include "scbconfig.h"Go to the source code of this file.
Functions | |
| void | scb_color_set_white (ScbColorPtr ptr) |
| void | scb_color_set_black (ScbColorPtr ptr) |
| void | scb_color_set_light_gray (ScbColorPtr ptr) |
| void | scb_color_set_dark_gray (ScbColorPtr ptr) |
| const char * | scb_color_to_html_color (const ScbColorPtr ptr) |
| ScbDevColor | scb_color_to_dev_color (ScbColorPtr ptr) |
| int | scb_html_color_to_color (const char *buf, const int length, ScbColorPtr ptr) |
| ScbDevColor | scb_html_color_to_dev_color (const char *buf, const int length) |
| void | scb_dev_color_to_color (ScbColorPtr ptr, const ScbDevColor color) |
| const char * | scb_dev_color_to_html_color (const ScbDevColor color) |
Variables | |
| char | _g_htmlColor [SCB_MAX_COLOR_LEN] = {0} |
| void scb_color_set_black | ( | ScbColorPtr | ptr | ) |
| void scb_color_set_dark_gray | ( | ScbColorPtr | ptr | ) |
| void scb_color_set_light_gray | ( | ScbColorPtr | ptr | ) |
| void scb_color_set_white | ( | ScbColorPtr | ptr | ) |
| ScbDevColor scb_color_to_dev_color | ( | ScbColorPtr | ptr | ) |
Definition at line 85 of file scbcolor.c.
00086 { 00087 if (NULL == ptr) return SCB_DEV_COLOR_UNKNOWN; 00088 if (0 == ptr->red && 0 == ptr->green && 0 == ptr->blue) 00089 { 00090 return SCB_DEV_COLOR_BLACK; 00091 } 00092 else if (0xff == ptr->red && 0xff == ptr->green && 0xff == ptr->blue) 00093 { 00094 return SCB_DEV_COLOR_WHITE; 00095 } 00096 else if (0xaa == ptr->red && 0xaa == ptr->green && 0xaa == ptr->blue) 00097 { 00098 return SCB_DEV_COLOR_LIGHT_GRAY; 00099 } 00100 else if (0x55 == ptr->red && 0x55 == ptr->green && 0x55 == ptr->blue) 00101 { 00102 return SCB_DEV_COLOR_DARK_GRAY; 00103 } 00104 return SCB_DEV_COLOR_UNKNOWN; 00105 }
| const char* scb_color_to_html_color | ( | const ScbColorPtr | ptr | ) |
Definition at line 76 of file scbcolor.c.
00077 { 00078 SCB_RET_NULL_IF(NULL == ptr, "Invalid color pointer!"); 00079 snprintf(_g_htmlColor, SCB_MAX_COLOR_LEN, 00080 "#%02X%02X%02X", ptr->red, ptr->green, ptr->blue); 00081 return _g_htmlColor; 00082 }
| void scb_dev_color_to_color | ( | ScbColorPtr | ptr, | |
| const ScbDevColor | color | |||
| ) |
Definition at line 148 of file scbcolor.c.
00149 { 00150 if (NULL == ptr) return; 00151 switch(color) 00152 { 00153 case SCB_DEV_COLOR_WHITE : 00154 scb_color_set_white(ptr); 00155 break; 00156 case SCB_DEV_COLOR_LIGHT_GRAY : 00157 scb_color_set_light_gray(ptr); 00158 break; 00159 case SCB_DEV_COLOR_DARK_GRAY : 00160 scb_color_set_dark_gray(ptr); 00161 break; 00162 default: 00163 scb_color_set_black(ptr); 00164 break; 00165 } 00166 }

| const char* scb_dev_color_to_html_color | ( | const ScbDevColor | color | ) |
Definition at line 168 of file scbcolor.c.
00169 { 00170 if (SCB_DEV_COLOR_WHITE == color) 00171 { 00172 snprintf(_g_htmlColor, SCB_MAX_COLOR_LEN, 00173 "#%02X%02X%02X", 0xff, 0xff, 0xff); 00174 } 00175 else if (SCB_DEV_COLOR_LIGHT_GRAY == color) 00176 { 00177 snprintf(_g_htmlColor, SCB_MAX_COLOR_LEN, 00178 "#%02X%02X%02X", 0xaa, 0xaa, 0xaa); 00179 } 00180 else if (SCB_DEV_COLOR_DARK_GRAY == color) 00181 { 00182 snprintf(_g_htmlColor, SCB_MAX_COLOR_LEN, 00183 "#%02X%02X%02X", 0x55, 0x55, 0x55); 00184 } 00185 else 00186 { 00187 snprintf(_g_htmlColor, SCB_MAX_COLOR_LEN, 00188 "#%02X%02X%02X", 0x00, 0x00, 0x00); 00189 } 00190 return _g_htmlColor; 00191 }
| int scb_html_color_to_color | ( | const char * | buf, | |
| const int | length, | |||
| ScbColorPtr | ptr | |||
| ) |
Definition at line 109 of file scbcolor.c.
00110 { 00111 if (NULL == ptr) 00112 { 00113 SCB_ERROR("Invalid color pointer!"); 00114 return SCB_RET_ERR; 00115 } 00116 00117 if (NULL == buf || 0 >= length) 00118 { 00119 SCB_ERROR("Buffer or lenght is invalid!"); 00120 return SCB_RET_ERR; 00121 } 00122 int r = 0, g = 0, b = 0; 00123 sscanf(buf, "#%02x%02x%02x", &r, &g, &b); 00124 ptr->red = (unsigned short)r; 00125 ptr->green = (unsigned short)g; 00126 ptr->blue = (unsigned short)b; 00127 return SCB_RET_OK; 00128 }
| ScbDevColor scb_html_color_to_dev_color | ( | const char * | buf, | |
| const int | length | |||
| ) |
Definition at line 130 of file scbcolor.c.
00131 { 00132 if (NULL == buf || 0 >= length) 00133 { 00134 SCB_ERROR("Buffer or lenght is invalid!"); 00135 return SCB_DEV_COLOR_UNKNOWN; 00136 } 00137 int r = 0, g = 0, b = 0; 00138 ScbColor color; 00139 sscanf(buf, "#%02x%02x%02x", &r, &g, &b); 00140 color.red = (unsigned short)r; 00141 color.green = (unsigned short)g; 00142 color.blue = (unsigned short)b; 00143 return scb_color_to_dev_color(&color); 00144 }

| char _g_htmlColor[SCB_MAX_COLOR_LEN] = {0} |
Definition at line 73 of file scbcolor.c.
1.5.6