LFile::LoadLayer

#include "ltwrappr.h"

virtual L_INT LFile::LoadLayer(nBitsPerPixel, nOrder, nLayer, pLayerInfo=NULL, pLoadOptions=NULL)

Loads the specified layer from the class object's associated bitmap. Currently only PSD files support layers.

Parameters

L_INT nBitsPerPixel

Resulting bitmap pixel depth. The following are valid values:

Value Meaning
0 Keep the original file's pixel depth (Do not convert).
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

L_INT nOrder

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 supported in the Document/Medical 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 the Document/Medical 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 Document/Medical toolkits.

L_INT nLayer

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.

pLAYERINFO pLayerInfo

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.

pLOADFILEOPTION pLoadOptions

Pointer to optional extended load options. Pass NULL to use the default load options.

Returns

Value Meaning
SUCCESS The function was successful.
< 1 An error occurred. Refer to Return Codes.

Comments

Support for 12 and 16-bit grayscale images is available in the Document/Medical toolkits.

Currently, only the PSD file format supports layers.

This function works similarly to the LFile::Load 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 LBitmapBase::Free.

Required DLLs and Libraries

Platforms

Win32, x64.

See Also

Functions

Topics

Example

L_INT LFile__LoadLayerExample(LFile & File, LBitmapBase & Bitmap, L_TCHAR * pszFile, L_INT nLayer) 
{ 
   L_INT nRet; 
   FILEINFO FileInfo; 
 
   File.SetBitmap(&Bitmap); 
   File.SetFileName(pszFile); 
   nRet = File.GetInfo(&FileInfo, sizeof(FILEINFO)); 
   if(nRet != SUCCESS) 
      return nRet; 
 
   if (FileInfo.Layers) 
   { 
      if (FileInfo.Layers > nLayer) 
      { 
         nRet  =  File.LoadLayer(0, ORDER_BGRORGRAY, nLayer); 
         if(nRet!=SUCCESS) 
         { 
           LBase::DisplayErrorFromList(); 
 
           return nRet; 
         } 
      } 
      else 
         MessageBox(NULL, TEXT("Invalid layer index!"), TEXT("Testing"), MB_OK); 
   } 
   else 
      MessageBox(NULL, TEXT("No layers in the file!"), TEXT("Testing"), MB_OK); 
 
   return SUCCESS; 
} 
Help Version 21.0.2021.7.2
Products | Support | Contact Us | Intellectual Property Notices
© 1991-2021 LEAD Technologies, Inc. All Rights Reserved.

LEADTOOLS Raster Imaging C++ Class Library Help
Products | Support | Contact Us | Intellectual Property Notices
© 1991-2021 LEAD Technologies, Inc. All Rights Reserved.