GetColorCount Example for C++ Builder

This example displays a message box showing the number of unique colors in the control's current bitmap.

   LEADRasterProcess* pRasterProc= NULL;
   AnsiString szMessage; //Buffer for the MessageBox string
   int NumberOfColors; //Number of colors in the bitmap

     CoCreateInstance(CLSID_LEADRasterProcess, NULL, CLSCTX_ALL, IID_ILEADRasterProcess, (void**)&pRasterProc);
   //Get the number of colors in the bitmap
   NumberOfColors= pRasterProc->GetColorCount (LEADRasterView1->Raster);
   pRasterProc-> Release( );
   //Display the result in a message
   szMessage= "The bitmap has " + IntToStr(NumberOfColors) + " colors";
   MessageBox (Handle, szMessage.c_str(), "Notice", MB_OK ) ;