Available in LEADTOOLS Imaging Pro, Vector, Document, and Medical Imaging toolkits. |
L_StartFeedInfo
#include "l_bitmap.h"
L_LTFIL_API L_INT EXT_FUNCTION L_StartFeedInfo(phInfo, pFileInfo, uStructSize, uFlags, pLoadOptions)
L_VOID** phInfo; |
/* address of a void pointer that will identify the info process */ |
pFILEINFO pFileInfo; |
/* pointer to the FILEINFOFILEINFO structure to be filled */ |
L_UINT uStructSize; |
/* size in bytes, of the structure pointed to by pFileInfo */ |
L_UINT uFlags; |
/* flag */ |
pLOADFILEOPTION pLoadOptions; |
/* pointer to optional extended load options */ |
Initializes a file-info process in which you control the input stream. You must call the L_FeedInfo function to supply buffered data, and you must call L_StopFeedInfo when the process is complete.
Parameter |
Description |
phInfo |
The address of a void pointer that will identify the info process. Use this pointer with the L_FeedInfo and L_StopFeedInfo functions. |
pFileInfo |
Pointer to the FILEINFO structure to be filled. For more information refer to FILEINFO structure. |
uStructSize |
Size in bytes, of the structure pointed to by pFileInfo. Use sizeof(FILEINFO). |
uFlags |
Flag indicating whether to update the TotalPages field in the FILEINFO structure. For more information, refer to the uFlags parameter in L_FileInfo. |
pLoadOptions |
Pointer to optional extended load options. Pass NULL to use the default load options. |
Returns
SUCCESS |
The function was successful. |
< 1 |
An error occurred. Refer to Return Codes. |
Comments
This file-info process is useful when receiving transmitted images, such as those on the Internet. It works the same way as the L_FileInfo function, except that your code supplies the image data. The file-info process works as follows:
1. |
You call the L_StartFeedInfo function to initialize the file-info process and identify the process with a void pointer (phInfo). |
2. |
You create a buffer, and each time you fill it with information, you call the L_FeedInfo function, which sends the data to the file-info process just as if the data were being read from a file on disk. |
3. |
Whenever it has enough data to do so, the file-info process behaves the same as in the L_FileInfo function. |
|
The file-info process does not update the FILEINFO structure until it has received enough information to do so. (Usually, the information, such as the bitmap height and width, is in the file header.) The file-info process will return SUCCESS_ABORT whenever all required information is available. |
4. |
To end the file-info process, you call the L_StopFeedInfo function, which cleans up the process. If you call this function before supplying enough data, it will successfully clean up the process, but will return a file-read error. You should trap the error if the process is canceled purposely. |
5. |
Get the image information from the fields described in the FILEINFO structure. |
For a summary of file information functions, refer to Getting and Setting File Information.
This function cannot be used in combination with L_RedirectIO.
Also, for information on loading an image using the same mechanism, refer to L_FeedLoad.
Note: |
More options are available in the LOADFILEOPTION structure. |
Note: |
For information about loading and saving large TIFF files faster, refer to Loading and Saving Large TIFF Files.. |
Required DLLs and Libraries
LTFIL For a listing of the exact DLLs and Libraries needed, based on the toolkit version, refer to Files To Be Included With Your Application. |
Platforms
Win32, x64, Mobile.
See Also
Functions: |
|
Topics: |
|
|
|
|
|
|
For a list of functions that utilize the LOADFILEOPTION or SAVEFILEOPTION structures, refer to Functions Utilizing the LOADFILEOPTION or SAVEFILEOPTION structures.
Example
For complete sample code, refer to the FEEDINFO example. This example demonstrates the feed-load feature by using the Windows GetTickCount function to simulate receiving a transmitted image. This example gets file information and displays it in a message box.
/* set this define to change the simulated baud rate must be a multiple of 100 */ #define SIMULATEDBAUDRATE 28800 L_INT StartFeedInfoExample(HWND hWnd) { HANDLE hFileOpen; L_VOID *hInfo; L_UCHAR cBuf[1024]; L_INT nRead; L_INT nRet; L_UINT32 dwBaseTime; L_UINT32 dwReceiveTotal; L_UINT32 dwReceiveRead; DWORD dwNumOfBytesRead=0; FILEINFO FileInfo; L_TCHAR szMessage[1024]; /* Buffer to hold information for display. */ dwBaseTime = GetTickCount(); dwReceiveTotal = 0; dwReceiveRead = 0; hFileOpen = CreateFile( MAKE_IMAGE_PATH(TEXT("ImageProcessingDemo\\Image3.cmp")), GENERIC_READ, 0, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL ); if( hFileOpen== NULL || hFileOpen == INVALID_HANDLE_VALUE) return (ERROR_FILE_OPEN); memset(&FileInfo, 0, sizeof(FILEINFO)); FileInfo.uStructSize = sizeof(FILEINFO); nRet = L_StartFeedInfo (&hInfo, &FileInfo, sizeof(FILEINFO), 0, NULL); if (nRet != SUCCESS) { CloseHandle(hFileOpen); return (nRet); } for( ; ; ) { dwReceiveTotal = ((GetTickCount() - dwBaseTime) * (SIMULATEDBAUDRATE / 100) / 100); nRead = (L_INT) min(dwReceiveTotal - dwReceiveRead, (L_UINT32) sizeof(cBuf)); if(nRead) { if(!ReadFile(hFileOpen, cBuf, nRead, &dwNumOfBytesRead, NULL)) { nRet = ERROR_FILE_READ; goto done; } if(!dwNumOfBytesRead) goto done; nRet = L_FeedInfo (hInfo, cBuf, dwNumOfBytesRead); if (nRet==SUCCESS_ABORT)//done, no more data needed goto done; if (nRet!=SUCCESS)//error goto done; dwReceiveRead += (L_UINT32) dwNumOfBytesRead; } } done: CloseHandle(hFileOpen); nRet = L_StopFeedInfo (hInfo); if(nRet==SUCCESS) { /* Format the message string with data from the FILEINFO structure */ wsprintf(szMessage, TEXT("Filename: %s\n\n") TEXT("Format: %d\n\n") TEXT("Width: %d\n\n") TEXT("Height: %d\n\n") TEXT("BitsPerPixel: %d\n\n") TEXT("Size On Disk: %ld\n\n") TEXT("Size In Memory: %ld\n\n") TEXT("Compression: %s"), (L_TCHAR *) FileInfo.Name, FileInfo.Format, FileInfo.Width, FileInfo.Height, FileInfo.BitsPerPixel, FileInfo.SizeDisk, FileInfo.SizeMem, (L_TCHAR *) FileInfo.Compression); /* Display the message string */ MessageBox( hWnd, szMessage, TEXT("File Information"), MB_OK ); } return (nRet); }