| ThorVG v0.8

Functions
Saver
ThorVG_CAPI

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

Collaboration diagram for Saver:

## Functions
TVG_EXPORT Tvg_Saver * | tvg_saver_new ()
| Creates a new Tvg_Saver object. More...
TVG_EXPORT 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_EXPORT Tvg_Result | tvg_saver_sync (Tvg_Saver *saver)
| Guarantees that the saving task is finished. More...
TVG_EXPORT 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_EXPORT Tvg_Result tvg_saver_del | ( | Tvg_Saver * | saver | ) |

Deletes the given Tvg_Saver object.

Parameters

  [in] | saver | The Tvg_Saver object to be deleted.

Returns
  Tvg_Result enumeration.

Return values

  TVG_RESULT_SUCCESS | Succeed.
  TVG_RESULT_INVALID_ARGUMENT | An invalid Tvg_Saver pointer.

## ◆ tvg_saver_new()

TVG_EXPORT Tvg_Saver* tvg_saver_new | ( |  | ) |

Creates a new Tvg_Saver object.

Returns
  A new Tvg_Saver object.

## ◆ tvg_saver_save()

TVG_EXPORT 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] | saver | The Tvg_Saver object connected with the saving task.
  [in] | paint | The paint to be saved with all its associated properties.
  [in] | path | A path to the file, in which the paint data is to be saved.
  [in] | compress | If `true` then compress data if possible.

Returns
  Tvg_Result enumeration.

Return values

  TVG_RESULT_SUCCESS | Succeed.
  TVG_RESULT_INVALID_ARGUMENT | A `nullptr` passed as the argument.
  TVG_RESULT_INSUFFICIENT_CONDITION | Currently saving other resources.
  TVG_RESULT_NOT_SUPPORTED | Trying to save a file with an unknown extension or in an unsupported format.
  TVG_RESULT_MEMORY_CORRUPTION | An internal error.
  TVG_RESULT_UNKNOWN | An 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_EXPORT 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] | saver | The Tvg_Saver object connected with the saving task.

Returns
  Tvg_Result enumeration.

Return values

  TVG_RESULT_SUCCESS | Succeed.
  TVG_RESULT_INVALID_ARGUMENT | A `nullptr` passed as the argument.
  TVG_RESULT_INSUFFICIENT_CONDITION | No saving task is running.

Note
  The asynchronous tasking is dependent on the Saver module implementation.

See also
  tvg_saver_save()