LoadMemoryTile example for C++ Builder
int TForm1::LoadMemoryTile(AnsiString szFilename, int nLeft, int nTop, int nWidth, int nHeight)
{
int nRet;
int iSize;
int hFileInMemory = 0;
// Check the passed parameter
if (szFilename == "")
{
return ERROR_INV_PARAMETER;
}
// Load a bitmap at its own bits per pixel
LEADImage1->Load(szFilename, 0, 1, 1);
// Save the image as a CMP file in memory
LEADImage1->SaveMemory(hFileInMemory, FILE_CMP, 24, 2, iSize);
// Free the temporary bitmap
LEADImage1->Bitmap = 0;
// Get the pointer to the memory-resident file
GlobalLock((HGLOBAL)hFileInMemory);
// Load the required bitmap tile
nRet= LEADImage1->LoadMemoryTile((L_HANDLE)hFileInMemory, 0, 1, 1, iSize, nLeft, nTop, nWidth, nHeight);
// Clean up
GlobalUnlock ((HGLOBAL)hFileInMemory);
GlobalFree ((HGLOBAL)hFileInMemory);
return nRet;
}