當我嘗試設置BMP.Height或BMP.Width時,嘗試使用BMP文件時,出現「EOutofresources - 存儲空間不足」。在這些指令後,立即執行堆棧跟蹤(按此順序): ntdll.dll.RtlLeaveCriticalSection,kernel32.dll.FileTimeToDosDateTime,GDI32.dll.GdiReleaseDC,GDI32.dll.PatBlt,kernel32.dll.ReadFile或如下所示:使用位圖時出現「存儲空間不足」錯誤
|7E429130|user32.dll GetParent
|7C90FF2D|ntdll.dll RtlGetNtGlobalFlags
|77F15A00|GDI32.dll GdiReleaseDC
|7C83069E|kernel32.dll FileTimeToDosDateTime
|7C9010E0|ntdll.dll RtlLeaveCriticalSection
| |my function (where I set BMP.Height or BMP.Width)
此刻我確信它必須做一些內存碎片 - 系統有足夠的空閒RAM來處理我的映像,但內存碎片化,所以沒有足夠大的塊來保存我的映像。但之後我在Windows啓動11秒後就看到它發生了。我的程序在循環中循環,只處理一次圖像!所以,這不能與RAM碎片相關。
不同的情況(但仍與繪圖),當我得到這個錯誤是下面:
|77F16A7E|GDI32.dll IntersectClipRect
|77F16FE5|GDI32.dll BitBlt
|7E429011|user32.dll OffsetRect
|7E42A97D|user32.dll CallWindowProcA
|7E42A993|user32.dll CallWindowProcA
|7C9010E0|ntdll.dll RtlLeaveCriticalSection
|7E4196C2|user32.dll DispatchMessageA
|7E4196B8|user32.dll DispatchMessageA
|0058A2E1|UTest.exe UTest.dpr
|7C90DCB8|ntdll.dll ZwSetInformationThread
我想總會有BMP.Height後的堆棧跟蹤「RtlLeaveCriticalSection」呼叫。
有this後指向一個可能的解決方案通過編輯Windows註冊表項。但是,這篇文章說它只適用於Win XP。雖然也出現在Win 7
我的錯誤,我看到很多類似的帖子(其中有些是接近連接到文件保存到磁盤),但直到沒人回來報告說,他固定的錯誤。
更新:
根據你的要求,這就是出現錯誤代碼:
procedure TMyBitmap.SetLargeSize(iWidth, iHeight: Integer);
CONST ctBytesPerPixel= 3;
begin
{ Protect agains huge/empty images }
if iWidth< 1 then iWidth:= 1 else
if iWidth> 32768 then iWidth:= 32768;
if iHeight< 1 then iHeight:= 1 else
if iHeight> 32768 then iHeight:= 32768;
{ Set image type }
if iWidth * iHeight * ctBytesPerPixel > 9000000 {~9MB}
then HandleType:= bmDIB { Pros and cons: -no hardware acceleration, +supports larger images }
else HandleType:= bmDDB;
{ Total size is higher than 1GB? }
if (iWidth* iHeight* ctBytesPerPixel) > 1*GB then
begin
Width := 8000; { Set a smaller size }
Height := 8000; { And rise an error }
RAISE Exception.Create('Image is too large.');
end;
{ Set size }
Width := iWidth; <----------------- HERE
Height:= iHeight;
end;
請顯示源代碼...它聽起來更像是一個資源泄漏(即處理泄漏)比內存問題... – Yahia
位圖有多大? –
位圖可以有任何大小。通常他們應該是正常的數碼相機圖片(4-16 Mpixels)。 – Ampere