把大图片分成四张小图片,定义了一个TBitmap指针数组,循环LoadFromFile,执行报错!

for(height=ImageHeight;height<=Image1->Height;height+=ImageHeight)
for(width=ImageWidth;width<=Image1->Width;width+=ImageWidth)
{
Application->ProcessMessages();
if(IdChange == true)
{
for(i;i>=0;i--)
delete pBitmap[i];
//lbTis->Caption = "";
return;
}
lbTis->Caption = "正在加载图片...";
String filename = DataModule5->adoqryPicture->FieldByName("name")->AsString;
String pathheader = "F:\";
String path = pathheader+ filename;
pBitmap[i] = new Graphics::TBitmap();
pBitmap[i]->LoadFromFile(path);

            SrcRect = Rect(0,0,pBitmap[i]->Width,pBitmap[i]->Height);
            DstRect = Rect(width-ImageWidth,height-ImageHeight,width,height);
            Image1->Canvas->CopyRect(DstRect,pBitmap[i]->Canvas,SrcRect);
            DataModule5->adoqryPicture->RecNo++;
            i++;
            //delete pBitmap;
        }

进入第二次循环时会报错“存储空间不足,无法执行该命令”

1个回答

先要调用deleteobject删除位图对象,再delete
另外你的delete都不配对,或者你的代码不完整,有内存泄漏。检查下

Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
立即提问
相关内容推荐