如何提升 ImageList Add 的速度 |
尚未結案
|
雪豆豆
一般會員 發表:19 回覆:22 積分:13 註冊:2002-08-18 發送簡訊給我 |
在 ImageList 加入大量圖檔的速度真是慢到不行
測試 160*120 加入 300 張影像要花 10 秒鐘
有無辦法提升呢?
http://ad.shanger.net/bean/imagelist.zip <-- 點這個 Link 下載測試程式
|
minjiu
中階會員 發表:27 回覆:119 積分:69 註冊:2002-06-26 發送簡訊給我 |
|
雪豆豆
一般會員 發表:19 回覆:22 積分:13 註冊:2002-08-18 發送簡訊給我 |
|
Chance36
版主 發表:31 回覆:1033 積分:792 註冊:2002-12-31 發送簡訊給我 |
雪豆豆 你好
試著將程式碼改成如下片段,也可像minjiu 兄的電腦一樣猛喔! procedure TForm1.Button1Click(Sender: TObject); var tBmp :TBitmap; //Thumbnail Bitmap i :Integer; StartTime : TDateTime; begin StartTime := now(); ImageList.Clear; //清空 ImageList ImageList.Width := StrToInt(Ed_Width.Text); ImageList.Height := StrToInt(Ed_Height.Text); //一次配置足够空間 ImageList.AllocBy := StrToInt(Ed_Count.Text) ; for i := 0 to StrToInt(Ed_Count.Text)-1 do Begin tBmp := TBitmap.Create; // with tBmp do begin Width := ImageList.Width; Height := ImageList.Height; Canvas.Brush.Color := clwhite; // Canvas.FillRect(Rect(1,1,ImageList.Width,ImageList.Height)); // end; // 逐個Image使用取代的方式更新 ImageList.Replace(i,tBmp,nil); End; Label1.Caption := '共消秏 : ' diffTime(StartTime,now) ' 時間'; end;PS:我用PIII-550 512MRam 第一次增加300 顯示00秒(好快呀),再按一次時則顯示02秒(還要將300個bmp釋放掉,所以變慢了),若一次增加1000時則顯示09秒,應該够猛了吧。 _______________________________________ 深藍的魚,祝您好運..........連連 |
wearefamily
一般會員 發表:12 回覆:16 積分:5 註冊:2004-03-13 發送簡訊給我 |
|
kwedr
一般會員 發表:1 回覆:1 積分:0 註冊:2004-07-19 發送簡訊給我 |
tBmp := TBitmap.Create; //將這行 往上移 就可以解決 記憶體不足的問題
for i := 0 to StrToInt(Ed_Count.Text)-1 do Begin with tBmp do begin
Width := ImageList.Width;
Height := ImageList.Height;
Canvas.Brush.Color := clwhite; //
Canvas.FillRect(Rect(1,1,ImageList.Width,ImageList.Height)); //
end; ~未來仍漫長~
------
~未來仍漫長~ |
本站聲明 |
1. 本論壇為無營利行為之開放平台,所有文章都是由網友自行張貼,如牽涉到法律糾紛一切與本站無關。 2. 假如網友發表之內容涉及侵權,而損及您的利益,請立即通知版主刪除。 3. 請勿批評中華民國元首及政府或批評各政黨,是藍是綠本站無權干涉,但這裡不是政治性論壇! |