ShowHistogramDlg example for Delphi

procedure TForm1.ShowHistogramDlg1Click(Sender: TObject); 
var
   i: L_INT; 
begin
   LEADImage1.GetHistogram ( CHANNEL_MASTER ); 
   LEADDlgImage1.MasterHistogramLen:= LEADImage1.HistogramTableSize; 

   for i:= 0 to LEADImage1.HistogramTableSize-1 do
   begin
      LEADDlgImage1.MasterHistogram [i]:= LEADImage1.HistogramTable[i]; 
   end; 

   LEADImage1.GetHistogram ( CHANNEL_RED ); 
   LEADDlgImage1.RedHistogramLen:= LEADImage1.HistogramTableSize; 

   for i:= 0 to LEADImage1.HistogramTableSize-1 do
   begin
      LEADDlgImage1.RedHistogram [i]:= LEADImage1.HistogramTable[i]; 
   end; 

   LEADImage1.GetHistogram ( CHANNEL_GREEN ); 
   LEADDlgImage1.GreenHistogramLen:= LEADImage1.HistogramTableSize; 

   for i:= 0 to LEADImage1.HistogramTableSize-1 do
   begin
      LEADDlgImage1.GreenHistogram [i]:= LEADImage1.HistogramTable[i]; 
   end; 

   LEADImage1.GetHistogram ( CHANNEL_BLUE ); 
   LEADDlgImage1.BlueHistogramLen:= LEADImage1.HistogramTableSize; 

   for i:= 0 to LEADImage1.HistogramTableSize-1 do
   begin
      LEADDlgImage1.BlueHistogram [i]:= LEADImage1.HistogramTable[i]; 
   end; 

   LEADDlgImage1.HistogramFlags:= HIST_LOWHIGH_BITS; 
   LEADDlgImage1.BlueChannelPenColor:= RGB ( 0, 0, 255 ); 
   LEADDlgImage1.GreenChannelPenColor:= RGB ( 0, 255, 0 ); 
   LEADDlgImage1.RedChannelPenColor:= RGB ( 255, 0, 0 ); 
   LEADDlgImage1.MasterPenColor:= RGB ( 0, 0, 0 ); 
   LEADDlgImage1.DlgFlags:= DLG_HISTOGRAM_SHOW_VIEWSTYLE Or
                            DLG_HISTOGRAM_USERPENCOLORS; 

   LEADDlgImage1.ShowHistogramDlg ( Self ); 
end;