SaveLayers example for C++ 5.0 and later

   ILEADRasterIO *pRasterIO=NULL; 
   CoCreateInstance(CLSID_LEADRasterIO, NULL, CLSCTX_ALL, IID_ILEADRasterIO, (void**)&pRasterIO); 


   ILEADRaster *pRaster2=NULL; 
   CoCreateInstance(CLSID_LEADRaster, NULL, CLSCTX_ALL, IID_ILEADRaster, (void**)&pRaster2); 

// Save all the extra bitmaps in the bitmap list as layers
   pRasterIO->SaveLayers= TRUE; 
   for(int i=1 ; i<m_RasterView1.GetRaster ().GetBitmapListCount(); ++i) 
   {
      // reset the layer info so all the layers are saved from 0,0 offset
      pRasterIO->PutLayerLeft(m_RasterView1.GetRaster(), i, 0); 
      pRasterIO->PutLayerTop(m_RasterView1.GetRaster(), i, 0); 
      pRasterIO->PutLayerBlendModeKey(m_RasterView1.GetRaster(), i, "dark");
      pRasterIO->PutLayerClipping(m_RasterView1.GetRaster(), i, 0); 
      pRasterIO->PutLayerOpacity(m_RasterView1.GetRaster(), i, 40); 
      
      pRaster2->Bitmap = 0; 
      pRasterIO->SetLayerMaskBitmap(m_RasterView1.GetRaster(), pRaster2, i); 
   }
   // set the active bitmap to be the first in the list
   pRasterIO->Save(m_RasterView1.GetRaster (), "c:\\temp\\layers.psd", FILE_PSD, 0, QFACTOR_LEAD_0, SAVE_OVERWRITE); 

   pRaster2->Release();
   pRasterIO->Release();