//COLORREF转换为字符串
BOOL CDataManager::GetRGBText(std::string &strRGBText , COLORREF color)
{
//COLORREF col = RGB( 255 , 12 , 4);
BYTE Red = GetRValue(color); ///得到红颜色
BYTE Green = GetGValue(color); ///得到绿颜色
BYTE Blue = GetBValue(color); ///得到兰颜色
char chR[4];
itoa(Red ,chR , 10 );
char chG[4];
itoa(Green , chG , 10);
char chB[4];
itoa(Blue , chB , 10);
std::string strR , strG, strB;
strR = chR ;
strG = chG;
strB = chB;
strRGBText = strR + "," + strG + "," + strB;
return TRUE;
}
//字符串转换为COLORREF,如("32","34","21")
BOOL CDataManager::GetColorRGB(CString strColorText , COLORREF& color)
{
char chR[4] = "", chG[4] = "", chB[4] = "";
sscanf( strColorText, "%[^,],%[^,],%[^,]", chR, chG, chB);
color = RGB(atoi(chR), atoi(chG), atoi(chB));
return TRUE;
}
浙公网安备 33010602011771号