L_VecLoadMemory

#include "ltvkrn.h"

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

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.

Parameters

L_UCHAR * pBuffer

Pointer to the file in memory to be loaded.

pVECTORHANDLE pVector

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

L_INT32 nBufferSize

Size of the file in memory (in bytes).

pLOADFILEOPTION pLoadOptions

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

pFILEINFO 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

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

You should never pass an uninitialized FILEINFO structure to this function.

Required DLLs and Libraries

See Also

Functions

Example

L_LTVKRNTEX_API 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 = NULL;     /* 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; 
 
   /* Do something here with new vector handle */ 
 
   /* Clean up */ 
   L_VecFree(&LeadVector); 
 
   GlobalUnlock( hFileInMemory ); 
 
   GlobalFree( hFileInMemory ); 
 
   return SUCCESS; 
} 
Help Version 21.0.2021.7.2
Products | Support | Contact Us | Intellectual Property Notices
© 1991-2021 LEAD Technologies, Inc. All Rights Reserved.

LEADTOOLS Vector C API Help

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