LoadArray example for C++ Builder
void __fastcall TForm1::LoadArrayClick(TObject *Sender)
{
long lCount;
HFILE hFile;
HGLOBAL hData=NULL;
char* pData=NULL;
ILEADRasterIO *pRasterIO=NULL;
ILEADRasterVariant* pRasterVar= NULL;
CoCreateInstance(CLSID_LEADRasterIO, NULL, CLSCTX_ALL,
IID_ILEADRasterIO, (void**)&pRasterIO);
CoCreateInstance( CLSID_LEADRasterVariant,
NULL,
CLSCTX_ALL,
IID_ILEADRasterVariant,
(void**)&pRasterVar);
hFile = _lopen("c:\\babe.cmp", OF_READ);
lCount = _llseek(hFile, 0, SEEK_END);
_llseek(hFile, 0, SEEK_SET);
hData = GlobalAlloc(GMEM_MOVEABLE, lCount);
pData= (char*)GlobalLock(hData);
_lread(hFile, pData, lCount);
pRasterVar->set_Type(VALUE_ARRAY_BYTE);
pRasterVar->ItemCount= lCount;
for (int i=0; i < lCount; i ++ )
{
pRasterVar->set_ShortItemValue(i, pData[i]);
}
GlobalUnlock(hData);
GlobalFree(hData);
pRasterIO->LoadArray( LEADRasterView1->Raster,
pRasterVar,
0,
0,
-1,
lCount);
_lclose(hFile);
if ( pRasterIO )
pRasterIO->Release();
if ( pRasterVar )
pRasterVar->Release();
}