GetBitmapClipSegments example for C++ Builder
unsigned uSegments;
unsigned int * pSegments= NULL;
int i, j;
int nStartVal, nEndVal;
// get the maximum number of elements in a row, so I know how big the array of segments should be
LEADImage1->GetBitmapClipSegmentsMax(&uSegments);
// allocate an array large enough to store the maximum number of segments-> Note that
// GetBitmapClipSegmentsMax took into account that each segment has two extremities->
pSegments= GlobalAllocPtr (GMEM_MOVEABLE, uSegments * sizeof(Cardinal));
if(pSegments== NULL)
{
// not enough memory!!
ShowMessage ( "Not Enough Memory" ) ;
return;
}
// get the segments for the first row
LEADImage1->GetBitmapClipSegments(LEADImage1->RgnTop, pSegments, &uSegments);
// do something with the segments->
// to keep this example simple, we will set the pixels in the segment to 0
for (i= 0; i < (int)uSegments; i ++ )
{
nStartVal= (int)pSegments[i * 2];
nEndVal= (int)pSegments[i * 2 + 1];
for (j= nStartVal; j < nEndVal; j ++ )
LEADImage1->Pixel[LEADImage1->RgnTop][j]= (TColor)clBlack;
}
// free the segments array
GlobalFreePtr (pSegments);