#include "l_bitmap.h"

L_INT pEXT_CALLBACK YourFunction (uRequiredSize, ppBuffer, pdwBufferSize, pUserData)

L_SIZE_T uRequiredSize;

buffer size

L_UCHAR ** ppBuffer;

address of a pointer to the buffer

L_SIZE_T* pdwBufferSize;

pointer to a variable

L_VOID* pUserData;

pointer to additional parameters

Provides input to the L_SaveFileBuffer or L_SaveBitmapBuffer function.




Minimum buffer size required to save the bitmap or file.


Address of a pointer to the buffer to save. The callback function allows the user to reallocate the buffer. When reallocating a buffer, the buffer address can change. This parameter should be updated with the new address of the reallocated buffer.


Pointer to a variable that contains the actual buffer size. For the bitmap or file to be saved, *pdwBufferSize must be greater than or equal to uRequiredSize.


A void pointer that can be used to access a variable or structure containing data that the callback function needs. This provides a way to receive data indirectly from the function that uses this callback function. (This is the same pointer passed in the pUserData parameter of the calling function.)


Keep in mind that this is a void pointer, which must be cast to the appropriate data type within the callback function.



The function was successful.


An error occurred.


This callback function is optional, but recommended. If the callback is not used, then the user must allocate a buffer that is large enough to hold the memory file. If the buffer is not large enough and the callback is not used, the function will fail.

If the user provides a callback function, it must reallocate the buffer to be at least uRequiredSize bytes. The ppBuffer parameter must be updated with the new buffer. The pdwBufferSize parameter must be updated with the size of the new buffer.

If the callback successfully reallocates the buffer, it should return SUCCESS.

If the callback fails to successfully reallocate the buffer, it should return FAILURE.

Required DLLs and Libraries


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


L_SaveFileBuffer, L_SaveBitmapBuffer


typedef struct _tagMYBUFFER 
   L_UCHAR   *pBuffer; 
   L_SIZE_T  dwBufferSize; 
L_INT EXT_CALLBACK ExampleSaveBufferCB(L_SIZE_T    uRequiredSize, 
                                       L_UCHAR  ** ppBuffer, 
                                       L_SIZE_T *  pdwBufferSize, 
                                       L_VOID*     pUserData) 
   L_UCHAR *pTempBuffer; 
   L_INT nRet; 
   L_TCHAR szMsg[400]; 
   pMYBUFFER pMyBuffer = (pMYBUFFER)pUserData; 
   pTempBuffer = (L_UCHAR*)realloc(pMyBuffer->pBuffer, uRequiredSize); 
   if (pTempBuffer) 
      wsprintf(szMsg, TEXT("** Reallocate from\n\t[0x%x, %d] to\n\t[0x%x, %d]\n"),  
      //MessageBox(NULL, szMsg, TEXT(""), MB_OK); 
      pMyBuffer->pBuffer = pTempBuffer; 
      pMyBuffer->dwBufferSize = uRequiredSize; 
      *ppBuffer = pMyBuffer->pBuffer; 
      *pdwBufferSize = uRequiredSize; 
      nRet = SUCCESS; 
      nRet = FAILURE; 
   return nRet; 
Help Version 20.0.2019.9.22
Products | Support | Contact Us | Intellectual Property Notices
© 1991-2019 LEAD Technologies, Inc. All Rights Reserved.

LEADTOOLS Raster Imaging C API Help