SetBitmapListValue Example for Delphi

Procedure TForm1.TestProcList();
var
   nCount: Integer;
   nRet: Integer;
   IO: LEADRasterIO;
   Process: LEADRasterProcess;
begin

   IO:= coLEADRasterIO.Create();
   Process:= coLEADRasterProcess.Create();

   LEADDicomDS1.EnableMethodErrors:= False;

   //move to the root element
   LEADDicomDS1.MoveFirstElement (False);
   LEADDicomDS1.MoveRootElement ();

   //insert a new element for the BitmapList Value
   nRet:= LEADDicomDS1.FindFirstElement (TAG_PIXEL_DATA, False);
   nRet:= LEADDicomDS1.DeleteElement ();
   nRet:= LEADDicomDS1.InsertElement (False, TAG_PIXEL_DATA, VR_OB, False, 0);

   //load an image
   IO.Load(LEADRasterView1.Raster, 'd:\lead14\dist\images\image1.cmp', 0, 1, 1);
   ShowMessage('Image loaded from File - Wait');

   //create a bitmap list
   LEADRasterView2.Raster.InsertBitmapListItem(0, LEADRasterView1.Raster.Bitmap);
   Process.Flip(LEADRasterView1.Raster);
   LEADRasterView2.Raster.InsertBitmapListItem(1, LEADRasterView1.Raster.Bitmap);
   Process.Reverse(LEADRasterView1.Raster);
   LEADRasterView2.Raster.InsertBitmapListItem(2, LEADRasterView1.Raster.Bitmap);

   //insert the image list into the element
   LEADDicomDS1.BitmapList:= LEADRasterView2.Raster.BitmapList;

   //set the bitmap list
   nRet:= LEADDicomDS1.SetBitmapListValue(DICOM_IMAGE_COMPRESSION_NONE, DICOM_IMAGE_PHOTOMETRIC_RGB, 0, 0, 0);

   if(nRet <> 0)then
   begin
      ShowMessage('Error');
      Exit;
   end;
   ShowMessage('Image set to Data Set - Wait');

   LEADDicomDS1.BitmapList:= 0; //free the value
   ShowMessage('ImageList cleared from memory - Wait');

   nCount:= LEADDicomDS1.GetBitmapCount ();

   //get the bitmap list back
   if(nRet = 0)then
   begin
      gbQuit:= False;
      LEADDicomDS1.GetBitmapListValue(0, nCount, 0, ORDER_RGB, 0);
      LEADRasterView1.Raster.BitmapList:= LEADDicomDS1.BitmapList;
      LEADRasterView1.ForceRepaint();
   end;
   LEADDicomDS1.EnableMethodErrors:= True;
   ShowMessage('ImageList loaded from Data Set - Wait');
end;