sznray
sznray
采纳率0%
2015-08-25 09:14 阅读 1.7k

把大图片分成四张小图片,定义了一个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条回答 默认 最新

  • caozhy 从今以后生命中的每一秒都属于我爱的人 2015-08-25 23:39

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

    点赞 评论 复制链接分享

相关推荐