unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, ExtCtrls, ExtDlgs;
type
TForm1 = class(TForm)
OpenPictureDialog1: TOpenPictureDialog;
Button1: TButton;
Image1: TImage;
Button2: TButton;
procedure FormCreate(Sender: TObject);
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
private
{ Private declarations }
procedure AddRight(const FileName: string);
procedure AddBottom(const FileName: string);
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.FormCreate(Sender: TObject);
begin
Image1.AutoSize:=True
end;
procedure TForm1.AddRight(const FileName: string);
var
Bitmap: TBitmap;
OldWidth: Integer;
begin
BitMap:=TBitmap.Create;
try
BitMap.LoadFromFile(FileName);
OldWidth:=Image1.Picture.Width;
Image1.AutoSize:=False;
Image1.Picture.Bitmap.Width:=Image1.Picture.Width+Bitmap.Width;
if Bitmap.Height>Image1.Picture.Height then
Image1.Picture.Bitmap.Height:=Bitmap.Height;
Image1.AutoSize:=True;
Image1.Canvas.CopyRect(Rect(OldWidth, 0, OldWidth+Bitmap.Width, Bitmap.Height),
Bitmap.Canvas, Rect(0, 0, Bitmap.Width, Bitmap.Height))
finally
Bitmap.Free
end
end;
procedure TForm1.Button1Click(Sender: TObject);
begin
if OpenPictureDialog1.Execute then
AddRight(OpenPictureDialog1.FileName)
end;
procedure TForm1.AddBottom(const FileName: string);
var
Bitmap: TBitmap;
OldHeight: Integer;
begin
BitMap:=TBitmap.Create;
try
BitMap.LoadFromFile(FileName);
OldHeight:=Image1.Picture.Height;
Image1.AutoSize:=False;
Image1.Picture.Bitmap.Height:=Image1.Picture.Height+Bitmap.Height;
if Bitmap.Width>Image1.Picture.Width then
Image1.Picture.Bitmap.Width:=Bitmap.Width;
Image1.AutoSize:=True;
Image1.Canvas.CopyRect(Rect(0, OldHeight, Bitmap.Width, OldHeight+Bitmap.Height),
Bitmap.Canvas, Rect(0, 0, Bitmap.Width, Bitmap.Height))
finally
Bitmap.Free
end
end;
procedure TForm1.Button2Click(Sender: TObject);
begin
if OpenPictureDialog1.Execute then
AddBottom(OpenPictureDialog1.FileName)
end;
end.