存储空间不足的问题(急救!)(50)

  • 主题发起人 主题发起人 shubiao123
  • 开始时间 开始时间
S

shubiao123

Unregistered / Unconfirmed
GUEST, unregistred user!
begin begin nextonescreen:=TBitmap.Create; nextonescreen.Width:=13; nextonescreen.Height:=20; nextonedc:=GetDC(0); nextonescreenCanvas:=TCanvas.Create; nextonescreenCanvas.Handle:=nextonedc; nextonescreen.Canvas.CopyRect(Rect(0,0,13,20),nextonescreenCanvas,Rect(832,509,845,529)); //自 nextonescreen.PixelFormat:=pf4bit; nextoneresult:=True; nextonebmp:=loadbitmap(hinstance,'nextonepokeend'); img_nextonepoke.Picture.Bitmap.Handle:=nextonebmp; for nextonex:=4 to nextonescreen.Width-4 do begin for nextoney:=5 to nextonescreen.Height-13 do begin if nextonescreen.Canvas.Pixels[nextonex,nextoney]<>img_nextonepoke.picture.Bitmap.Canvas.Pixels[nextonex,nextoney] then begin nextoneresult:=false; end; end; end; if nextoneresult then begin tmr2_getnextpoke_data.Enabled:=True ; end else tmr2_getnextpoke_data.Enabled:=False; end; nextonescreen.Free; nextonescreenCanvas.Free; MessageBeep(1);end;请高手帮我看看这段代码为什么会出现存储空间不足呢?且光标指向nextoneresult:=True;,
 
大概意思是把桌面832,509,845,529区域和一张图片做比较?这代码真不容易看懂...if nextonescreen.Canvas.Pixels[nextonex,nextoney]<>img_nextonepoke.picture.Bitmap.Canvas.Pixels[nextonex,nextoney] then begin nextoneresult:=false;这里少了个Break;if nextoneresult then begin tmr2_getnextpoke_data.Enabled:=True ; end else tmr2_getnextpoke_data.Enabled:=False; end;这个可以这么写:tmr2_getnextpoke_data.Enabled := nextoneresult;LZ的代码我运行没问题
 
楼上的大哥我改成你那样还是存储控件不足啊?请各位大哥、大姐帮帮忙啊?我这代码是写在timer控件里的,是不跟timer控件有关系呢?
 
既然在 timer 里面 ,可以会 涉及 到 线程 问题, 需要 保护 某些东西,2是 不要反复申请内存,3是 加大 timer 间隔, 然后优化代码
 
接受答案了.
 

Similar threads

S
回复
0
查看
1K
SUNSTONE的Delphi笔记
S
S
回复
0
查看
911
SUNSTONE的Delphi笔记
S
S
回复
0
查看
3K
SUNSTONE的Delphi笔记
S
S
回复
0
查看
2K
SUNSTONE的Delphi笔记
S
后退
顶部