Available in LEADTOOLS Medical Imaging toolkits. |
LImageViewerCell::AnnToRgn
#include "ltwrappr.h"
L_INT LImageViewerCell::AnnToRgn(nSubCellIndex, uCombineMode, bDeleteAnn, uFlags)
L_INT nSubCellIndex; |
/* index into the image list attached to the cell */ |
L_UINT uCombineMode; |
/* action to apply on the existing region */ |
L_BOOL bDeleteAnn; |
/* flag */ |
L_UINT uFlags; |
/* reserved for future use */ |
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.
Parameter |
Description |
|
nSubCellIndex |
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. |
|
uCombineMode |
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. |
|
bDeleteAnn |
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. |
uFlags |
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. |
Returns
SUCCESS |
The function was successful. |
< 1 |
An error occurred. Refer to Return Codes. |
Comments
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.
Required DLLs and Libraries
LTIVW For a listing of the exact DLLs and Libraries needed, based on the toolkit version, refer to Files To Be Included With Your Application. |
See Also
Functions: |
LImageViewer::Create, LImageViewer::Destroy, LImageViewerCell::SetAction, LImageViewerCell::AddAction, LImageViewerCell::GetSelectedAnnotationAttributes. |
Topics: |
|
|
Example
This function inverts a region inside the bitmap, we assumed that we have one cell, and there is a selected rectanglur or elliptical annotation on it.
#if defined LTV17_CONFIG L_INT LImageViewer_AnnToRgn(LImageViewerCell& ImageViewerCell) { BITMAPHANDLE Bitmap; L_INT nRet; DISPCONTAINERANNATTRIBS AnnAttrib; LBitmap tmpBitmap; AnnAttrib.uStructSize = sizeof(DISPCONTAINERANNATTRIBS); nRet = ImageViewerCell.GetSelectedAnnotationAttributes(-2, &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; } #else L_INT LImageViewer_AnnToRgn(LImageViewer& ImageViewer) { BITMAPHANDLE Bitmap; L_INT nRet; DISPCONTAINERANNATTRIBS AnnAttrib; LBitmap tmpBitmap; AnnAttrib.uStructSize = sizeof(DISPCONTAINERANNATTRIBS); nRet = ImageViewer.GetSelectedAnnotationAttributes(0, -2, &AnnAttrib, 0); switch(AnnAttrib.uType) { case ANNOBJECT_RECT: case ANNOBJECT_ELLIPSE: case ANNOBJECT_HILITE: break; default: return FAILURE; break; } nRet = ImageViewer.AnnToRgn(0, -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 = ImageViewer.GetBitmapHandle(0, -2, &Bitmap, 0); if (nRet != SUCCESS) return nRet; tmpBitmap.SetHandle(&Bitmap); nRet = tmpBitmap.Invert(); if (nRet != SUCCESS) return nRet; nRet = ImageViewer.SetBitmapHandle(0, -2, tmpBitmap.GetHandle(), FALSE, 0); if (nRet != SUCCESS) return nRet; // Repaint the cell after the user is done with the changes. nRet = ImageViewer.RepaintCell(0, 0, 0); if (nRet != SUCCESS) return nRet; return SUCCESS; } #endif // LTV17_CONFIG