L_VecLoadMemory

#include "lvkrn.h"

L_LVKRN_API L_INT L_VecLoadMemory(pBuffer, pVector, nBufferSize, pLoadOptions, pFileInfo)

L_UCHAR * pBuffer;

/* pointer to the file in memory to be loaded */

pVECTORHANDLE pVector;

/* pointer to a vector handle */

L_INT32 nBufferSize;

/* size of the file in memory (in bytes) */

pLOADFILEOPTION pLoadOptions

/* pointer to optional extended load options */

pFILEINFO pFileInfo;

/* pointer to a structure */

Loads an image file from memory into a vector handle. The file in memory can be in any supported image vector file format, compressed or uncompressed.

Parameter

Description

pBuffer

Pointer to the file in memory to be loaded.

pVector

Pointer to a vector handle referencing the vector to be filled with image data.

nBufferSize

Size of the file in memory (in bytes).

pLoadOptions

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

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

 

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 L_FileInfo has been called previously, but values that affect the size of the image loaded have been changed (for example, by calling L_SetPCDResolution or L_SetWMFResolution). In this case the FILEINFO structure pointed to by pFileInfo will be updated with the results of L_FileInfo.

 

If L_FileInfo has been called prior to calling this function, and no changes have been made to the contents of the structure filled by L_FileInfo, 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 L_FileInfo 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

The function will initialize the vector handle and allocate the storage necessary to hold the vector image.

Since the function allocates storage to hold the vector image, it is up to you to free this storage by calling L_VecFree.

This function cannot be used in combination with L_RedirectIO.

Note:

More options are available in the LOADFILEOPTION structure.

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:

L_VecLoadFile, L_VecSaveMemory, L_VecSaveFile, L_VecFree

Example

L_INT VecLoadMemoryExample(L_VOID)
{
   L_INT nRet;
   VECTORHANDLE LeadVector;   /* Vector handle for the final image */
   VECTORHANDLE TmpVector;    /* Vector handle for the initial image */
   HGLOBAL hFileInMemory;     /* Memory handle */
   L_SIZE_T zMemSize;         /* Size of the data in memory */
   L_UCHAR* pData;            /* Pointer to the data in memory */

   /* Load a vector image */
   nRet = L_VecLoadFile(MAKE_IMAGE_PATH(TEXT("random.dxf")), &TmpVector, NULL, NULL );
   if(nRet != SUCCESS)
      return nRet;

   /* Save the image as a WMF file in memory */
   nRet = L_VecSaveMemory( &hFileInMemory, &TmpVector, FILE_WMF, &zMemSize, NULL );
   if(nRet != SUCCESS)
      return nRet;

   /* Free the temporary vector */
   nRet = L_VecFree( &TmpVector );
   if(nRet != SUCCESS)
      return nRet;

   /* Get the pointer to the memory-resident file */
   pData = (L_UCHAR*) GlobalLock( hFileInMemory );

   /* Load the new vector image from memory */
   nRet = L_VecLoadMemory( pData, &LeadVector, zMemSize, NULL, NULL );
   if(nRet != SUCCESS)
      return nRet;

   /* Clean up */
   GlobalUnlock( hFileInMemory );

   GlobalFree( hFileInMemory );

   return SUCCESS;
}