LImageViewer::AnnToRgn

#include "ltwrappr.h"

L_INT LImageViewer::AnnToRgn(nCellIndex, nSubCellIndex, uCombineMode, bDeleteAnn, uFlags)

L_INT nCellIndex;

/* index of a cell */

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

nCellIndex

A zero-based index of the cell that holds the sub-cell that contains the selected annotation object. Pass -1 to apply this effect on all cells. Pass -2 to apply this effect on the selected cells.

nSubCellIndex

A zero-based index into the image list attached to the cell specified in nCellIndex. 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

Reserved for future use. Pass 0.

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, LImageViewer::SetAction, LImageViewer::AddAction, LImageViewer::GetSelectedAnnotationAttributes.

Topics:

Image Viewer Functions: The Annotation Feature.

 

The Annotation Feature

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.

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; 
}