LBitmapBase::Slice

#include "ltwrappr.h"

L_INT LBitmapBase::Slice(pOptions, pnDeskewAngle)

pSLICEBITMAPOPTIONS pOptions;

/* pointer to a structure */

L_INT32 * pnDeskewAngle;

/* address of the deskew angle variable to be updated */

Extracts individual slices from radiographic scanned film.

Parameter

Description

pOptions

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

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

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

LTIMGCOR

For a listing of the exact DLLs and Libraries needed, based on the toolkit version, refer to Files To Be Included With Your Application.

Platforms

Win32, x64.

See Also

Functions:

LBitmapBase::SliceCallBack, Class Members

Topics:

Processing an Image

 

Raster Image Functions: Creating and Maintaining Lists of Images

 

Raster Image Functions: Creating and Using a Region

 

Raster Image Functions: Processing an Image

Example

LUserBitmapWindow    m_BitmapWindow;
void CSliceSampleDlg::OnSlice()
{
   SLICEBITMAPOPTIONS      Options; 
   L_INT                   nRet; 
   L_CHAR                  S[30] = "";
   L_CHAR                  Message[512] = "";

   LBase::LoadLibraries (LT_ALL_LEADLIB); 
   WRPUNLOCKSUPPORT();   

   nRet = m_BitmapWindow.SetWndHandle (this->GetSafeHwnd());
   m_BitmapWindow.EnableCallBack (TRUE); 
   nRet = m_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 = m_BitmapWindow.Slice(&Options, NULL);  
   if(nRet == SUCCESS) 
   {
      strcpy(Message, "The number of sliced image is");
      sprintf(S, "%d", m_BitmapWindow.m_uSlicesCount); 
      strcat(Message, S ); 
      MessageBoxA(this->GetSafeHwnd(), Message, "SliceBitmap Example", MB_OK); 
   }

   
}

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; 
}