LBitmapBase::Slice

Summary

Extracts individual slices from radiographic scanned film.

Syntax

#include "ltwrappr.h"

L_INT LBitmapBase::Slice(pOptions, pnDeskewAngle)

Parameters

pSLICEBITMAPOPTIONS pOptions

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.

Returns

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

Comments

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.

image\BeforeSliceBitmap.gif

Film Before Function Is Called

image\AfterSliceBitmap.gif

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

Platforms

Win32, x64.

See Also

Functions

Topics

Example

class LUserBitmapWindow : public LBitmapWindow 
{ 
public: 
   L_INT m_uSlicesCount; 
   virtual L_INT SliceCallBack(LBitmapBase * pBitmap, LPRECT lpSliceRect, L_INT nAngle); 
}; 
 
void SliceExample(CWnd * pWnd) 
{ 
   LUserBitmapWindow       BitmapWindow; 
   SLICEBITMAPOPTIONS      Options;  
   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.uFlags = SLC_DESKEW|SLC_DSKW_LINEAR|SLC_CUTSLICES;  
   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) 
{ 
   UNREFERENCED_PARAMETER(nAngle); 
   UNREFERENCED_PARAMETER(lpSliceRect); 
 
   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 22.0.2023.2.2
Products | Support | Contact Us | Intellectual Property Notices
© 1991-2023 LEAD Technologies, Inc. All Rights Reserved.

LEADTOOLS Raster Imaging C++ Class Library Help

Products | Support | Contact Us | Intellectual Property Notices
© 1991-2023 LEAD Technologies, Inc. All Rights Reserved.