LVectorFile::StartFeedLoad

#include "ltwrappr.h"

virtual L_INT LVectorFile::StartFeedLoad(pLoadFileOption=NULL, pFileInfo=NULL)

pLOADFILEOPTION pLoadFileOption;

/* pointer to a structure */

pFILEINFO pFileInfo;

/* pointer to a structure */

Initializes a file-load process in which you control the input stream. You must call the LVectorFile::FeedLoad function to supply buffered data, and you must call LVectorFile::StopFeedLoad when the loading is complete.

Parameter

Description

pLoadFileOption

Pointer to a structure that contains information that determines the behavior of LVectorFile::FeedLoad

pFileInfo

Pointer to a FILEINFO structure. This structure may contain file information used in loading an image, or it may be updated with information about the file being loaded.

 

If nothing is known about the file, pass NULL for this parameter, or declare a variable of type FILEINFO and set the FILEINFO.Flags to 0, then pass the address of the FILEINFO structure in this parameter. In this case, if the address of a FILEINFO structure is passed, the FILEINFO structure will be updated with the results of LFile::GetInfo.

 

If only the file type is known, set pFileInfo.Format to the file type and set pFileInfo.Flags to FILEINFO_ONLYFORMATVALID. This can also be done if LFile::GetInfo has been called previously, but values that affect the size of the image loaded have been changed (for example, by calling LFileSettings::SetPCDResolution or LFileSettings::SetWMFResolution). In this case the FILEINFO structure pointed to by pFileInfo will be updated with the results of LFile::GetInfo.

 

If LFile::GetInfo has been called prior to calling this function, and no changes have been made to the contents of the structure filled by LFile::GetInfo, then the address of the filled FILEINFO structure can be passed for this parameter. In this case, the FILEINFO.Flags member should be set to FILEINFO_INFOVALID. The LFile::GetInfo function will set the FILEINFO.Flags to FILEINFO_INFOVALID. In this case the load will be faster since this function does not have to query the file filters for the file type.

Returns

SUCCESS

The function was successful.

< 1

An error occurred. Refer to Return Codes.

Comments

This file-load process is useful when receiving transmitted images, such as those on the Internet. It works the same way as the LVectorFile::LoadFile function, except that your code supplies the image data. The file-load process works as follows:

1.

You call the LVectorFile::StartFeedLoad function to initialize the file-load process and identify the process with a handle (phLoad).

2.

You create a buffer, and each time you fill it with information, you call the LVectorFile::FeedLoad function, which sends the data to the file-load 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-load process behaves the same as in the LVectorFile::LoadFile function. It allocates and begins loading the bitmap, according to the flags that you specify in the LVectorFile::StartFeedLoad function.

 

The file-load process does not update information in the bitmap handle 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-load process will make the first call to the callback function whenever this information is available.

4.

To end the file-load process, you call the LVectorFile::StopFeedLoad function, which cleans up the process. If you call this function before supplying the complete file, it will successfully clean up the process, but will return a file-read error. You should trap the error if the load is canceled purposely.

This function cannot be used in combination with the Redirect input / output functions.

Required DLLs and Libraries

LVKRN
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.

See Also

Functions:

Class Members

Topics:

Vector Images: Loading and Saving Vector Files

 

Vector Loading, Saving and Copying

Example

#define  MAX_SIZE 1024
L_INT LVectorFile__StartFeedLoadExample(HWND hWnd)
{
   UNREFERENCED_PARAMETER(hWnd);
   L_INT       nRet;
   HANDLE      hf;
   L_UCHAR     cBuf[MAX_SIZE]; // Buffer for receiving data 
   LVectorBase Vector;
   DWORD       nBytesRead;
   L_BOOL      bResult;
   LVectorFile VectorFile(&Vector, TEXT("C:\\Program Files\\LEAD Technologies, Inc\\LEADTOOLS 16\\Images\\test.dxf"));
   nRet = VectorFile.StartFeedLoad();
   if(nRet != SUCCESS)
      return nRet;
   hf = CreateFile(TEXT("C:\\Program Files\\LEAD Technologies, Inc\\LEADTOOLS 16\\Images\\POL008.DXF"), GENERIC_READ, 0, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, 0);
   for (;;)
   {
      bResult = (L_INT) ReadFile(hf, cBuf, MAX_SIZE, &nBytesRead, NULL);
      if (bResult &&  (nBytesRead == 0))
         break;
      // Supply image data from cBuf to the file-load process
      LBuffer  ImageBuffer(cBuf,MAX_SIZE) ;
      VectorFile.FeedLoad ( &ImageBuffer);
   }
   nRet = VectorFile.StopFeedLoad();
   if(nRet != SUCCESS)
      return nRet;
   //Do something with the file
   CloseHandle(hf);
   return SUCCESS;
}