GetBitmapClipSegments example for Delphi
var
uSegments: Cardinal;
pSegments: Pointer;
i, j: Integer;
nStartVal, nEndVal: Integer;
begin
// 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= Nil)then
begin
// not enough memory!!
ShowMessage ( 'Not Enough Memory' ) ;
Exit;
end;
// 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 to uSegments-1 do
begin
nStartVal:= Integer (PChar ( pSegments ) + (i * 2 * sizeof ( Integer )));
nEndVal:= Integer (PChar ( pSegments ) + ((i * 2 + 1)* sizeof ( Integer )));
for j:= nStartVal to nEndVal -1 do
LEADImage1.Pixel[LEADImage1.RgnTop, j]:= clBlack;
end;
// free the segments array
GlobalFreePtr (pSegments);
end;