发变一个picture(100分)

  • 主题发起人 主题发起人 flysand
  • 开始时间 开始时间
F

flysand

Unregistered / Unconfirmed
GUEST, unregistred user!
//先执行本过程,改变form1.image1.picture,并把原image1.picture保存到form1.fpicture
procedure tform1.bnt1click(sender:tobject);
var
tmpPicture:tPicture;
begin
tmpPicture:=image1.Picture;
image1.Picture:=fPicture; // form1.fPicture:tpicture已建立并保存了一图片
fPicture:=tmpPicture; //保存不了
Update;
end;

//执行此过程,不能得到原form1.image1.picture;
procedure tform1.bnt2click(sender:tobject);
var
tmpPicture:tPicture;
begin
tmpPicture:=image1.Picture;
image1.Picture:=fPicture;
fPicture:=tmpPicture;
Update;
end;

我错在哪?
 
什么意思? picture控件? 干吗?
 
用TBitmap试一下。
 
把 := 改为 Assign
procedure tform1.bnt1click(sender:tobject);
var
tmpPicture:tPicture;
begin
tmpPicture.Assign (image1.Picture);
image1.Picture.Assign (fPicture);
fPicture.Assign (tmpPicture); Update;
end;

procedure tform1.bnt2click(sender:tobject);
var
tmpPicture:tPicture;
begin
tmpPicture.Assign (image1.Picture);
image1.Picture.Assign (fPicture);
fPicture.Assign (tmpPicture);
Update;
end;
 
var
tmpPicture:tPicture;
begin
tmpPicture.Assign (image1.Picture);
image1.Picture.Assign (fPicture);
fPicture.Assign (tmpPicture);
Update;
end;
 
:= 只是地址直接链接
用.Assign才会复制啦
 
二個事件都一樣,建議改成這樣,我調試可以成功:
procedure TForm1.BitBtn1Click(Sender: TObject);
var
tmpPicture:tPicture;
begin
tmpPicture:=tPicture.Create; //不要忘記
tmpPicture.Assign(image1.Picture);//此有變化
image1.Picture:=fPicture;
fPicture:=tmpPicture;
Update;
end;
 
多人接受答案了。
 
后退
顶部