CTimeSpan span = t2 - t1
int nIndex = (int)span.GetTotalSeconds //得出程序运行的开始t1 到t2 运行的时间段的毫秒数
CString str;
str.format(_T("%d:%02d:%02d"),nIdex / 3600,nIdex %3600/60,nIdex %3600%60);
十进制颜色值转换RGB
void ToRGB(int color)
{
int rgb[3];
memset(rgb,0,sizeof(a));
int b = (color &0xff);
int g = (color>>8)&0xff;
int r = (color>>16)&0xff;
rgb[0] = r;
rgb[1] = g;
rgb[2] = b;
}
RGB转换十进制
int Rgb2int(int rr, int gg,int bb)
{
int color = ((rr << 16) | (gg << 8) | bb);
return color;
}
RGB 计算公式:
颜色值 = (65536 * Blue) + (256 * Green) + (Red)
RGB值转换16进制
#include <sstream>
#include <string>
using namespace std;
std::string rgb2hex(int r, int g, int b, bool with_head)
{
stringstream ss;
if (with_head)
ss << "#";
ss << std::hex << (r << 16 | g << 8 | b);
return ss.str();
}
int main()
{
int r = 255;
int g = 255;
int b = 255;
string ss = rgb2hex(r, g, b, true);
return 0;
}