LFile::SaveWithLayers

#include "ltwrappr.h"

virtual L_INT LFile::SaveWithLayers(nFormat, nBitsPerPixel, nQFactor, pLayers, pLayerInfo=NULL, nLayers=0, pSaveOptions=NULL)

Saves the class object's associated bitmap to a file, along with the specified layers.

Parameters

L_INT nFormat

Output file format. Currently, only PSD (FILE_PSD) files support layers.

L_INT nBitsPerPixel

Resulting file's pixel depth. For color images this can be 24 or 32. For grayscale images, this can be 8.

L_INT nQFactor

Reserved for future use. Pass 0.

LBitmapList * pLayers

Pointer to an LBitmapList object that contains the layers to save in the output file. The layers should have the same bits per pixel as the file. Every bitmap in the list will be saved as a layer. The first bitmap in the list will be interpreted as the first layer. The bitmaps in the bitmap list must have the same bits per pixel as specified in nBitsPerPixel.

pLAYERINFO pLayerInfo

Pointer to an optional array of LAYERINFO structures. If this is NULL, then each layer will start at (0, 0) and will have the same size as the image. If this is not NULL, then the layer information for each layer in hLayers will be stored here. The number of LAYERINFO structures is given in nLayers.

L_INT nLayers

The number of LAYERINFO structures in the pLayerInfo array. This value should be the same as the number of bitmaps in the hLayers bitmap list. This parameter is used only if pLayerInfo is not NULL.

pSAVEFILEOPTION pSaveOptions

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

Returns

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

Comments

Currently, only the PSD format supports layers.

This function supports signed data images, but only DICOM and TIFF formats support signed data. This function will return an error code if you attempt to save a signed image to a format other than DICOM or TIFF.

If the bitmap has a region, the region stored in the bitmap will be saved, if the image is saved as one of the TIFF file formats.

Required DLLs and Libraries

Platforms

Win32, x64.

See Also

Functions

Topics

Example

L_INT LFile__SaveBitmapWithLayersExample(L_TCHAR * pszOutFile, L_TCHAR * pszFile, L_TCHAR * pszLayers[], L_INT nLayers) 
{ 
   L_INT nRet; 
   LBitmapBase Bitmap; 
   LBitmapList Layers; 
   LFile File; 
 
   nRet = Layers.Create(); 
   if(nRet != SUCCESS) 
      return nRet; 
 
   for (L_INT i = 0; i < nLayers; i++) 
   { 
      nRet = Bitmap.Load(pszLayers[i]); 
      if(nRet != SUCCESS) 
         return nRet; 
      nRet = Layers.InsertItem(&Bitmap); 
      if(nRet != SUCCESS) 
         return nRet; 
   } 
 
   nRet = Bitmap.Load(pszFile); 
   if(nRet != SUCCESS) 
      return nRet; 
   File.SetFileName(pszOutFile); 
   File.SetBitmap(&Bitmap); 
 
   nRet = File.SaveBitmapWithLayers(FILE_PSD, 0, 0, &Layers); 
   if(nRet != SUCCESS) 
      return nRet; 
 
   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.