定义一个TBitmap对象,循环加载图片,有时会出错,有时可以执行成功!

TRect SrcRect,DstRect;
int width,height;
ImageWidth = Image1->Width/ImageNum;
ImageHeight = Image1->Height/ImageNum;
Graphics::TBitmap* pBitmap=new Graphics::TBitmap();
for(height=ImageHeight;height<=Image1->Height;height+=ImageHeight)
for(width=ImageWidth;width<=Image1->Width;width+=ImageWidth)
{
Application->ProcessMessages();
if(IdChange == true)
break;
bTis->Caption = "正在加载图片...";
String filename = DataModule5->adoqryPicture->FieldByName("name")->AsString;
String pathheader = "F:\";
String path = pathheader+ filename;
pBitmap->LoadFromFile(path);

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

进入循环执行第二次时,在SrcDest = Rect(0,0,pBitmap->Width,pBitmap->Height);处出现“存储空间不足,无法执行此命令”!

1个回答

是不是图片尺寸太大了?
http://bbs.csdn.net/topics/300073357

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