L_LTFIL_API L_INT L_LoadBitmap(pszFile, pBitmap, uStructSize, nBitsPerPixel, nOrder, pLoadOptions, pFileInfo)
Loads an image file into a bitmap. The file can be in any supported image file format and bits per pixel, whether compressed or uncompressed.
Note: More options are available in the LOADFILEOPTION structure.
Character string containing the name of the file to load.
Pointer to the bitmap handle referencing the target bitmap.
Size in bytes, of the structure pointed to by
pBitmap, for versioning. Use sizeof(BITMAPHANDLE).
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.|
Color order for 16-, 24-, 32-, 48-, and 64-bit bitmaps. If the resultant bitmap is less than 16 bits per pixel, this will have no effect since palletized images have no order. The following are valid values:
|ORDER_RGB|| Red, green, and blue color order in memory|
|ORDER_BGR|| Blue, green, and red color order in memory|
|ORDER_GRAY|| 12- or 16-bit grayscale image. 12- and 16-bit grayscale images are only supported in the Document and Medical Imaging toolkits.|
|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 the 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 the 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 the Document and Medical Imaging toolkits. ROMM only supports 24- and 48-bit color images.|
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_FileInfohas 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.|
Support for 12- and 16-bit grayscale images is available in Document and Medical Imaging toolkits.
For supported formats, refer to Files To Be Included With Your Application.
Before calling this function, you may need to get or set file information, such as the page number of a multipage file or the resolution of a PCD file. Refer to Getting and Setting File Information.
The function will initialize the bitmap handle and allocate the storage necessary to hold the image. If the bits per pixel of the file is larger than 8 bits, the image data will be loaded in the same color order as the one passed to the function in
Since the function allocates storage to hold the image, it is up to you to free this storage by calling L_FreeBitmap.
Warning: The function will return ERROR_INV_PARAMETER if nOrder was set to ORDER_GRAY and the image file was not 12- or 16-bits per pixel.
If Document/Medical support is unlocked, and the format being loaded is FILE_LEAD1BIT, FILE_CCITT_GROUP3_1DIM, FILE_CCITT_GROUP3_2DIM, FILE_CCITT_GROUP4, FILE_ICA_G3_1D, FILE_ICA_G3_2D, FILE_ICA_G4, FILE_RAWICA_G3_1D, FILE_RAWICA_G3_2D, FILE_RAWICA_G4, FILE_FAX_G3_1D, FILE_FAX_G3_2D, FILE_FAX_G4, FILE_WFX_G3_1D, or FILE_WFX_G4, the image data will be loaded compressed. For more information, refer to Speeding Up 1-Bit Documents.
If you are loading a PDF file, LEADTOOLS loads all PDF files as Raster PDF uncompressed (FILE_RAS_PDF), regardless of the compression and color space used when saving the file.
You should never pass an uninitialized FILEINFO structure to this function.
Required DLLs and Libraries
Win32, x64, Linux.
For complete sample code, refer to the FEATURE1 example. This example loads a bitmap
/* Bitmap handle to hold the loaded image. */
/* Load the bitmap, keeping the bits per pixel of the file */
nRet = L_LoadBitmap (MAKE_IMAGE_PATH(TEXT("IMAGE1.CMP")), &LeadBitmap, sizeof(BITMAPHANDLE), 0, ORDER_BGR, NULL, NULL);
if(nRet != SUCCESS)
Medical Web Viewer .NET
.NET, Java, Android, and iOS/macOS Assemblies
C API/C++ Class Libraries