GetColorCount Example for C++ 5.0 and later
This example displays a message box showing the number of unique colors in the control's current bitmap.
// Declare local variables.
TCHAR szMessage[80]; // Buffer for the MessageBox string
long NumberOfColors; // Number of colors in the bitmap
ILEADRasterProcess *pRasterProc=NULL;
CoCreateInstance(CLSID_LEADRasterProcess, NULL, CLSCTX_ALL,
IID_ILEADRasterProcess, (void**)&pRasterProc);
// Get the number of colors in the bitmap.
NumberOfColors = pRasterProc->GetColorCount(m_LEADRasterView1.GetRaster());
// Display the result in a message.
wsprintf( szMessage, TEXT("The bitmap has %ld colors"), NumberOfColors );
MessageBox(szMessage, TEXT("Notice"));
pRasterProc->Release();