Converts a selected annotation object inside a specific cell or sub-cell into a region, this region will be either set or combined with another existing region.
#include "ltwrappr.h"
L_INT LImageViewerCell::AnnToRgn(nSubCellIndex, uCombineMode, bDeleteAnn, uFlags)
A zero-based index into the image list attached to the cell. This image contains the annotation object that the user chooses to convert into region. Pass -1 to apply this effect on all sub-cells. Pass -2 to apply this effect on the selected sub-cell.
Value that specifies the action to apply on the existing bitmap region, if one is defined. For descriptions of the possible values, refer to Creating a Bitmap Region Inside the Image Viewer.
Flag that indicates whether to delete the annotation object after converting it to a region. Possible values are:
Value | Meaning |
---|---|
TRUE | Delete the annotation object after completing the process. |
FALSE | Do not delete the annotation object after completing the process. |
Flags that determine whether to apply the feature on the one cell only, or more than one cell. This value can only be used when the cell is attached to the LImageViewer through the function LImageViewer::InsertCell. Possible values are:
Value | Meaning |
---|---|
CELL_APPLYTOTHIS | [0x00000000] Apply the feature to this cell only. |
CELL_APPLYTOALL | [0x10000000] Apply the feature to all the cells in the Image Viewer. |
CELL_APPLYTOSELECTED | [0x20000000] Apply the feature to the selected cells in the Image Viewer. |
Value | Meaning |
---|---|
SUCCESS | The function was successful. |
< 1 | An error occurred. Refer to Return Codes. |
The chosen sub-cell or cell must have a selected annotation in order to convert it into a region. If there is no selected annotation, the function will return ERROR_INV_PARAMETER.
This function works only on the closed shape annotation objects, such as rectangle, ellipse and Hilite.
If you have a cell with one image, you must set nSubCellIndex to zero.
This function inverts a region inside the bitmap, we assumed that we have one cell, and there is a selected rectangular or elliptical annotation on it.
L_INT LImageViewer_AnnToRgnExample(LImageViewerCell& ImageViewerCell)
{
BITMAPHANDLE Bitmap;
L_INT nRet;
DISPCONTAINERANNATTRIBS AnnAttrib;
LBitmap tmpBitmap;
memset(&AnnAttrib,0,sizeof(DISPCONTAINERANNATTRIBS));
AnnAttrib.uStructSize = sizeof(DISPCONTAINERANNATTRIBS);
nRet = ImageViewerCell.GetSelectedAnnotationAttributes(0, &AnnAttrib, 0);
switch(AnnAttrib.uType)
{
case ANNOBJECT_RECT:
case ANNOBJECT_ELLIPSE:
case ANNOBJECT_HILITE:
break;
default:
return FAILURE;
break;
}
nRet = ImageViewerCell.AnnToRgn(-2, L_RGN_SET, TRUE, 0);
if (nRet != SUCCESS)
return nRet;
// Just apply the effect on the active sub-cell.
// this is done by setting the nSubCell parameter to -2.
nRet = ImageViewerCell.GetBitmapHandle(-2, &Bitmap, 0);
if (nRet != SUCCESS)
return nRet;
tmpBitmap.SetHandle(&Bitmap);
nRet = tmpBitmap.Invert();
if (nRet != SUCCESS)
return nRet;
nRet = ImageViewerCell.SetBitmapHandle(-2, tmpBitmap.GetHandle(), FALSE, 0);
if (nRet != SUCCESS)
return nRet;
// Repaint the cell after the user is done with the changes.
//nRet = ImageViewerCell.RepaintCell(0, 0);
if (nRet != SUCCESS)
return nRet;
return SUCCESS;
}