#include "ltwrappr.h"

L_INT LBitmapBase::Slice(pOptions, pnDeskewAngle)

Extracts individual slices from radiographic scanned film.



Pointer to the SLICEBITMAPOPTIONS structure that LEADTOOLS uses to slice the bitmap.

L_INT32 * pnDeskewAngle

NULL or the address of the variable to be updated with the amount that the function rotates the sliced bitmap. The amount of rotation is expressed in hundredths of degrees. For example, 500 means 5 degrees clockwise. You can pass NULL if you do not need to check the amount of rotation. This field is updated only if SLC_DESKEW is selected from pSLICEBITMAPOPTIONS flag parameter.


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


This function is designed to extract the individual slices from radiographic scanned film. The image below shows an example of these radiographic images before and after applying the LBitmapBase::Slice function where we use the output data to draw a white line around each separate slice.


Film Before Function Is Called


Film After Function Is Called

To update a status bar or detect a user interrupt during execution of this function, refer to LBase::EnableStatusCallback.

This function supports 12 and 16-bit grayscale and 48 and 64-bit color images. Support for 12 and 16-bit grayscale and 48 and 64-bit color images is available only in the Document/Medical toolkits.

This function does not support 32-bit grayscale images. It returns the error code ERROR_GRAY32_UNSUPPORTED if a 32-bit grayscale image is passed to this function.

Required DLLs and Libraries


Win32, x64.

See Also




class LUserBitmapWindow : public LBitmapWindow 
   L_INT m_uSlicesCount; 
   virtual L_INT SliceCallBack(LBitmapBase * pBitmap, LPRECT lpSliceRect, L_INT nAngle); 
void SliceExample(CWnd * pWnd) 
   LUserBitmapWindow       BitmapWindow; 
   L_INT                   nRet;  
   L_TCHAR                 S[30] = L""; 
   L_TCHAR                 Message[512] = L""; 
   LBase::LoadLibraries (LT_ALL_LEADLIB);  
   nRet = BitmapWindow.SetWndHandle (pWnd->GetSafeHwnd()); 
   BitmapWindow.EnableCallBack (TRUE);  
   nRet = BitmapWindow.Load (TEXT("c:\\parrots.jpg")); 
   Options.uStructSize = sizeof(SLICEBITMAPOPTIONS);  
   // Deskew the sliced image, the deskew angle is located between -5 and 5 degrees 
   Options.uMaxDeskewAngle = 500;  
   Options.crFill = RGB(0,0,0);  
   nRet = BitmapWindow.Slice(&Options, NULL);   
   if(nRet == SUCCESS)  
      lstrcpy(Message, L"The number of sliced image is"); 
      wsprintf(S, L"%d", BitmapWindow.m_uSlicesCount);  
      lstrcat(Message, S );  
      MessageBox(pWnd->GetSafeHwnd(), Message, L"SliceBitmap Example", MB_OK);  
   BitmapWindow.SetWndHandle (NULL); 
L_INT LUserBitmapWindow::SliceCallBack(LBitmapBase * pBitmap,  
                                       LPRECT         lpSliceRect, 
                                       L_INT          nAngle) 
   L_TCHAR               szDirectory[L_MAXPATH];  
   L_TCHAR               S[30];  
   L_INT                nRet;  
   lstrcpy(szDirectory, TEXT("c:\\SliceTmp")); 
   lstrcat(szDirectory, TEXT("\\")); 
   wsprintf(S, TEXT("%d.bmp"), m_uSlicesCount);  
   lstrcat(szDirectory, S);  
   nRet = Save(szDirectory, FILE_BMP, 24, 0, 0); 
   if(nRet == SUCCESS) 
      m_uSlicesCount ++; 
      pBitmap->Free (); 
   return SUCCESS;  
Help Version 21.0.2021.4.8
Products | Support | Contact Us | Intellectual Property Notices
© 1991-2021 LEAD Technologies, Inc. All Rights Reserved.

LEADTOOLS Raster Imaging C++ Class Library Help