L_StartFeedInfo

#include "l_bitmap.h"

L_LTFIL_API L_INT EXT_FUNCTION L_StartFeedInfo(phInfo, pFileInfo, uStructSize, uFlags, pLoadOptions)

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.

Parameters

L_HGLOBAL* 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 pFileInfo

Pointer to the FILEINFO structure to be filled. For more information refer to FILEINFO structure.

L_UINT uStructSize

Size in bytes, of the structure pointed to by pFileInfo. Use sizeof(FILEINFO).

L_UINT uFlags

Flag indicating whether to update the TotalPages field in the FILEINFO structure. For more information, refer to the uFlags parameter in L_FileInfo.

pLOADFILEOPTION pLoadOptions

Pointer to optional extended load options. Pass NULL to use the default load options.

Returns

Value Meaning
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.

Notes:

Required DLLs and Libraries

Platforms

Win32, x64, Linux.

See Also

Functions

Topics

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, 
                     (long)FileInfo.SizeDisk, 
                     (long)FileInfo.SizeMem, 
                     (L_TCHAR *) FileInfo.Compression); 
      /* Display the message string */ 
      MessageBox( hWnd, szMessage, TEXT("File Information"), MB_OK ); 
   } 
   return (nRet); 
} 

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

LEADTOOLS Raster Imaging C API Help