L_SliceBitmap

#include "l_bitmap.h"

L_LTIMGCOR_API L_INT L_SliceBitmap(pBitmap, pOptions, pnDeskewAngle, pfnCallback, pUserData, uFlags)

pBITMAPHANDLE pBitmap;

pointer to the bitmap

pSLICEBITMAPOPTIONS pOptions;

pointer to a structure

L_INT *pnDeskewAngle;

address of the deskew angle variable to be updated

BITMAPSLICECALLBACK pfnCallback;

callback function

L_VOID *pUserData;

pointer to more parameters for the callback

L_UINT32 uFlags;

flags

Extracts individual slices from radiographic scanned film.

Parameter

Description

pBitmap

Pointer to the bitmap handle referencing the bitmap to be sliced.

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.

pfnCallback

Pointer to a callback function used retrieve each slice's data and information.

This callback function must return a positive number or an error code (negative number). If it returns an error code, the slicing process will stop, and the code will be passed back as the return code.

The callback function must adhere to the function prototype described in the BITMAPSLICECALLBACK function.

pUserData

Void pointer that you can use to pass one or more additional parameters that the callback function needs.

To use this feature, assign a value to a variable or create a structure that contains as many fields as you need. Then, in this parameter, pass the address of the variable or structure, casting it to L_VOID  *. The callback function, which receives the address in its own pUserData parameter, can cast it to a pointer of the appropriate data type to access your variable or structure.

If the additional parameters are not needed, you can pass NULL in this parameter.

uFlags

Reserved for future use. Must be 0.

Returns

SUCCESS

The function was successful.

< 1

An error occurred. Refer to Return Codes.

Comments

This function does not support signed data images. It returns the error code ERROR_SIGNED_DATA_NOT_SUPPORTED if a signed data image is passed to this function.

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 L_SliceBitmap 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 L_SetStatusCallback.

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 in the Document and Medical Imaging 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, Linux.

See Also

Functions:

BITMAPSLICECALLBACK

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

typedef struct tagSLICEBITMAPUSERINFO 
{ 
   L_TCHAR SlicesFolder[L_MAXPATH]; 
   L_UINT  SlicesCount; 
 
} 
SLICEBITMAPUSERINFO, * pSLICEBITMAPUSERINFO; 
 
 
 
L_INT EXT_CALLBACK ExampleSliceCB(pBITMAPHANDLE pBitmap, 
                                  LPRECT        lpSliceRect, 
                                  L_INT         nAngle, 
                                  L_VOID      * pUserData) 
{ 
   pSLICEBITMAPUSERINFO pSlicesUserInfo; 
   L_TCHAR              szDirectory[L_MAXPATH]; 
   L_TCHAR              S[30]; 
   L_INT                nRet; 
    
   UNREFERENCED_PARAMETER(lpSliceRect); 
   UNREFERENCED_PARAMETER(nAngle);  
 
   pSlicesUserInfo = (pSLICEBITMAPUSERINFO)pUserData; 
    
   lstrcpy(szDirectory, pSlicesUserInfo->SlicesFolder); 
   lstrcat(szDirectory, TEXT("\\")); 
   wsprintf(S,TEXT("%d.bmp"), (pSlicesUserInfo->SlicesCount)); 
   lstrcat(szDirectory, S); 
 
   nRet = L_SaveFile(szDirectory, pBitmap, FILE_BMP, 24, 0, SAVEFILE_FIXEDPALETTE, NULL, NULL, NULL  ); 
   if(nRet == SUCCESS) 
   { 
      pSlicesUserInfo->SlicesCount++; 
      L_FreeBitmap(pBitmap); 
      GlobalFreePtr(pBitmap); 
   } 
   return SUCCESS; 
} 
L_INT SliceBitmapExample(HWND hWnd, pBITMAPHANDLE pBitmap, LPSTR SlicesFolder) 
{ 
   SLICEBITMAPOPTIONS      Options; 
   SLICEBITMAPUSERINFO     UserData; 
   L_INT                   nRet; 
   L_TCHAR                  S[30] = TEXT(""); 
   L_TCHAR                  Message[512] = TEXT(""); 
 
   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); 
    
   memcpy(UserData.SlicesFolder, SlicesFolder, L_MAXPATH); 
   UserData.SlicesCount = 0; 
 
   nRet = L_SliceBitmap(pBitmap, &Options, NULL, ExampleSliceCB, (L_VOID *)(&UserData), 0);   
   if(nRet == SUCCESS) 
   { 
      lstrcpy(Message, TEXT("The number of sliced image is")); 
      wsprintf(S, TEXT("%d"), (UserData.SlicesCount)); 
      lstrcat(Message, S ); 
      MessageBox(hWnd, Message, TEXT("SliceBitmap Example"), MB_OK); 
   } 
   else 
   { 
      return nRet; 
   } 
   return SUCCESS; 
} 

Help Version 20.0.2018.1.19
Products | Support | Contact Us | Copyright Notices
© 1991-2018 LEAD Technologies, Inc. All Rights Reserved.
LEADTOOLS Raster Imaging C API Help