ThorVG  v0.9
Functions

A module for exporting a paint object into a specified file. More...

Collaboration diagram for Saver:

Functions

TVG_API Tvg_Savertvg_saver_new ()
 Creates a new Tvg_Saver object. More...
 
TVG_API Tvg_Result tvg_saver_save (Tvg_Saver *saver, Tvg_Paint *paint, const char *path, bool compress)
 Exports the given paint data to the given path. More...
 
TVG_API Tvg_Result tvg_saver_sync (Tvg_Saver *saver)
 Guarantees that the saving task is finished. More...
 
TVG_API Tvg_Result tvg_saver_del (Tvg_Saver *saver)
 Deletes the given Tvg_Saver object. More...
 

Detailed Description

A module for exporting a paint object into a specified file.

The module enables to save the composed scene and/or image from a paint object. Once it's successfully exported to a file, it can be recreated using the Picture module.

Function Documentation

◆ tvg_saver_del()

TVG_API Tvg_Result tvg_saver_del ( Tvg_Saver saver)

Deletes the given Tvg_Saver object.

Parameters
[in]saverThe Tvg_Saver object to be deleted.
Returns
Tvg_Result enumeration.
Return values
TVG_RESULT_SUCCESSSucceed.
TVG_RESULT_INVALID_ARGUMENTAn invalid Tvg_Saver pointer.

◆ tvg_saver_new()

TVG_API Tvg_Saver* tvg_saver_new ( )

Creates a new Tvg_Saver object.

Returns
A new Tvg_Saver object.

◆ tvg_saver_save()

TVG_API Tvg_Result tvg_saver_save ( Tvg_Saver saver,
Tvg_Paint paint,
const char *  path,
bool  compress 
)

Exports the given paint data to the given path.

If the saver module supports any compression mechanism, it will optimize the data size. This might affect the encoding/decoding time in some cases. You can turn off the compression if you wish to optimize for speed.

Parameters
[in]saverThe Tvg_Saver object connected with the saving task.
[in]paintThe paint to be saved with all its associated properties.
[in]pathA path to the file, in which the paint data is to be saved.
[in]compressIf true then compress data if possible.
Returns
Tvg_Result enumeration.
Return values
TVG_RESULT_SUCCESSSucceed.
TVG_RESULT_INVALID_ARGUMENTA nullptr passed as the argument.
TVG_RESULT_INSUFFICIENT_CONDITIONCurrently saving other resources.
TVG_RESULT_NOT_SUPPORTEDTrying to save a file with an unknown extension or in an unsupported format.
TVG_RESULT_MEMORY_CORRUPTIONAn internal error.
TVG_RESULT_UNKNOWNAn empty paint is to be saved.
Note
Saving can be asynchronous if the assigned thread number is greater than zero. To guarantee the saving is done, call tvg_saver_sync() afterwards.
See also
tvg_saver_sync()

◆ tvg_saver_sync()

TVG_API Tvg_Result tvg_saver_sync ( Tvg_Saver saver)

Guarantees that the saving task is finished.

The behavior of the Saver module works on a sync/async basis, depending on the threading setting of the Initializer. Thus, if you wish to have a benefit of it, you must call tvg_saver_sync() after the tvg_saver_save() in the proper delayed time. Otherwise, you can call tvg_saver_sync() immediately.

Parameters
[in]saverThe Tvg_Saver object connected with the saving task.
Returns
Tvg_Result enumeration.
Return values
TVG_RESULT_SUCCESSSucceed.
TVG_RESULT_INVALID_ARGUMENTA nullptr passed as the argument.
TVG_RESULT_INSUFFICIENT_CONDITIONNo saving task is running.
Note
The asynchronous tasking is dependent on the Saver module implementation.
See also
tvg_saver_save()