Available in the LEADTOOLS Imaging toolkit. |
GetRgnHandle example for Visual J++
The following code creates a region, saves its handle and adds the saved region beside the current region.
// Initialize the variables that we will manipulate to simulate mouse coordinates.
int nOffsetX = (int) LEAD1.getBitmapWidth() / 8;
int nOffsetY = (int) LEAD1.getBitmapHeight() / 6;
// Create an elliptical region.
LEAD1.SetRgnEllipse( nOffsetX, nOffsetY, nOffsetX, nOffsetY, (short) LTOCXU.RgnCombineModeConstants.L_RGN_SET );
// Save a copy of the region.
int hSavedRegion = LEAD1.GetRgnHandle();
// Add the saved region to the bitmap, offsetting it so that we can see it.
LEAD1.SetRgnHandle( hSavedRegion, nOffsetX, nOffsetY, (short) LTOCXU.RgnCombineModeConstants.L_RGN_OR );
// Delete the saved region.
LEAD1.DeleteRgnHandle( (short) hSavedRegion );
// Fill the bitmap region with blue.
LEAD1.Fill( new Color( 0, 0, 255 ) );
// Free the bitmap region.
LEAD1.FreeRgn();
// Repaint the image so that we can see how the image was updated.
LEAD1.ForceRepaint();