Available in the LEADTOOLS Imaging toolkit. |
HSV_HfromRGB example for C++ 4.0 and later
//Takes an RGB, displays the RGB components, and displays the HSV components
void CColorReplaceDlg::RGBtoHSV(COLORREF cr)
{
int nR, nG, nB, nH, nS, nV;
char szMsg[100];
nR = GetRValue(cr);
nG = GetGValue(cr);
nB = GetBValue(cr);
nH = m_Lead.HSV_HfromRGB(cr);
nS = m_Lead.HSV_SfromRGB(cr);
nV = m_Lead.HSV_VfromRGB(cr);
wsprintf(szMsg, "RGB(%d,%d,%d) is HSV(%d,%d,%d)", nR, nG, nB, nH, nS, nV);
::MessageBox(NULL, szMsg, "", MB_OK);
}