L_LTFIL_API L_INT L_LoadMemoryTile(pBuffer, pBitmap, uStructSize, nCol, nRow, uWidth, uHeight, nBitsPerPixel, nOrder, uFlags, pfnCallback, pUserData, nBufferSize, pLoadOptions, pFileInfo)
Loads a section of an image file (any format), using a callback function. The section begins at (
nRow) and extends
uWidth pixels across and
uHeight pixels down.
Pointer to the file in memory to be loaded.
Pointer to the bitmap handle for the loaded data.
Size in bytes, of the structure pointed to by
pBitmap for versioning. Use sizeof(BITMAPHANDLE).
Left column number of tile.
Top row number of tile.
Tile width in pixels.
Tile height in pixels.
Resulting bitmap pixel depth. The following are valid values:
|0||Keep the original file's pixel depth (Do not convert). A special note about loading 12 and 16-bit grayscale images.|
|1 to 8||The specified bits per pixel in the resultant bitmap|
|12||12 bits per pixel in the resultant bitmap|
|16||16 bits per pixel in the resultant bitmap|
|24||24 bits per pixel in the resultant bitmap|
|32||32 bits per pixel in the resultant bitmap|
|48||48 bits per pixel in the resultant bitmap|
|64||64 bits per pixel in the resultant bitmap|
The desired color order. Possible values are:
|ORDER_RGB|| Red-green-blue order.|
|ORDER_BGR|| Blue-green-red order.|
|ORDER_GRAY|| 12 or 16-bit grayscale image. 12 and 16-bit grayscale images are only supported in Document and Medical Imaging toolkits.|
|0||The data is 8 bits per pixel or less.|
|ORDER_RGBORGRAY|| Load the image as red, green, blue OR as a 12 or 16-bit grayscale image. 12 and 16-bit grayscale images are supported in Document and Medical Imaging toolkits.|
|ORDER_BGRORGRAY|| Load the image as blue, green, red OR as a 12 or 16-bit grayscale image. 12 and 16-bit grayscale images are supported in Document and Medical Imaging toolkits.|
|ORDER_ROMM|| ROMM order. ROMM only supports 24 and 48-bit images.|
|ORDER_BGRORGRAYORROMM|| Load the image as red, green, blue OR as a 12 or 16-bit grayscale image OR as ROMM. 12 and 16-bit grayscale images are supported in Document and Medical Imaging toolkits. ROMM only supports 24 and 48-bit color images.|
Binary flags that determine the behavior of L_LoadMemoryTile. You can specify one or more of the following values:
|LOADFILE_ALLOCATE||[0x0001] The function allocates memory for the specified bitmap. (Setting the LOADFILE_STORE flag will override this flag.)|
|LOADFILE_STORE||[0x0002] The function loads data into the specified bitmap. (This takes place in addition to the actions of your callback function.)|
|LOADFILE_FIXEDPALETTE||[0x0004] This flag will force a palletized image to be dithered to a fixed palette.|
|LOADFILE_NOINTERLACE||[0x0008] The function passes image data in the order that is displayed, regardless of how it is stored in the file. (Set this flag if your program does not handle interlaced file formats.)|
|LOADFILE_ALLPAGES||[0x0010] The function loads all pages of a multi-page file. Use this flag only if you are creating a bitmap list using the L_AppendPlayback function.|
|LOADFILE_NOINITBITMAP||[0x0020] The function does not initialize the bitmap handle when it loads the file. Use this flag only if you are supplying all of the required information in the BITMAPHANDLE structure.|
|LOADFILE_COMPRESSED||[0x0040] (Document and Medical Imaging toolkits) If possible, load the file as a 1-bit RLE-compressed image. For more information, refer to Speeding Up 1-Bit Documents.|
|LOADFILE_SUPERCOMPRESSED||[0x0080] (Document and Medical Imaging toolkits) Load 1-bit or 24-bit images as super compressed. This flag is ignored if the bitmaps are not loaded as 1-bit or 24-bit.|
|LOADFILE_MULTITHREADED||[0x2000] Use Multithreaded load|
Optional callback function for additional processing.
If you do not provide a callback function, use NULL as the value of this parameter.
If you do provide a callback function, use the function pointer as the value of this parameter.
The callback function must adhere to the function prototype described in FILEREADCALLBACK Function.
Void pointer that you can use to pass one or more additional parameters that the callback function needs.
To use this feature, assign a value to a variable or create a structure that contains as many fields as you need. Then, in this parameter, pass the address of the variable or structure, casting it to L_VOID *. The callback function, which receives the address in its own pUserData parameter, can cast it to a pointer of the appropriate data type to access your variable or structure.
If the additional parameters are not needed, you can pass NULL in this parameter.
Size of the file in memory (in bytes).
Pointer to optional extended load options. Pass NULL to use the default load options.
Pointer to a FILEINFO structure. This structure may contain file information used in loading an image, or it may be updated with information about the file being loaded.
If nothing is known about the file, pass NULL for this parameter, or declare a variable of type FILEINFO and set the FILEINFO.Flags to 0, then pass the address of the FILEINFO structure in this parameter. In this case, if the address of a FILEINFO structure is passed, the FILEINFO structure will be updated with the results of L_FileInfo.
If only the file type is known, set pFileInfo.Format to the file type and set pFileInfo.Flags to FILEINFO_FORMATVALID. This can also be done if L_FileInfo has been called previously, but values that affect the size of the image loaded have been changed (for example, by calling L_SetPCDResolution or L_SetWMFResolution). In this case the FILEINFO structure pointed to by pFileInfo will be updated with the results of L_FileInfo.
If L_FileInfo has been called prior to calling this function, and no changes have been made to the contents of the structure filled by L_FileInfo, then the address of the filled FILEINFO structure can be passed for this parameter. In this case, the FILEINFO.Flags member should be set to FILEINFO_INFOVALID. The L_FileInfo function will set the FILEINFO.Flags to FILEINFO_INFOVALID. In this case the load will be faster since this function does not have to query the file filters for the file type.
Note: Local variables are not initialized (since they are placed on the stack). So if you have a FILEINFO structure as a local variable, the value of its Flags parameter is undefined, possibly having FILEINFO_INFOVALID or FILEINFO_FORMATVALID set. That is why it is important to initialize FILEINFO.Flags before passing the address of the FILEINFO structure to the function.
|SUCCESS||The function was successful.|
|< 1||An error occurred. Refer to Return Codes.|
This function is very similar to L_LoadFileTile, except that it loads the image from a buffer instead of a file.
Support for 12 and 16-bit grayscale images is only available in the Document and Medical Imaging toolkits.
More options are available in the LOADFILEOPTION structure.
You should never pass an uninitialized FILEINFO structure to this function.
Required DLLs and Libraries
Win32, x64, Linux.
Load a portion of an image without loading the entire image.
// read the file into the buffer. The error checking is reduced for clarity
L_INT ReadFileIntoBuffer(L_UCHAR *pBuffer, L_OFFSET nBufferSize, L_TCHAR *pszFile)
HANDLE hFile = CreateFile(pszFile, GENERIC_READ, 0, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
if(hFile == INVALID_HANDLE_VALUE)
ReadFile(hFile, pBuffer, (DWORD)nBufferSize, &dwBytesRead, NULL);
L_UCHAR *pBuffer; /* Pointer to the data in memory */
TCHAR *pszFileName = MAKE_IMAGE_PATH(TEXT("clean.tif"));
memset(&FileInfo, 0, sizeof(FILEINFO));
FileInfo.uStructSize = sizeof(FileInfo);
nRet = L_FileInfo(pszFileName, &FileInfo, sizeof(FILEINFO), 0, NULL);
if(nRet != SUCCESS)
// allocate a memory buffer large enough to contain the file
pBuffer = (L_UCHAR*)malloc((SIZE_T)FileInfo.SizeDisk);
nRet = ReadFileIntoBuffer(pBuffer, FileInfo.SizeDisk, pszFileName);
if(nRet != SUCCESS)
// Load 1/2 from an image (center)
nRet = L_LoadMemoryTile(pBuffer, &Bitmap, sizeof(BITMAPHANDLE), FileInfo.Width/4, FileInfo.Height/4, (FileInfo.Width)/2, (FileInfo.Height)/2, 0, ORDER_BGR, LOADFILE_ALLOCATE | LOADFILE_STORE, NULL, NULL, (L_SSIZE_T)FileInfo.SizeDisk, NULL, &FileInfo);
if(nRet != SUCCESS)
free(pBuffer); // free the memory buffer, as we are done with it
nRet = L_SaveBitmap(MAKE_IMAGE_PATH(TEXT("Result.BMP")), &Bitmap, FILE_BMP, 24, 0, NULL);
if(nRet != SUCCESS)
Medical Web Viewer .NET
.NET, Java, Android, and iOS/macOS Assemblies
C API/C++ Class Libraries