AddImgToRepository

Declaration: Frm2DImg.AddImgToRepository(Data: TDouble2DArray; OffsX, OffsY: integer; Caption, Subcaption: string): integer;
Adds the data in the array Data to the image repository of the 2D Imager. The size of the matrix Data need not be the same as the lateral size of the data cube and can be copied to any position of the repository (the repository images always have the same the size as the images in the data cube). The parameters OffsX and OffsY control the offset of the lower left corner. OffsX has a valid range between -length(Data) and MData.SizeX, OffsY has a valid range between -length(Data[0]) and MData.SizeY.

The parameter Caption specifies the caption of the selection tab. It must not be longer than 15 characters. The parameter Subcaption is displayed above the image and is not restricted in length. The function returns an access handle to the special image (1 to 16), or a negative number in the case of an error:

-1 ... the maximum number of special images (16) has been reached
-2 ... the size of the Data array does not match the data cube
-3 ... OffsX and/or OffsY are outside the range of the repository
Please note that the access handle of the create repository image can be used to adjust image parameters (colors, zoom, display mode etc.) later on.

Sample program: The following code lets you select a few layers, then calculates the sum of the selected layers and visualizes the resulting matrix as a special image in the 2D Imager:

program LayerSum;

var
  imgmat    : TDouble2DArray;
  i         : integer;
  ll        : TIntArray;
  Weights   : TDoubleArray;

begin
SetLength(ll,0);
if SelectLayer (1,true,true,ll,'Please select the layers to be added up') > 0 then
  begin
  SetLength(Weights, length(ll));
  for i:=1 to length(ll) do
    Weights[i-1] := 1;
  WeightedSumOfLayers (ll, Weights, 1, imgmat);
  AddImgToRepository (imgmat, 0, 0, 'Sum',
        'sum of the following layers: '+IntList(ll,'; '));
  end;
end.