LSegment::MrcSetSegmentData

#include "ltwrappr.h"

L_INT LSegment::MrcSetSegmentData(pBitmap, nSegId, pSegmentData)

LBitmapBase * pBitmap;

pointer to an LBitmapBase object

L_INT nSegId;

segment identifier

pSEGMENTDATA pSegmentData;

new segment information

Updates the specified segment.

Parameter

Description

pBitmap

Pointer to an LBitmapBase object that references the bitmap in which the segment will be updated.

nSegId

Segments ID to be updated.

pSegmentData

Pointer to the SEGMENTDATA structure that contains the new segment information.

Returns

SUCCESS

The function was successful.

< 1

An error occurred. Refer to Return Codes.

Comments

Use this function to update the segment information. In the auto segmentation mode, the LEADTOOLS engine will update the segments using the new segment data passed to this function. This process may create or delete segments. The function will update the segments so they remain within the bitmap width and height.

In the manual segmentation mode, the user is free to update the segments. The LEAD engine will not delete or create segments. If an error occurs, the pSegmentData parameter will be updated with the target segment.

To get segment IDs and segment information, use the LSegment::MrcEnumSegments function to enumerate all segments.

The function will return an error if the updated segment exceeds its stripe boundaries.

Call the LSegment::MrcStartBitmapSegmentation function before using any of the segmentation functions. When the LSegment class object is no longer needed, free it by calling the LSegment::MrcStopBitmapSegmentation function.

Required DLLs and Libraries

LTSGM

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

See Also

Elements:

LSegment::MrcStartBitmapSegmentation, LSegment::MrcStopBitmapSegmentation, LSegment::MrcSegmentBitmap, LSegment::MrcEnumSegments, LSegment::MrcDeleteSegment, LSegment::MrcCreateNewSegment, Segment::MrcCombineSegments, LSegment::MrcSaveSegmentation, LSegment::MrcLoadSegmentation, LSegment::MrcCopySegmentationHandle, LSegment::MrcSegmentBitmap, Class Members

Topics:

General Segmentation

 

Auto-Segmentation

 

Manual Segmentation

Example

The following example uses LSegment::MrcSetSegmentData to update the data of the segment with the identifier 0. It also demonstrates the use of LSegment::MrcDeleteSegment to delete a segment. Create a new class derived from LSegment and override LSegment::MrcEnumSegments CallBack.

#ifdef LUserSeg 
class LUserSeg : public LSegment 
{ 
   virtual L_INT MrcEnumSegmentsCallBack(const pSEGMENTDATA pSegment, L_INT nSegId) 
   { 
      L_TCHAR szSegmentRect[256]; 
      L_TCHAR szSegmentId[256]; 
      memset(szSegmentRect, 0, 256); 
      memset(szSegmentId, 0, 256); 
      wsprintf(szSegmentId, TEXT("Segment ID %d"), nSegId); 
      wsprintf(szSegmentRect, TEXT("Left = %d, Top = %d, Right = %d, Bottom = %d"), pSegment->rcBitmapSeg.left,  pSegment->rcBitmapSeg.top, pSegment->rcBitmapSeg.right, pSegment->rcBitmapSeg.bottom); 
      MessageBox(NULL, szSegmentRect, szSegmentId, MB_OK); 
      return SUCCESS; 
   } 
}; 
#endif // #ifdef LUserSeg 
L_INT LSegment__MrcSetSegmentDataExample(LUserSeg seg, LBitmapBase & Bitmap, pSEGMENTDATA pNewSegmentData, L_INT nSegId) 
{ 
   L_INT nRet; 
   /* update the segments dependent on the new segment */ 
   nRet = seg.MrcSetSegmentData (&Bitmap, nSegId, pNewSegmentData); 
   if (nRet != SUCCESS) 
      return nRet; 
   /* Enumerate the new segments and their id's */ 
   nRet = seg.MrcEnumSegments(0); 
   if(nRet < 1) 
      return nRet; 
   /* Delete a segment */ 
   nRet = seg.MrcDeleteSegment(nSegId); 
   if (nRet != SUCCESS) 
      return nRet; 
   /* Enumerate the new segments and their id's */ 
   nRet = seg.MrcEnumSegments(0); 
   if(nRet < 1) 
      return nRet; 
   return SUCCESS; 
} 

Help Version 19.0.2017.10.27
Products | Support | Contact Us | Copyright Notices
© 1991-2017 LEAD Technologies, Inc. All Rights Reserved.
LEADTOOLS MRC C++ Class Library Help