AnnLoadArray example for Delphi

Note:

This topic is for Document/Medical only.

var
//Global declarations
RasterAnn: LEADRasterAnnotation;
RasterAnnToolbar: LEADRasterAnnToolBar;

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

procedure TForm1.AnnLoadArrayClick(Sender: TObject);
var
   i: Smallint;
   Buffer: Variant;
   MyBufferPtr: Pointer;
   BytesRead: Longint;
   FileHandle: integer;
   RasterVarBuffer: LEADRasterVariant;
begin
   Buffer:= VarArrayCreate([0, 4000-1], varByte);
   MyBufferPtr:= AllocMem(4000);
   FileHandle:= FileOpen('c:\test.ann', fmOpenRead );
   if (FileHandle > 0) then
   begin
      BytesRead:= FileRead(FileHandle, MyBufferPtr^, 4000 );  // read from the file
      for i:= 0 to BytesRead-1 do
         Buffer[i]:= Byte((Pchar(MyBufferPtr)+i)^);
      RasterVarBuffer.StringValue:= Buffer;
      RasterAnn.AnnLoadArray ( RasterVarBuffer, BytesRead, 1 );
   end;
   FreeMem(MyBufferPtr);
   FileClose( FileHandle );
end;