#include "l_bitmap.h"
L_INT pEXT_CALLBACK YourFunction (uRequiredSize, ppBuffer, pdwBufferSize, pUserData)
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.
Value | Meaning |
---|---|
SUCCESS | The function was successful. |
FAILURE | 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
typedef struct _tagMYBUFFER
{
L_UCHAR *pBuffer;
L_SIZE_T dwBufferSize;
} MYBUFFER, *pMYBUFFER;
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"),
pMyBuffer->pBuffer,
pMyBuffer->dwBufferSize,
pTempBuffer,
uRequiredSize);
//MessageBox(NULL, szMsg, TEXT(""), MB_OK);
OutputDebugString(szMsg);
pMyBuffer->pBuffer = pTempBuffer;
pMyBuffer->dwBufferSize = uRequiredSize;
*ppBuffer = pMyBuffer->pBuffer;
*pdwBufferSize = uRequiredSize;
nRet = SUCCESS;
}
else
{
nRet = FAILURE;
}
return nRet;
}
Help Collections
Raster .NET | C API | C++ Class Library | HTML5 JavaScript
Document .NET | C API | C++ Class Library | HTML5 JavaScript
Medical .NET | C API | C++ Class Library | HTML5 JavaScript
Medical Web Viewer .NET
Multimedia
Direct Show .NET | C API | Filters
Media Foundation .NET | C API | Transforms
Supported Platforms
.NET, Java, Android, and iOS/macOS Assemblies
Imaging, Medical, and Document
C API/C++ Class Libraries
Imaging, Medical, and Document
HTML5 JavaScript Libraries
Imaging, Medical, and Document