L_DispContainerSetLowMemoryUsageCallBack

#include "l_bitmap.h"

L_LTIVW_API L_INT EXT_FUNCTION L_DispContainerSetLowMemoryUsageCallBack(hCellWnd, pfnCallBack, pUserData)

Sets a callback function which will be fired every time the control requests a new frame and the low memory usage feature is enabled (for more information see the L_DispContainerEnableCellLowMemoryUsage).

Parameters

L_HWND hCellWnd

A handle to the window that represents the Medical Viewer Cell.

DISPCONTAINERFRAMEREQUESTEDCALLBACK pfnCallBack

Callback function, which will be fired when the control requests a new frame and the low memory usage feature, is enabled (for more information refer to L_DispContainerEnableCellLowMemoryUsage). The callback function must adhere to the function prototype described in DISPCONTAINERFRAMEREQUESTEDCALLBACK.

LPVOID pUserData

Void pointer that you can use to pass one or more additional parameters that the callback function needs.

To use this feature, assign a value to a variable or create a structure that contains as many fields as you need. Then, in this parameter, pass the address of the variable or structure, casting it to L_VOID *. The callback function, which receives the address in its own pUserData parameter, can cast it to a pointer of the appropriate data type to access your variable or structure. If the additional parameters are not needed, you can pass NULL in this parameter.

Returns

Value Meaning
SUCCESS The function was successful.
< 1 An error occurred. Refer to Return Codes.

Comments

The low memory usage feature works by making the control stop from loading all of the frames at runtime. Instead, the control will load only the frames that are currently visible on the cell. The control will send a request each time the user scrolls down or up, changes the number of visible frames, etc. For example, suppose the cell layout is a 2X2 (See L_DispContainerSetCellProperties), and the user needs to load more than 100000 frames. Instead of loading them all, this function will send a callback (DISPCONTAINERFRAMEREQUESTEDCALLBACK) when the cell is loaded, requesting 4 frames (1, 2, 3 and 4) (because the cell is 2X2). Once the user scrolls down the cell to view frame number 5, frame number 1 will be disposed of because it is no longer visible, and the callback will be fired to request frame number 5. When frames are requested, the user is supposed to send them to the control using the function L_DispContainerSetRequestedImage.

To get the current frames request callback function, call L_DispContainerGetLowMemoryUsageCallBack

Required DLLs and Libraries

See Also

Functions

Topics

Example

This example shows how to use the low memory 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.

L_INT EXT_CALLBACK FramesRequestedCallBack (L_INT    nCellIndex, 
                                            L_UINT * puFramesRequested, 
                                            L_UINT   uLength, 
                                            L_VOID * pUserData) 
{ 
   L_INT nI; 
   LOADFILEOPTION LoadOption; 
   BITMAPHANDLE * pBitmap; 
   HDISPCONTAINER hCon = (HDISPCONTAINER)pUserData; 
 
   if (uLength == 0) 
      return 0; 
 
   HWND hCellWnd = L_DispContainerGetCellWindowHandle(hCon, nCellIndex, 0); 
 
   L_GetDefaultLoadFileOption(&LoadOption, sizeof(LOADFILEOPTION)); 
 
   pBitmap = (pBITMAPHANDLE)malloc(sizeof(BITMAPHANDLE) * uLength); 
 
   for (nI = 0; nI < (L_INT)uLength; nI++) 
   { 
      LoadOption.PageNumber = puFramesRequested[nI]; 
      L_LoadBitmap(MAKE_IMAGE_PATH(TEXT("xa.dcm")), &pBitmap[nI], sizeof(BITMAPHANDLE), 0, ORDER_BGRORGRAY, &LoadOption, NULL); 
       
   } 
   L_DispContainerSetRequestedImage(hCellWnd, pBitmap, (L_INT *) puFramesRequested, uLength, 0); 
   return SUCCESS; 
} 
 
 
L_INT DispContainerEnableCellLowMemoryUsageExample(HDISPCONTAINER hCon) 
{ 
   DISPCONTAINERFRAMEREQUESTEDCALLBACK oldCallBack; 
   L_VOID *                            pOldUserData; 
   FILEINFO                            FileInfo; 
   pDISPCONTAINERBITMAPINFO            pBitmapInfo; 
   L_INT                               nI; 
 
 
   L_FileInfo(MAKE_IMAGE_PATH(TEXT("xa.dcm")), &FileInfo, sizeof(FILEINFO), 0, NULL); 
 
   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; 
   } 
 
   HWND hConWnd = L_DispContainerGetWindowHandle(hCon, 0); 
   HWND hCellWnd = L_DispContainerCreateCell(hConWnd, 0); 
 
   L_DispContainerInsertCell(hCon, hCellWnd, 0, 0); 
 
 
   L_DispContainerGetLowMemoryUsageCallBack(hCellWnd, &oldCallBack, &pOldUserData); 
   L_DispContainerSetLowMemoryUsageCallBack(hCellWnd, FramesRequestedCallBack, hCon); 
 
   L_DispContainerEnableCellLowMemoryUsage(hCellWnd, 
                                          0, 
                                           FileInfo.TotalPages, 
                                           pBitmapInfo, 
                                           0); 
 
   // invert all the frames in the cell. 
 
   for (nI = 0; nI < FileInfo.TotalPages; nI ++) 
   { 
      L_DispContainerInvertBitmap(hCellWnd, nI, 0); 
   } 
 
 
   return SUCCESS; 
} 

Help Version 21.0.2021.7.2
Products | Support | Contact Us | Intellectual Property Notices
© 1991-2021 LEAD Technologies, Inc. All Rights Reserved.

LEADTOOLS Medical Image Viewer C API Help
Products | Support | Contact Us | Intellectual Property Notices
© 1991-2021 LEAD Technologies, Inc. All Rights Reserved.