LSegment::MrcSetSegmentData

Summary

Updates the specified segment.

Syntax

#include "ltwrappr.h"

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

Parameters

LBitmapBase * pBitmap

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

L_INT nSegId

Segments ID to be updated.

pSEGMENTDATA pSegmentData

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

Returns

Value Meaning
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

See Also

Elements

Topics

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 23.0.2024.2.29
Products | Support | Contact Us | Intellectual Property Notices
© 1991-2024 LEAD Technologies, Inc. All Rights Reserved.

LEADTOOLS MRC C++ Class Library Help
Products | Support | Contact Us | Intellectual Property Notices
© 1991-2023 LEAD Technologies, Inc. All Rights Reserved.