#include "l_bitmap.h"
L_LTFIL_API L_INT L_LoadLayer(pszFile, pBitmap, uStructSize, nBitsPerPixel, nOrder, nLayer, pLayerInfo, pLoadOptions)
Loads the specified layer from the specified file. Currently only PSD files support layers.
Character string containing the name of the file from which to load the layer.
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:
Value | Meaning |
---|---|
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:
Value | Meaning |
---|---|
ORDER_RGB | [0] Red, green, and blue color order in memory |
ORDER_BGR | [1] Blue, green, and red color order in memory |
ORDER_GRAY | [2] 12 or 16-bit grayscale image. 12 and 16-bit grayscale images are only supported in Document and Medical Imaging toolkits. |
ORDER_RGBORGRAY | [3] 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 | [4] 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 | [5] ROMM order. ROMM only supports 24 and 48-bit images. |
ORDER_BGRORGRAYORROMM | [6] 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. |
Index of the layer to load. This index is zero-based. Pass 0 to load the first layer, 1 to load the second layer, etc.
Pointer to a LAYERINFO structure to be updated with information about the loaded layer. Pass NULL for this parameter if layer information is not needed. If this parameter contains a valid pointer to a LAYERINFO structure, the lSize member should be set to the sizeof (LAYERINFO) before calling this function.
Pointer to optional extended load options. Pass NULL to use the default load options.
Value | Meaning |
---|---|
SUCCESS | The function was successful. |
< 1 | An error occurred. Refer to Return Codes. |
Support for 12 and 16-bit grayscale images is only available in Document and Medical Imaging toolkits.
Currently, only the PSD file format supports layers.
This function works similarly to the L_LoadBitmap function, except that it loads only a layer from a file. It loads the layer specified in nLayer
.
Before calling this function, you may need to get or set file information, such as the number of layers on the file. Refer to Getting and Setting File Information.
The number of layers in a file is indicated in FILEINFO.Layers. If FILEINFO.Layers is 0, the file does not contains any layers and this function should not be called.
Since the function allocates storage to hold the image, it is up to you to free this storage by calling L_FreeBitmap.
Required DLLs and Libraries
Win32, x64, Linux.
This example loads the first layer from a file.
#define IDM_TEST_LOADLAYER_0 0
#define IDM_TEST_LOADLAYER_1 1
#define IDM_TEST_LOADLAYER_2 2
L_INT LoadLayerExample(L_INT nId)
{
L_INT nRet = 0;
FILEINFO FileInfo;
BITMAPHANDLE Bitmap;
LAYERINFO LayerInfo;
L_INT nIndex= 0;
L_TCHAR *pszLayer = NULL;
switch(nId)
{
case IDM_TEST_LOADLAYER_0:
nIndex = 0;
pszLayer = MAKE_IMAGE_PATH(TEXT("Layer0.psd"));
break;
case IDM_TEST_LOADLAYER_1:
nIndex = 1;
pszLayer = MAKE_IMAGE_PATH(TEXT("Layer1.psd"));
break;
case IDM_TEST_LOADLAYER_2:
nIndex = 2;
pszLayer = MAKE_IMAGE_PATH(TEXT("Layer2.psd"));
break;
}
memset(&FileInfo, 0, sizeof(FILEINFO));
FileInfo.uStructSize = sizeof(FileInfo);
nRet = L_FileInfo(MAKE_IMAGE_PATH(TEXT("Bear.psd")), &FileInfo, sizeof(FILEINFO), 0, NULL);
if(nRet == SUCCESS)
{
if(FileInfo.Layers)
{
nRet = 0;
/* I have to set the lSize member of LayerInfo, otherwise L_LoadLayer will fail */
memset(&LayerInfo, 0, sizeof(LAYERINFO));
LayerInfo.uStructSize = sizeof(LAYERINFO);
nRet = L_LoadLayer(MAKE_IMAGE_PATH(TEXT("Bear.psd")), &Bitmap, sizeof(BITMAPHANDLE), 0, ORDER_BGRORGRAY, nIndex, &LayerInfo, NULL);
if(nRet != SUCCESS)
return nRet;
nRet = L_SaveBitmap(pszLayer, &Bitmap, FILE_PSD, 24, 0, NULL);
if(nRet != SUCCESS)
return nRet;
}
}
return nRet;
}
Help Collections
Raster .NET | C API | C++ Class Library | HTML5 JavaScript
Document .NET | C API | C++ Class Library | HTML5 JavaScript
Medical .NET | C API | C++ Class Library | HTML5 JavaScript
Medical Web Viewer .NET
Multimedia
Direct Show .NET | C API | Filters
Media Foundation .NET | C API | Transforms
Supported Platforms
.NET, Java, Android, and iOS/macOS Assemblies
Imaging, Medical, and Document
C API/C++ Class Libraries
Imaging, Medical, and Document
HTML5 JavaScript Libraries
Imaging, Medical, and Document