L_SvgLoadDocumentMemory

#include "l_bitmap.h"

L_LTSVG_API L_INT L_SvgLoadDocumentMemory(buffer, bufferSize, docHandle, options)

Loads an SVG document from an SVG file from memory.

Parameters

const L_UCHAR* buffer

Pointer to the file in memory to be loaded.

L_UINT bufferSize

Size of the file in memory (in bytes).

L_SvgNodeHandle* docHandle

Pointer to the L_SvgNodeHandle referencing the target SVG document.

const L_SvgLoadOptions* options

Optional pointer to a structure containing SVG load options. Pass NULL to use the default options.

Returns

Value Meaning
SUCCESS The function was successful.
< 1 An error occurred. Refer to Return Codes.

Comments

Support for SVG is available in Document and Medical Imaging toolkits.

To get and set information on the document bounds and resolution refer to SVG Size, Bounds and Flat.

When the SVG document data is no longer needed, you must call L_SvgFreeNode to free storage allocated for the SVG document.

Required DLLs and Libraries

Platforms

Win32, x64, Linux.

See Also

Functions

Topics

Example

This example will save an SVG document to a memory buffer and reload it.

L_INT SvgLoadDocumentMemoryExample(L_VOID) 
{ 
   L_INT nRet = SUCCESS; 
   L_TCHAR srcFileName[L_MAXPATH] = MAKE_IMAGE_PATH(TEXT("Leadtools.doc")); 
   L_TCHAR dstFileName[L_MAXPATH] = MAKE_IMAGE_PATH(TEXT("Output.svg")); 
   L_TCHAR msg[1024] = {0}; 
 
   // Load as SVG from source document 
   wsprintf(msg, L_TEXT("Loading: %s\n"), srcFileName); 
   wprintf(msg); 
   LOADSVGOPTIONS svgOptions = {0}; 
   svgOptions.uStructSize = sizeof(LOADSVGOPTIONS); 
   nRet = L_LoadSvg(srcFileName, &svgOptions, NULL); 
 
   if(nRet != SUCCESS) 
      return nRet; 
 
   // Save it to memory as SVG 
   wsprintf(msg, L_TEXT("Saving to memory\n")); 
   wprintf(msg); 
   L_UCHAR* buffer = NULL; 
   L_UINT bufferSize = 0; 
   nRet = L_SvgSaveDocumentMemory(svgOptions.SvgHandle, &buffer, &bufferSize, NULL); 
 
   // Free the source SVG document 
   L_SvgFreeNode(svgOptions.SvgHandle); 
   svgOptions.SvgHandle = NULL; 
 
   if(nRet == SUCCESS) 
   { 
      // Load from memory 
      wsprintf(msg, L_TEXT("Loading from memory\n")); 
      wprintf(msg); 
      L_SvgNodeHandle docHandle = NULL; 
      nRet = L_SvgLoadDocumentMemory(buffer, bufferSize, &docHandle, NULL); 
 
      // Free the memory allocated by L_SvgSaveDocumentMemory 
      L_SvgFreeMemory(buffer); 
 
      if(nRet == SUCCESS) 
      { 
         // Save it to file on disk as SVG 
         wsprintf(msg, L_TEXT("Saving: %s\n"), dstFileName); 
         wprintf(msg); 
         nRet = L_SvgSaveDocument(dstFileName, docHandle, NULL); 
      } 
 
      // Free the SVG document 
      L_SvgFreeNode(docHandle); 
   } 
 
   return nRet; 
} 

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

LEADTOOLS SVG C API Help