unit uSiluet;

{$mode delphi}

interface

type

{ TSiluet }

TSiluet = class
  W, H : Integer;
  Mask : array of array of Boolean;
  constructor Create(filename : string); overload;
  constructor Create(Src : TSiluet; pX, pY, pW, pH : Integer);
end;


implementation

{ TSiluet }

type
  TFig = record
    W, H : Integer;
    A : array[1..512, 1..128] of Boolean;
  end;

constructor TSiluet.Create(filename: string);
var
  X, Y : Integer;
  A : TFig;
  AFile : File of TFig;
begin
  AssignFile(AFile, filename);
  Reset(AFile);
  Read(AFile, A);
  CloseFile(AFile);
  W := A.W;
  H := A.H;
  SetLength(Mask, W + 1, H + 1);

  for X := 1 to A.W do
  for Y := 1 to A.H do
   Mask[X, Y] := A.A[X, Y];


end;

constructor TSiluet.Create(Src: TSiluet; pX, pY, pW, pH: Integer);
var
  X, Y : Integer;
begin
  if pX + pW > Src.W then
    pW := Src.W - pX;
  if pY + pH > Src.H then
    pH := Src.H - pY;
  W := pW;
  H := pH;

  SetLength(Mask, W + 1, H + 1);
  for X := 1 to pW do
  for Y := 1 to pH do
   Mask[X][Y] := Src.Mask[X + pX][Y + pY];

end;

end.

