Products | Support | Send comments on this topic. | Email a link to this topic. | Back to Getting Started | Help Version 18.0.10.23
LEADTOOLS Medical Image Viewer C++ Class Library Help

LImageViewerCell::EnableLowMemoryUsageCallBack

Show in webframe

#include "ltwrappr.h"

L_BOOL LImageViewerCell::EnableLowMemoryUsageCallBack(bEnable)

L_BOOL bEnable;

/* flag */

Enables or disables the LImageViewerCell::LowMemoryUsageCallBack function.

Parameter

Description

bEnable

Flag that indicates whether to enable or disable the LImageViewerCell::LowMemoryUsageCallBack function. Possible values are:

 

Value

Meaning

 

TRUE

Enable the LImageViewerCell::LowMemoryUsageCallBack function.

 

FALSE

Disable the LImageViewerCell::LowMemoryUsageCallBack function.

Returns

The previous setting.

Comments

Call this function to enable or disable the Low Memory Usage callback overridable function for your class object. This will enable or disable the callback functions, which exist in the calling object.

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::LowMemoryUsageCallBack, LImageViewerCell::EnableActionCallBack, LImageViewerCell::ActionCallBack, Class Members

Topics:

Image Viewer Cells

 

Image Viewer Functions: Image Viewer Cells

 

Image Viewer Functions: Callbacks

Example

This example shows how to use the low memroy usage feature to display a medical image with multiple pages. it will also invert all the bitmap to show the invert function works even if the bitmap is not loaded yet.

#define MAKE_IMAGE_PATH(pFileName) TEXT("C:\\Users\\Public\\Documents\\LEADTOOLS Images\\")pFileName
#if defined(LEADTOOLS_V17_OR_LATER)
#ifdef LImageViewerChild 
class LImageViewerChild :public LImageViewerCell
{
   virtual L_INT FramesRequestedCallBack (L_INT    nCellIndex,
                                          L_UINT * puFramesRequested,
                                          L_UINT   uLength);
};
#endif
L_INT LImageViewerChild::FramesRequestedCallBack (L_INT    nCellIndex,
                               L_UINT * puFramesRequested,
                               L_UINT   uLength)
{
   UNREFERENCED_PARAMETER(nCellIndex);
   L_INT nI;
   LOADFILEOPTION LoadOption;
   BITMAPHANDLE * pBitmap;
   LBitmap        BitmapHandles;
   pBITMAPHANDLE  pBitmapHandle;
   if (uLength == 0)
      return 0;
   LBaseFile::GetDefaultLoadFileOption(&LoadOption, sizeof(LOADFILEOPTION));
   pBitmap = (pBITMAPHANDLE)malloc(sizeof(BITMAPHANDLE) * uLength);
   for (nI = 0; nI < (L_INT)uLength; nI++)
   {
      LoadOption.PageNumber = puFramesRequested[nI];
      BitmapHandles.Load(MAKE_IMAGE_PATH(TEXT("image1.dcm")), 0, ORDER_BGRORGRAY, &LoadOption, NULL);
      pBitmapHandle = BitmapHandles.GetHandle();
      memcpy(&pBitmap[nI], pBitmapHandle, sizeof(BITMAPHANDLE));
      BitmapHandles.SetHandle(NULL, FALSE);
   }
   SetRequestedImage(pBitmap, (L_INT *) puFramesRequested, uLength, 0);
   return SUCCESS;
}
L_INT LImageViewer_EnableCellLowMemoryUsageExample(LImageViewer& ImageViewer)
{
   FILEINFO                 FileInfo;
   pDISPCONTAINERBITMAPINFO pBitmapInfo;
   L_INT                    nI, nRet;
   LBitmapBase             LeadBitmap;
   LFile                  LeadFile;
   LeadFile.SetBitmap(&LeadBitmap) ;
   LeadFile.SetFileName(MAKE_IMAGE_PATH(TEXT("image1.dcm")));
   nRet = LeadFile.GetInfo(&FileInfo, sizeof(FILEINFO)) ;
   if(nRet != SUCCESS)
      return nRet;
   pBitmapInfo = (DISPCONTAINERBITMAPINFO *)malloc(sizeof(DISPCONTAINERBITMAPINFO) * FileInfo.TotalPages);
   for (nI = 0; nI < FileInfo.TotalPages; nI++)
   {
      pBitmapInfo[nI].uHeight = FileInfo.Height;
      pBitmapInfo[nI].uWidth = FileInfo.Width;
      pBitmapInfo[nI].uXResolution = FileInfo.XResolution;
      pBitmapInfo[nI].uYResolution = FileInfo.YResolution;
   }
   LImageViewerCell * ImageViewerCell = new LImageViewerCell();
   ImageViewerCell->Create(ImageViewer.GetWindowHandle(0), 0);
   ImageViewer.InsertCell(ImageViewerCell->GetWindowHandle(0), 0, 0);
   ImageViewerCell->EnableLowMemoryUsageCallBack(TRUE);
   ImageViewerCell->EnableCellLowMemoryUsage(0,
                                             FileInfo.TotalPages,
                                             pBitmapInfo,
                                             0);
   // invert all the frames in the cell.
   for (nI = 0; nI < FileInfo.TotalPages; nI ++)
   {
      ImageViewerCell->InvertBitmap(nI, 0);
   }
   return SUCCESS;
}
#else
#ifdef LImageViewerChild 
class LImageViewerChild :public LImageViewerCell
{
   virtual L_INT FramesRequestedCallBack (L_INT    nCellIndex,
                                          L_UINT * puFramesRequested,
                                          L_UINT   uLength);
};
#endif
L_INT LImageViewerChild::FramesRequestedCallBack (L_INT    nCellIndex,
                               L_UINT * puFramesRequested,
                               L_UINT   uLength)
{
   L_INT nI;
   LOADFILEOPTION LoadOption;
   BITMAPHANDLE * pBitmap;
   LBitmap        BitmapHandles;
   pBITMAPHANDLE  pBitmapHandle;
   if (uLength == 0)
      return 0;
   LBaseFile::GetDefaultLoadFileOption(&LoadOption, sizeof(LOADFILEOPTION));
   pBitmap = (pBITMAPHANDLE)malloc(sizeof(BITMAPHANDLE) * uLength);
   for (nI = 0; nI < (L_INT)uLength; nI++)
   {
      LoadOption.PageNumber = puFramesRequested[nI];
      BitmapHandles.Load(MAKE_IMAGE_PATH(TEXT("image1.dcm")), 0, ORDER_BGRORGRAY, &LoadOption, NULL);
      pBitmapHandle = BitmapHandles.GetHandle();
      memcpy(&pBitmap[nI], pBitmapHandle, sizeof(BITMAPHANDLE));
      BitmapHandles.SetHandle(NULL, FALSE);
   }
   SetRequestedImage( nCellIndex, pBitmap, (L_INT *) puFramesRequested, uLength, 0);
   return SUCCESS;
}
L_INT LImageViewer_EnableCellLowMemoryUsageExample(LImageViewer& ImageViewer)
{
   FILEINFO                 FileInfo;
   pDISPCONTAINERBITMAPINFO pBitmapInfo;
   L_INT                    nI, nRet;
   LBitmapBase              LeadBitmap;
   LFile                    LeadFile;
   LeadFile.SetBitmap(&LeadBitmap) ;
   LeadFile.SetFileName(MAKE_IMAGE_PATH(TEXT("image1.dcm")));
   nRet = LeadFile.GetInfo(&FileInfo, sizeof(FILEINFO)) ;
   if(nRet != SUCCESS)
      return nRet;
   pBitmapInfo = (DISPCONTAINERBITMAPINFO *)malloc(sizeof(DISPCONTAINERBITMAPINFO) * FileInfo.TotalPages);
   for (nI = 0; nI < FileInfo.TotalPages; nI++)
   {
      pBitmapInfo[nI].uHeight = FileInfo.Height;
      pBitmapInfo[nI].uWidth = FileInfo.Width;
      pBitmapInfo[nI].uXResolution = FileInfo.XResolution;
      pBitmapInfo[nI].uYResolution = FileInfo.YResolution;
   }
   ImageViewer.InsertCell( 0, 0);
   ImageViewer.EnableLowMemoryUsageCallBack(TRUE);
   ImageViewer.EnableCellLowMemoryUsage(0,
                                        0,
                                        FileInfo.TotalPages,
                                        pBitmapInfo,
                                        0);
   // invert all the frames in the cell.
   for (nI = 0; nI < FileInfo.TotalPages; nI ++)
   {
      ImageViewer.InvertBitmap( 0, nI, 0);
   }
   return SUCCESS;
}
#endif // #if defined(LEADTOOLS_V17_OR_LATER)
Products | Support | Contact Us | Copyright Notices
© 2006-2014 All Rights Reserved. LEAD Technologies, Inc.