W
wpsqsibo12
Unregistered / Unconfirmed
GUEST, unregistred user!
我用了了第三方提供的BMP2GIF控件后,
代码如下
gif:=TGIFImage.Create;
mmm:=extractfilepath(Application.exename)+'temp/';
Screen.Cursor:=crhourglass;
form1.CoolBar2.Visible:=True;
form1.Gauge2.MaxValue:=Form1.ScrollBar2.Max;
for i:=1 to Form1.ScrollBar2.Max do
Begin
Form1.ScrollBar2.Position:=i;
form1.Gauge2.Progress:=i-10;
form1.POLARDraw1.Write(mmm+inttostr(i-1)+'.bmp',3);
End;
bitmap :=TBitmap.Create;
for i:=0 to form1.ScrollBar2.Max-1 do
Begin
try
bitmap.LoadFromFile(mmm+inttostr(i)+'.bmp');
Index :=Gif.Add(bitmap);
If Index=0 Then
Begin
LoopExt := TGIFAppExtNSLoop.Create(GIF.Images[Index]);
LoopExt.Loops := 0; // Forever
LoopExt.BufferSize:=32768;
GIF.Images.Extensions.Add(LoopExt);
End;
Ext := TGIFGraphicControlExtension.Create(GIF.Images[Index]);
If Flag =1 Then
Ext.Delay := 10
Else
If Flag=2 Then
Ext.Delay:=30
Else
Ext.Delay:=60;
GIF.Images[Index].Extensions.Add(Ext);
finally
LoopExt.Free;
LoopExt:=Nil;
Ext.Free;
Ext:=Nil;
End; //.//try ...finally;
End; //for scrollbar 2;
bitmap.FreeImage;
bitmap.Dormant;
bitmap.ReleaseHandle;
bitmap.Free;
bitmap:=Nil;
Gif.SaveToFile(FileName);
Finally
Gif.Free;
但是当BMP数量很多, GIF在ADD的时候内存一直增加,很快就内存益处了,高手们如何解决
代码如下
gif:=TGIFImage.Create;
mmm:=extractfilepath(Application.exename)+'temp/';
Screen.Cursor:=crhourglass;
form1.CoolBar2.Visible:=True;
form1.Gauge2.MaxValue:=Form1.ScrollBar2.Max;
for i:=1 to Form1.ScrollBar2.Max do
Begin
Form1.ScrollBar2.Position:=i;
form1.Gauge2.Progress:=i-10;
form1.POLARDraw1.Write(mmm+inttostr(i-1)+'.bmp',3);
End;
bitmap :=TBitmap.Create;
for i:=0 to form1.ScrollBar2.Max-1 do
Begin
try
bitmap.LoadFromFile(mmm+inttostr(i)+'.bmp');
Index :=Gif.Add(bitmap);
If Index=0 Then
Begin
LoopExt := TGIFAppExtNSLoop.Create(GIF.Images[Index]);
LoopExt.Loops := 0; // Forever
LoopExt.BufferSize:=32768;
GIF.Images.Extensions.Add(LoopExt);
End;
Ext := TGIFGraphicControlExtension.Create(GIF.Images[Index]);
If Flag =1 Then
Ext.Delay := 10
Else
If Flag=2 Then
Ext.Delay:=30
Else
Ext.Delay:=60;
GIF.Images[Index].Extensions.Add(Ext);
finally
LoopExt.Free;
LoopExt:=Nil;
Ext.Free;
Ext:=Nil;
End; //.//try ...finally;
End; //for scrollbar 2;
bitmap.FreeImage;
bitmap.Dormant;
bitmap.ReleaseHandle;
bitmap.Free;
bitmap:=Nil;
Gif.SaveToFile(FileName);
Finally
Gif.Free;
但是当BMP数量很多, GIF在ADD的时候内存一直增加,很快就内存益处了,高手们如何解决