Advertisement
TLama

Untitled

Aug 13th, 2014
392
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Delphi 1.14 KB | None | 0 0
  1. var
  2.   X, Y: Integer;    // column and row iterators
  3.   DstArea: TRect;   // destination area
  4.   Margins: TSize;   // calculated margins between images
  5.   ImgSize: TSize;   // size of a single image
  6.   ImgOrig: TPoint;  // target image origin
  7.   CntCols: Integer; // actual number of columns
  8.   CntRows: Integer; // actual number of rows
  9.   MaxRows: Integer; // maximum number of columns that can be placed in the area
  10.   MaxCols: Integer; // maximum number of rows that can be placed in the area
  11. begin
  12.   DstArea := ???;
  13.  
  14.   MaxCols := ???;
  15.   MaxRows := ???;
  16.  
  17.   ImgSize.cx := ???;
  18.   ImgSize.cy := ???;
  19.  
  20.   CntCols := Min(DstArea.Width div ImgSize.cx, MaxCols);
  21.   CntRows := Min(DstArea.Height div ImgSize.cy, MaxRows);
  22.   Margins.cx := (DstArea.Width - (CntCols * ImgSize.cx)) div (CntCols + 1);
  23.   Margins.cy := (DstArea.Height - (CntRows * ImgSize.cy)) div (CntRows + 1);
  24.  
  25.   for X := 0 to CntCols - 1 do
  26.     for Y := 0 to CntRows - 1 do
  27.     begin
  28.       ImgOrig.X := (X * ImgSize.cx) + ((X + 1) * Margins.cx);
  29.       ImgOrig.Y := (Y * ImgSize.cy) + ((Y + 1) * Margins.cy);
  30.      
  31.       SomeCanvas.Draw(ImgOrig.X, ImgOrig.Y, SomeImage);
  32.     end;
  33. end;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement