#include "l_bitmap.h"

L_UINT pEXT_CALLBACK YourRead (nFd, pBuf, uCount, pUserData)

Replaces the normal LEADTOOLS function for reading a file.



Identifies the file to be read. The file handle is returned by the REDIRECTOPEN callback function.


Points to a buffer that is to receive the data read from the file.

L_UINT uCount

Specifies the number of bytes to be read from the file.

L_VOID* pUserData

A void pointer that you can use to access a variable or structure containing data that your callback function needs. This gives you a way to receive data indirectly from the function that uses this callback function. (This is the same pointer that you pass 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 your callback function.


Value Meaning
>0 The number of bytes that the function read from the file.
-1 The function failed.


For information about using this type of callback, refer to L_RedirectIO.

Required DLLs and Libraries


For how the following function is defined and called, refer to L_RedirectIO.
This procedure is a replacement to the built in read procedure.
It reads the data from the allocated memory and adjusts the internal data.

/************************** Global Declarations **********************************/ 
typedef struct tagUSERDATA 
   L_INT32 dwSize; /* Size of the buffer. */ 
   L_INT32 dwUsed; /* Number of bytes used. */ 
   L_CHAR *pData; /* Pointer to the buffer. */ 
   L_CHAR *pCurData; /* Current pointer location. */ 
static USERDATA UserData; 
 /* Pointer to DATA structure */ 
L_UINT  WindowsRead (L_INT FD, L_CHAR  * pBuf, L_UINT uCount) 
   /* Is the request for more data than is left in memory? / 
   if (uCount + UserData.pCurData > UserData.pData + UserData.dwSize) 
      uCount = (L_UINT) (UserData.dwSize - UserData.dwUsed);   / adjust request */ 
   /* Copy data to the buffer of the caller. */ 
   _fmemcpy (pBuf, UserData.pCurData, uCount); 
   /* Adjust internal data. */ 
   UserData.pCurData += uCount; 
   UserData.dwUsed += uCount; 
   return (uCount); 

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

LEADTOOLS Raster Imaging C API Help