All pastes #523695 Raw Edit

Unnamed

public text v1 · immutable
#523695 ·published 2007-05-30 21:25 UTC
rendered paste body
procedure TLibForm.CreateBoxes(cols: Integer);
var
row: Integer;
i,j : Integer;
bmpUnit: TBitmap;
scroll,marginx,marginy: Integer;
destWidth,destHeight: Integer;
begin
  CenterImage.Width:=Screen.Width;
  booksBoxes:=TList.Create;
  pressBoxes:=TList.Create;
  row:=5;
  scroll:=30;
  marginx:=30;
  marginy:=30;
  destWidth:=Screen.Width-scroll-marginx;
  destWidth:=Round(destWidth/(row-1));
  destWidth:=destWidth-marginx;
  ShowMessage('Kniga size'+IntToStr(destWidth));

  libmp:=TBitmap.Create;
  libmp.Canvas.Lock;
  libmp.Width:=CenterImage.Width;
  libmp.Height:=(lib.pressUnits.Count div row)+(lib.booksUnits.Count div row)+2;
    j:=0;


for i:=0 to lib.pressUnits.Count-1 do
     begin
     bmpUnit:=TBitmap.Create;
     bmpUnit.Assign(DGSingleImage(DGPressUnit(lib.pressUnits[0]).thumb).normal);
     if i=0 then
     begin
       libmp.Height:=libmp.Height*(marginy+destWidth);
       destHeight:=Round(destWidth*(bmpUnit.Width/bmpUnit.Height));
     end;
     BMPZoom(bmpUnit,destWidth,destHeight);
     libmp.Canvas.Draw(marginx+(marginx+destHeight)* (i-((i div row)*row)),
          marginy+(marginy+destWidth)* (i div row),bmpUnit);
     bmpUnit.Free;
     j:=i;
     end;

for i:=0 to lib.booksUnits.Count-1 do
     begin
     bmpUnit:=TBitmap.Create;
     bmpUnit.Assign(DGSingleImage(DGPressUnit(lib.booksUnits[0]).thumb).normal);
     if i=0 then
     begin
       libmp.Height:=libmp.Height*(marginy+destWidth);
       destHeight:=Round(destWidth*(bmpUnit.Width/bmpUnit.Height));
     end;
     BMPZoom(bmpUnit,destWidth,destHeight);
     libmp.Canvas.Draw(marginx+(marginx+destHeight)* ((i+j)-(((i+j) div 4)*4)),
          marginy+(marginy+destWidth)* ((i+j) div 4),bmpUnit);
     bmpUnit.Free;
     end;

     libmp.Canvas.Unlock;
     CenterImage.Picture.Assign(libmp);
end;