LImageViewerCell::SaveRegion

#include "ltwrappr.h"

L_INT LImageViewerCell::SaveRegion(pFileName, nSubCellIndex, nStartPage, uFlags)

LPTSTR pFileName;

/* output file name */

L_INT nSubCellIndex;

/* index into the image list attached to the cell */

L_INT nStartPage;

/* the page number of a multi-page file */

L_UINT uFlags;

/* flag */

Saves the region of the specified cell or sub-cell image to a file.

Parameter

Description

pFileName

Character string that contains the name of the file to save.

nSubCellIndex

A zero-based index into the image list attached to the cell. This sub-cell contains the image region that will be saved. Pass -2 to refer to the selected sub-cell. If the cell contains 1 frame then the nSubCellIndex should be 0.

nStartPage

The page number of a multi-page file, which can contain more than one image.

uFlags

Flag that is used to determine the way of saving the region. Possible values are:

 

Value

Meaning

 

CONTAINER_FILE_CREATE

[0x00000000] Create a file.

 

CONTAINER_FILE_APPEND

[0x00000001] Append an existing file.

 

CONTAINER_FILE_REPLACE

[0x00000002] Replace the region in the index nStartPage in the existing file with the new region.

 

CONTAINER_FILE_INSERT

[0x00000003] Insert the region in the index nStartPage in the existing file.

 

The following 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

This function saves the region into an encrypted file. To load the saved region file use the LImageViewerCell::LoadRegion function.

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:

LImageViewerCell::LoadRegion, LImageViewerCell::AnnToRgn, LImageViewerCell::EnableRegionCallBack, LImageViewerCell::RegionCallBack, Class Members

Topics:

Image Viewer Cells

 

Window Control/Image Viewer Functions: Image Viewer Cells

 

Creating a Bitmap Region Inside the Image Viewer

Example

This example will create a bitmap region on the first frame of the first image, save it, and then apply it to the rest of the frames.

#define MAKE_IMAGE_PATH(pFileName) TEXT("C:\\Users\\Public\\Documents\\LEADTOOLS Images\\")pFileName
#if defined LTV17_CONFIG
L_INT LImageViewer_SaveBitmapRegionExample(LImageViewerCell& ImageViewerCell)
{
   L_INT        nRet;
   BITMAPHANDLE Bitmap;
   RECT         rcRect;
   L_INT        nI;
   L_INT        nCount;
   HBITMAPLIST  hBitmapList;
   LBitmapList  BitmapList;
   LBitmap      BitmapHandle;
   nRet = ImageViewerCell.GetBitmapHandle(0, &Bitmap, 0);
   if (nRet != SUCCESS)
      return nRet;
   nRet = ImageViewerCell.GetCellBitmapList(&hBitmapList, 0);
   if (nRet != SUCCESS)
      return nRet;
   nCount = BitmapList.GetItemsCount();
   BitmapList.SetHandle(NULL, NULL, FALSE);
   L_INT nBitmapCenterX = BITMAPWIDTH(&Bitmap) >> 1;
   L_INT nBitmapCenterY = BITMAPHEIGHT(&Bitmap) >> 1;
   SetRect(&rcRect, nBitmapCenterX - (nBitmapCenterX >> 1),
                    nBitmapCenterY - (nBitmapCenterY >> 1),
                    nBitmapCenterX + (nBitmapCenterX >> 1),
                    nBitmapCenterY + (nBitmapCenterY >> 1));
   BitmapHandle.SetHandle(&Bitmap);
   LBitmapRgn Region(&BitmapHandle);
   Region.SetRgnRect(&rcRect);
   pBITMAPHANDLE pBitmap = BitmapHandle.GetHandle();
   ImageViewerCell.SetBitmapHandle(0, pBitmap, TRUE, 0);
   ImageViewerCell.SaveRegion( MAKE_IMAGE_PATH(TEXT("Region.rgn")), 0, 0, 0);
   for (nI = 0; nI < nCount; nI++)
      ImageViewerCell.LoadRegion(MAKE_IMAGE_PATH(TEXT("Region.rgn")), nI, 0, 0);
   BitmapHandle.SetHandle(NULL, FALSE);
   return SUCCESS;
}
#else
L_INT LImageViewer_SaveBitmapRegionExample(LImageViewer& ImageViewer)
{
   L_INT        nRet;
   BITMAPHANDLE Bitmap;
   RECT         rcRect;
   L_INT        nI;
   L_INT        nCount;
   HBITMAPLIST  hBitmapList;
   LBitmapList  BitmapList;
   LBitmap      BitmapHandle;
   nRet = ImageViewer.GetBitmapHandle( 0, 0, &Bitmap, 0);
   if (nRet != SUCCESS)
      return nRet;
   nRet = ImageViewer.GetCellBitmapList( 0, &hBitmapList, 0);
   if (nRet != SUCCESS)
      return nRet;
   nCount = BitmapList.GetItemsCount();
   BitmapList.SetHandle(NULL, NULL, FALSE);
   L_INT nBitmapCenterX = BITMAPWIDTH(&Bitmap) >> 1;
   L_INT nBitmapCenterY = BITMAPHEIGHT(&Bitmap) >> 1;
   SetRect(&rcRect, nBitmapCenterX - (nBitmapCenterX >> 1),
                    nBitmapCenterY - (nBitmapCenterY >> 1),
                    nBitmapCenterX + (nBitmapCenterX >> 1),
                    nBitmapCenterY + (nBitmapCenterY >> 1));
   BitmapHandle.SetHandle(&Bitmap);
   LBitmapRgn Region(&BitmapHandle);
   Region.SetRgnRect(&rcRect);
   pBITMAPHANDLE pBitmap = BitmapHandle.GetHandle();
   ImageViewer.SetBitmapHandle( 0, 0, pBitmap, TRUE, 0);
   ImageViewer.SaveRegion( MAKE_IMAGE_PATH(TEXT("Region.rgn")), 0, 0, 0, 0);
   for (nI = 0; nI < nCount; nI++)
      ImageViewer.LoadRegion( MAKE_IMAGE_PATH(TEXT("Region.rgn")), 0, nI, 0, 0);
   BitmapHandle.SetHandle(NULL, FALSE);
   return SUCCESS;
}
#endif // LV17_CONFIG