AnnSaveArray example for Delphi

Note:

This topic is for Document/Medical only.

var
//Global declarations
RasterAnn: LEADRasterAnnotation;

procedure TForm1.Button1Click(Sender: TObject);
begin
   RasterAnn:= CoLEADRasterAnnotation.Create ();
   RasterAnn.AnnParentRasterView := LEADRasterView1.Raster;
   LEADEventSink1.Connect (RasterAnn, _LEADRasterAnnotationEvents);
   RasterAnn.AnnUserMode:= ANN_USERMODE_DESIGN;
end;

var
   RasterVarBuffer: LEADRasterVariant;
   RasterIO: LEADRasterIO;
   lSize: longint;
   MyBufferPtr: Pointer;
   FileHandle: L_HANDLE;
   uWrite: cardinal;
begin
   RasterIO:= CoLEADRasterIO.Create ();
   RasterVarBuffer:= coLEADRasterVariant.Create ( );

   RasterAnn.AnnSaveArray ( ANN_FMT_NATIVE, True, RasterVarBuffer, SAVE_OVERWRITE, 0 );
   FileHandle:= CreateFile ( 'c:\test.ann',
                             GENERIC_WRITE,
                             0,
                             Nil,
                             OPEN_ALWAYS,
                             FILE_ATTRIBUTE_NORMAL,
                             0 );
   if (FileHandle > 0 ) then
   begin
      lSize:= RasterIO.ArraySize (RasterVarBuffer);
      MyBufferPtr := AllocMem(lSize);
      StrLCopy ( MyBufferPtr, PChar(RasterVarBuffer.StringValue), lSize );
      writeFile ( FileHandle, MyBufferPtr^, lSize, uWrite, Nil );
      FreeMem(MyBufferPtr);
   end;
  FileClose (FileHandle);
end;