此代码可实现你的要求:(www.huasoft.net)
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, jpeg, ExtCtrls, Mask, Grids, Buttons, dbcgrids,
AppEvnts, Menus;
type
TForm1 = class(TForm)
Image: TImage;
Image1: TImage;
MainMenu1: TMainMenu;
N1: TMenuItem;
Image2: TImage;
N2: TMenuItem;
N3: TMenuItem;
procedure ImageMouseMove(Sender: TObject; Shift: TShiftState; X,
Y: Integer);
procedure FormCreate(Sender: TObject);
procedure N1Click(Sender: TObject);
procedure N3Click(Sender: TObject);
procedure N2Click(Sender: TObject);
procedure ImageMouseDown(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
procedure Image1MouseDown(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
private
{自定义过程}
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
mx,my:Integer;
implementation
{$R *.dfm}
procedure TForm1.ImageMouseMove(Sender: TObject; Shift: TShiftState; X,
Y: Integer);
begin
if shift<>[] then
with TImage(Sender) do
begin
Left:=Left+x-mx;
Top:=Top+y-my;
end;
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
Form1.DoubleBuffered:=true;
end;
procedure TForm1.N1Click(Sender: TObject);
begin
Image2.Picture.SaveToFile('c:/合成.bmp');
showmessage('图像已经存到C:/合成.bmp');
end;
procedure TForm1.N3Click(Sender: TObject);
begin
Image2.Width:=1;Image2.Height:=1;
Image2.Visible:=false;
end;
procedure TForm1.N2Click(Sender: TObject);
begin
Image2.Width:=form1.ClientWidth;
Image2.Height:=form1.ClientHeight;
Image2.Picture:=nil;
Image2.Canvas.Draw(Image.Left,Image.Top,Image.Picture.Graphic);
Image2.Canvas.Draw(Image1.Left,Image1.Top,Image1.Picture.Graphic);
Image2.Visible:=true;
Image2.BringToFront;
end;
procedure TForm1.ImageMouseDown(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
begin
mx:=x;
my:=y;
if ssright in shift then Image.BringToFront;
end;
procedure TForm1.Image1MouseDown(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
begin
mx:=x;
my:=y;
if ssright in shift then Image1.BringToFront;
end;
end.