All pastes #11532 Raw Edit

Stuff

public text v1 · immutable
#11532 ·published 2005-05-11 20:26 UTC
rendered paste body
global vars:

  PhotoCount,PhotoSpace, PhotosPrRow,PhotoNumber: Integer;
  Files: TStrings;
  Photos: Array of Timage;



(......)



procedure TFormMain.MenuOpenClick(Sender: TObject);
var
   i,j: integer;
   Jpg: TJpegImage;
begin
   if OpenPictureDialog.Execute then
   begin
      MenuAdd.Visible:=true;
      MenuOpen.Visible:=false;
      Files:=OpenPictureDialog.Files;
      PhotoCount:=Files.Count;
      SetLength(Photos,PhotoCount);
      PhotosPrRow:=(FormMain.Width - MinPhotoSpace) div (MiniPhotoWidth + MinPhotoSpace);
      PhotoSpace:=(FormMain.Width - PhotosPrRow * MiniPhotoWidth) div (PhotosPrRow+1)-1;
      for i:=0 to (Ceil(PhotoCount / PhotosPrRow) - 1) do
      begin
         for j:=0 to (PhotosPrRow - 1) do
         begin
            PhotoNumber:=i*PhotosPrRow+j;
            Photos[PhotoNumber]:=TImage.Create(FormMain);
            with Photos[PhotoNumber] do
            try
               Parent:=FormMain;
               Tag:=PhotoNumber;
               Top:=PhotoSpace+i*(PhotoSpace+MiniPhotoHeight);
               Left:=PhotoSpace+j*(PhotoSpace+MiniPhotoWidth);
               Width:=MiniPhotoWidth;
               Height:=MiniPhotoHeight;
               Center:=true;
               Stretch:=true;
               Proportional:=true;
               OnMouseDown := FlipBitmapRight;
            except Photos[PhotoNumber].Free;
            end;

            Jpg:=TJpegImage.Create;
            Jpg.LoadFromFile(Files[PhotoNumber]);
            Photos[PhotoNumber].Picture.Bitmap.Assign(Jpg);
            Jpg.Free;

            MenuAdd.Visible:=true;

            if PhotoCount-1=PhotoNumber then break;
         end;
      end;
   end;

end;


procedure TFormMain.MenuAddClick(Sender: TObject);
var
   i,j: integer;
   Jpg: TJpegImage;
begin
   if OpenPictureDialog.Execute then
   begin
      Files.AddStrings(OpenPictureDialog.Files);
      PhotoCount:=Files.Count;
      SetLength(Photos,PhotoCount);
      for i:=0 to (Ceil(PhotoCount / PhotosPrRow) - 1) do
      begin
         for j:=0 to (PhotosPrRow - 1) do
         begin
            PhotoNumber:=i*PhotosPrRow+j;
            if not Assigned(Photos[PhotoNumber]) then
            begin
               Photos[PhotoNumber]:=TImage.Create(FormMain);
               with Photos[PhotoNumber] do
               try
                  Parent:=FormMain;
                  Tag:=PhotoNumber;
                  Top:=PhotoSpace+i*(PhotoSpace+MiniPhotoHeight);
                  Left:=PhotoSpace+j*(PhotoSpace+MiniPhotoWidth);
                  Width:=MiniPhotoWidth;
                  Height:=MiniPhotoHeight;
                  Center:=true;
                  Stretch:=true;
                  Proportional:=true;
                  OnMouseDown := FlipBitmapRight;
                except Photos[PhotoNumber].Free;
                end;

                Jpg:=TJpegImage.Create;
                Jpg.LoadFromFile(Files[PhotoNumber]);
                Photos[PhotoNumber].Picture.Bitmap.Assign(Jpg);
                Jpg.Free;

            end;
            if PhotoCount-1=PhotoNumber then break;
         end;
      end;
   end;
end;