LoadMemoryTile example for Delphi
Function TForm1.LoadMemoryTile(sFilename: String; nLeft: Integer; nTop: Integer; nWidth: Integer; nHeight: Integer): Integer;
var
nRet: Integer;
iSize: Integer;
hFileInMemory: L_HANDLE;
begin
// Check the passed parameter
if (sFilename = '') Then
begin
Result:= ERROR_INV_PARAMETER;
Exit;
end;
hFileInMemory := 0;
// Load a bitmap at its own bits per pixel
LEADImage1.Load(sFilename, 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(hFileInMemory);
// Load the required bitmap tile
nRet:= LEADImage1.LoadMemoryTile(hFileInMemory, 0, 1, -1, iSize, nLeft, nTop, nWidth, nHeight);
// Clean up
GlobalUnlock (hFileInMemory);
GlobalFree (hFileInMemory);
Result:= nRet;
end;