L_DispContainerAnnToRgn

#include "ltivw.h"

L_LTIVW_API L_INT L_DispContainerAnnToRgn(hCellWnd, nSubCellIndex, uCombineMode, bDeleteAnn, uFlags)

HWND hCellWnd;

/* handle to the cell window */

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

hCellWnd

A handle to the window that represents the cell on which the function's effect will be applied.

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:

L_DispContainerCreate, L_DispContainerDestroy, L_DispContainerSetAction, L_DispContainerAddAction, L_DispContainerGetSelectedAnnotationAttributes

Topics:

Working with Annotations

Image Viewer Functions: Working with Annotations

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 LEADTOOLS_V17_OR_LATER

L_INT DispContainerAnnToRgnExample(HDISPCONTAINER hCon) 
{
   BITMAPHANDLE Bitmap;
   L_INT        nRet;

   L_INT nCellIndex = 0;
   HWND hCellWnd = L_DispContainerGetCellWindowHandle(hCon, nCellIndex, 0);

   nRet = L_DispContainerAnnToRgn(hCellWnd, -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 = L_DispContainerGetBitmapHandle(hCellWnd, -2, &Bitmap, 0);
   if (nRet != SUCCESS)
      return nRet;

#if defined (LEADTOOLS_V16_OR_LATER)
   nRet = L_InvertBitmap(&Bitmap, 0);
#else
   nRet = L_InvertBitmap(&Bitmap);
#endif
   if (nRet != SUCCESS)
      return nRet;

   nRet = L_DispContainerSetBitmapHandle(hCellWnd, -2, &Bitmap, FALSE, 0);
   if (nRet != SUCCESS)
      return nRet;

   // Repaint the cell after the user is done with the changes.
   nRet = L_DispContainerRepaintCell(hCellWnd, 0);
   if (nRet != SUCCESS)
      return nRet;

   return SUCCESS;
}

#else




L_INT DispContainerAnnToRgnExample(HDISPCONTAINER hCon) 
{
   BITMAPHANDLE Bitmap;
   L_INT        nRet;

   nRet = L_DispContainerAnnToRgn(hCon, 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 = L_DispContainerGetBitmapHandle(hCon, 0, -2, &Bitmap, 0);
   if (nRet != SUCCESS)
      return nRet;

#if defined (LEADTOOLS_V16_OR_LATER)
   nRet = L_InvertBitmap(&Bitmap, 0);
#else
   nRet = L_InvertBitmap(&Bitmap);
#endif
   if (nRet != SUCCESS)
      return nRet;

   nRet = L_DispContainerSetBitmapHandle(hCon, 0, -2, &Bitmap, FALSE, 0);
   if (nRet != SUCCESS)
      return nRet;

   // Repaint the cell after the user is done with the changes.
   nRet = L_DispContainerRepaintCell(hCon, 0, 0, 0);
   if (nRet != SUCCESS)
      return nRet;

   return SUCCESS;
}

#endif