GetHistogramGray example for C++ Builder

//This example gets a histogram for a 12-bit or 16-bit grayscale image and then
//displays the number of occurrences of the brightest and darkest intensities
   int nRet;
   LEADRasterProcess* pRasterProc= NULL;

     CoCreateInstance(CLSID_LEADRasterProcess, NULL, CLSCTX_ALL, IID_ILEADRasterProcess, (void**)&pRasterProc);

   ShowMessage ("Table size before call to GetHistogramGray: " + IntToStr((int)pRasterProc->HistogramGrayTableSize));
   nRet = pRasterProc->GetHistogramGray (LEADRasterView1->Raster);
   if (nRet== 0)
   {
      LEADRasterView1->Raster->GetMinMaxVal ();
      ShowMessage ("Highest Intensity: 0x" + IntToHex((int)LEADRasterView1->Raster->MaxVal, 4) + "  Count: " + IntToStr((int)pRasterProc->get_HistogramGrayTable (LEADRasterView1->Raster->MaxVal))
      + "\nLowest Intensity: 0x" + IntToHex((int)LEADRasterView1->Raster->MinVal, 4) + "  Count: " + IntToStr((int)pRasterProc->get_HistogramGrayTable(LEADRasterView1->Raster->MinVal)));
   }
   ShowMessage ("Table size of current histogram: " + IntToStr((int)pRasterProc->HistogramGrayTableSize));
   pRasterProc-> Release( );