Janilabo

Untitled

Aug 26th, 2013
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pascal 0.94 KB | None | 0 0
  1. procedure ResizeTPA(var TPA: TPointArray; AWidth, AHeight: Integer);
  2. var
  3.   w, h, l, i, x, y: Integer;
  4.   m: array of TBoolArray;
  5.   b: TBox;
  6. begin
  7.   l := Length(TPA);
  8.   if (l > 0) then
  9.   begin
  10.     b := GetTPABounds(TPA);
  11.     w := ((b.X2 - b.X1) + 1);
  12.     h := ((b.Y2 - b.Y1) + 1);
  13.     if (AWidth <> w) or (AHeight <> h) then
  14.     begin
  15.       SetLength(m, w);
  16.       for x := 0 to (w - 1) do
  17.       begin
  18.         SetLength(m[x], h);
  19.         for y := 0 to (h - 1) do
  20.           m[x][y] := False;
  21.       end;
  22.       for i := 0 to (l - 1) do
  23.         m[(TPA[i].X - b.X1)][(TPA[i].Y - b.Y1)] := True;
  24.       SetLength(TPA, 0);
  25.       l := 0;
  26.       for y := 0 to (AHeight - 1) do
  27.         for x := 0 to (AWidth - 1) do
  28.           if m[((x * w) div aWidth)][((y * h) div aHeight)] then
  29.           begin
  30.             SetLength(TPA, (l + 1));
  31.             TPA[l] := Point((x + b.X1), (y + b.Y1));
  32.             Inc(l);
  33.           end;
  34.     end;
  35.   end;
  36. end;
Advertisement
Add Comment
Please, Sign In to add comment