这里有原代码,请阅读,并“帮忙”!!!!(50分)

  • 主题发起人 主题发起人 出人头地
  • 开始时间 开始时间

出人头地

Unregistered / Unconfirmed
GUEST, unregistred user!
我自己编写的多媒体动画程序,但是一运行就死机,恳请各位大虾help小弟!!!




unit Unit1;

interface

uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
ExtCtrls, StdCtrls,extdlgs, MPlayer;

type
TForm1 = class(TForm)
Image1: TImage;
Button1: TButton;
MediaPlayer1: TMediaPlayer;
procedure Button1Click(Sender: TObject);
procedure FormDestroy(Sender: TObject);
procedure FormCreate(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;


var
Form1: TForm1;

implementation

{$R *.DFM}

const
step=1500;
var
newbmp1,newbmp2,newbmp3,newbmp4,newbmp5,newbmp6,newbmp7,newbmp8:tbitmap;
bmpheight,bmpwidth:integer;
xgroup,xcount:integer;
x0,y0:integer;
midx,midy:integer;
ratiox,ratioy:real;


procedure TForm1.Button1Click(Sender: TObject);
var
i,j,k:integer;
begin

button1.visible:=false;
for k:=1 to 6do

begin


newbmp1:=tbitmap.create;
newbmp1.loadfromfile('1.bmp');
image1.visible:=true;
newbmp1.width:=image1.width;
newbmp1.height:=image1.height;
bmpheight:=image1.height;
bmpwidth:=image1.width;
xgroup:=15;
xcount:=bmpheight div xgroup;
for i:=0 to xcountdo

for j:=0 to xgroupdo

begin

newbmp1.canvas.CopyRect(rect(0,xcount*j+i-

1,bmpwidth,xcount*j+i),image1.canvas,rect(0,xcount*j+i-1,bmpwidth,xcount*j+i));
form1.canvas.draw(0,0,newbmp1);
end;

newbmp1.free;



newbmp2:=tbitmap.create;
newbmp2.loadfromfile('2.bmp');
x0:=width div 2;
y0:=height div 2;
ratiox:=newbmp2.width/step;
ratioy:=newbmp2.height/step;
for i:=0 to stepdo

begin

midx:=round(ratiox*i*0.5);
midy:=round(ratioy*i*0.5);
bitblt(form1.canvas.handle,x0-midx,y0-midy,round(ratiox*i),round

(ratioy*i),newbmp2.canvas.handle,x0
-midx,y0-midy,srccopy);
end;

newbmp2.free;






newbmp3:=tbitmap.create;
newbmp3.loadfromfile('3.bmp');
ratiox:=newbmp3.width/step;
ratioy:=newbmp3.height/step;
for i:=0 to stepdo

begin

bitblt(form1.canvas.handle,0,0,round(ratiox*i*1),round(ratioy*i*1),newbmp3.canvas.handle,0,
0,srccopy);
end;

newbmp3.free;


newbmp4:=tbitmap.create;
newbmp4.loadfromfile('4.bmp');
x0:=0;
y0:=0;
ratiox:=newbmp4.width/step;
ratioy:=newbmp4.height/step;
for i:=0 to stepdo

begin

midx:=round(ratiox*i);
midy:=round(ratioy*i);
bitblt(form1.canvas.handle,0,0,round(ratiox*i),height,newbmp4.canvas.handle,0,
0,srccopy);
end;

newbmp4.free;



newbmp5:=tbitmap.create;
newbmp5.loadfromfile('5.bmp');
x0:=width div 2;
y0:=0;
ratiox:=newbmp5.width/step;
ratioy:=newbmp5.height/step;
for i:=0 to stepdo

begin

midx:=round(ratiox*i*0.5);
midy:=round(ratioy*i);
bitblt(form1.canvas.handle,x0-midx,0,round(ratiox*i*0.5),width,newbmp4.canvas.handle,x0
-midx,0,srccopy);
bitblt(form1.canvas.handle,width div
2,0,round(ratiox*i*0.5),width,newbmp5.canvas.handle,width div 2,0,srccopy);
end;

newbmp5.free;



newbmp6:=tbitmap.create;
newbmp6.loadfromfile('6.bmp');
x0:=width div 2;
y0:=height div 2;
ratiox:=newbmp6.width/step;
ratioy:=newbmp6.height/step;
for i:=0 to stepdo

begin

midx:=round(ratiox*i*0.5);
midy:=round(ratioy*i*0.5);
bitblt(form1.canvas.handle,x0-midx,y0-midy,round(ratiox*i),round

(ratioy*i),newbmp6.canvas.handle,x0 -midx,y0-midy,srccopy);
end;

newbmp6.free;




newbmp7:=tbitmap.create;
newbmp7.loadfromfile('7.bmp');
newbmp7.width:=image1.width;
newbmp7.height:=image1.height;
bmpheight:=image1.height;
bmpwidth:=image1.width;
i:=0;
while i<=bmpheightdo

begin

j:=i;
while j>0do

begin

newbmp7.canvas.copyrect(rect(0,j-1,bmpwidth,j),
image1.canvas,rect(0,bmpheight-i+j-1,bmpwidth,bmpheight-i+j));
newbmp7.canvas.copyrect(rect(0,bmpheight-j,bmpwidth,bmpheight-j+1),image1.canvas,Rect

(0,i-j,bmpwidth,i-j+1));
j:=j-2;
end;

form1.canvas.draw(0,0,newbmp7);
i:=i+2;
end;

end;

newbmp7.free;



newbmp8:=tbitmap.create;
newbmp8.loadfromfile('8.bmp');
newbmp8.width:=image1.width;
newbmp8.height:=image1.height;
bmpheight:=image1.height;
bmpwidth:=image1.width;
i:=0;
while i<=bmpheightdo

begin

j:=i;
while j>0do

begin

newbmp8.canvas.copyrect(rect(0,j-1,bmpwidth,j),
image1.canvas,rect(0,bmpheight-i+j-1,bmpwidth,bmpheight-i+j));
newbmp8.canvas.copyrect(rect(0,bmpheight-j,bmpwidth,bmpheight-j+1),image1.canvas,Rect

(0,i-j,bmpwidth,i-j+1));
j:=j-2;
end;

form1.canvas.draw(0,0,newbmp8);
i:=i+2;
end;

newbmp8.free;
end;





procedure TForm1.FormDestroy(Sender: TObject);
begin

newbmp1.free;
newbmp2.free;
newbmp3.free;
newbmp4.free;
newbmp5.free;
newbmp6.free;
newbmp7.free;
end;






procedure TForm1.FormCreate(Sender: TObject);
{播放mp3声音文件}
begin

mediaplayer1.devicetype:= dtAutoSelect;
mediaplayer1.filename:='1.mp3';{动态调用文件}
mediaplayer1.autoopen:=true;
{设置自动运行}
mediaplayer1.open;
{打开播放器}
mediaplayer1.play;
end;


end.
 
首先,你的程序过于复杂了,应该把他对象化一下,先不要启动cmediaplayer
 
1.既然bitmap2的使用前bitmap1已经被释放,所以根本没必要定义这么多tbitmap
只要一个就可以了。
2。我不知道free后再来create会不会又问题,但是事实上你只需要创建一次对象,并
对该对象使用6*8次后,最后释放就可以了。
 
后退
顶部