Slice Example for Visual C++ 5.0 and later

void CDemoView::OnImageSlice() 
{
   int nRet = theApp.m_pRasterProcess->Slice (m_RasterView.GetRaster (), 500, RGB(0,0,0), SLICE_DESKEW|SLICE_DESKEW_LINEAR|SLICE_CUT_SLICES, TRUE);
   CString strMsg;
   strMsg.Format(TEXT("Deskew Angle : %d"), theApp.m_pRasterProcess->SliceDeskewAngle);
   MessageBox(strMsg);
}
void CRasterProcSink::OnSliceBitmap (long Bitmap, long lLeft, long lTop, long lWidth, long lHeight, long lAngle)
{
   static int nCount =1;
   
   ILEADRasterIO * pRasterIO = NULL;
   ILEADRaster * pSliceRaster = NULL;

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

   hr = CoCreateInstance(
      CLSID_LEADRaster, 
      NULL, 
      CLSCTX_ALL, 
      IID_ILEADRaster, 
      (void**)&pSliceRaster
      );

   TCHAR strFileName[MAX_PATH];
   wsprintf(strFileName, TEXT("c:\\Slices\\%d.bmp"), nCount);

   pSliceRaster->PutBitmap (Bitmap);

   int nRet = pRasterIO->Save (pSliceRaster, strFileName,FILE_BMP, 24, (QFactorConstants)1, SAVE_OVERWRITE);

   if (nRet == 0)
   {
      nCount ++;
      if(nCount > 10)

      theApp.m_pRasterProcess->ContinueSlicing = FALSE;
   }

   pSliceRaster->Release();
   pRasterIO->Release();
}