全國最多中醫師線上諮詢網站-台灣中醫網
發文 回覆 瀏覽次數:2690
推到 Plurk!
推到 Facebook!

如何提升 ImageList Add 的速度

尚未結案
雪豆豆
一般會員


發表:19
回覆:22
積分:13
註冊:2002-08-18

發送簡訊給我
#1 引用回覆 回覆 發表時間:2004-08-15 11:45:31 IP:203.222.xxx.xxx 未訂閱
在 ImageList 加入大量圖檔的速度真是慢到不行 測試 160*120 加入 300 張影像要花 10 秒鐘 有無辦法提升呢?  http://ad.shanger.net/bean/imagelist.zip <-- 點這個 Link 下載測試程式
minjiu
中階會員


發表:27
回覆:119
積分:69
註冊:2002-06-26

發送簡訊給我
#2 引用回覆 回覆 發表時間:2004-08-16 12:33:43 IP:220.130.xxx.xxx 未訂閱
插花一下~~~ 在我的電腦建立160x120的300張只花2秒,建立1000張也只花10秒 =.=a
雪豆豆
一般會員


發表:19
回覆:22
積分:13
註冊:2002-08-18

發送簡訊給我
#3 引用回覆 回覆 發表時間:2004-08-16 12:46:20 IP:203.222.xxx.xxx 未訂閱
minjiu 兄的電腦比較猛吧... 呵呵
Chance36
版主


發表:31
回覆:1033
積分:792
註冊:2002-12-31

發送簡訊給我
#4 引用回覆 回覆 發表時間:2004-08-17 00:17:30 IP:203.204.xxx.xxx 未訂閱
雪豆豆  你好
  試著將程式碼改成如下片段,也可像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

發送簡訊給我
#5 引用回覆 回覆 發表時間:2004-08-21 18:39:57 IP:210.66.xxx.xxx 未訂閱
這個方式真的很快, 可以搭配Listview嗎? 我搭配 Listview,會掛掉 另外160*120 3000個大一點時,還會出現" 存放體空間不足,無法處理此命令" 請問要如合解決?
kwedr
一般會員


發表:1
回覆:1
積分:0
註冊:2004-07-19

發送簡訊給我
#6 引用回覆 回覆 發表時間:2004-08-27 16:09:58 IP:203.69.xxx.xxx 未訂閱
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; ~未來仍漫長~
------
~未來仍漫長~
系統時間:2024-05-04 7:32:37
聯絡我們 | Delphi K.Top討論版
本站聲明
1. 本論壇為無營利行為之開放平台,所有文章都是由網友自行張貼,如牽涉到法律糾紛一切與本站無關。
2. 假如網友發表之內容涉及侵權,而損及您的利益,請立即通知版主刪除。
3. 請勿批評中華民國元首及政府或批評各政黨,是藍是綠本站無權干涉,但這裡不是政治性論壇!