ThorVG  v0.8
Functions

A module enabling to create and to load an image in one of the supported formats: svg, png, jpg and raw. More...

Collaboration diagram for Picture:

Functions

TVG_EXPORT Tvg_Painttvg_picture_new ()
 Creates a new picture object. More...
 
TVG_EXPORT Tvg_Result tvg_picture_load (Tvg_Paint *paint, const char *path)
 Loads a picture data directly from a file. More...
 
TVG_EXPORT Tvg_Result tvg_picture_load_raw (Tvg_Paint *paint, uint32_t *data, uint32_t w, uint32_t h, bool copy)
 Loads a picture data from a memory block of a given size. (BETA_API) More...
 
TVG_EXPORT Tvg_Result tvg_picture_load_data (Tvg_Paint *paint, const char *data, uint32_t size, const char *mimetype, bool copy)
 Loads a picture data from a memory block of a given size. More...
 
TVG_EXPORT Tvg_Result tvg_picture_set_size (Tvg_Paint *paint, float w, float h)
 Resizes the picture content to the given width and height. More...
 
TVG_EXPORT Tvg_Result tvg_picture_get_size (const Tvg_Paint *paint, float *w, float *h)
 Gets the size of the loaded picture. More...
 
TVG_EXPORT Tvg_Result tvg_picture_get_viewbox (const Tvg_Paint *paint, float *x, float *y, float *w, float *h)
 Gets the position and the size of the loaded picture. (BETA_API) More...
 

Detailed Description

A module enabling to create and to load an image in one of the supported formats: svg, png, jpg and raw.

Function Documentation

◆ tvg_picture_get_size()

TVG_EXPORT Tvg_Result tvg_picture_get_size ( const Tvg_Paint paint,
float *  w,
float *  h 
)

Gets the size of the loaded picture.

Parameters
[in]paintA Tvg_Paint pointer to the picture object.
[out]wA width of the image in pixels.
[out]hA height of the image in pixels.
Returns
Tvg_Result enumeration.
Return values
TVG_RESULT_SUCCESSSucceed.
TVG_RESULT_INVALID_ARGUMENTAn invalid Tvg_Paint pointer.

◆ tvg_picture_get_viewbox()

TVG_EXPORT Tvg_Result tvg_picture_get_viewbox ( const Tvg_Paint paint,
float *  x,
float *  y,
float *  w,
float *  h 
)

Gets the position and the size of the loaded picture. (BETA_API)

Warning
Please do not use it, this API is not official one. It can be modified in the next version.

◆ tvg_picture_load()

TVG_EXPORT Tvg_Result tvg_picture_load ( Tvg_Paint paint,
const char *  path 
)

Loads a picture data directly from a file.

Parameters
[in]paintA Tvg_Paint pointer to the picture object.
[in]pathThe absolute path to the image file.
Returns
Tvg_Result enumeration.
Return values
TVG_RESULT_SUCCESSSucceed.
TVG_RESULT_INVALID_ARGUMENTAn invalid Tvg_Paint pointer or an empty path.
TVG_RESULT_NOT_SUPPORTEDA file with an unknown extension.
TVG_RESULT_UNKNOWNAn error at a later stage.

◆ tvg_picture_load_data()

TVG_EXPORT Tvg_Result tvg_picture_load_data ( Tvg_Paint paint,
const char *  data,
uint32_t  size,
const char *  mimetype,
bool  copy 
)

Loads a picture data from a memory block of a given size.

Parameters
[in]paintA Tvg_Paint pointer to the picture object.
[in]dataA pointer to a memory location where the content of the picture file is stored.
[in]sizeThe size in bytes of the memory occupied by the data.
[in]mimetypeMimetype or extension of data such as "jpg", "jpeg", "svg", "svg+xml", "png", etc. In case an empty string or an unknown type is provided, the loaders will be tried one by one.
[in]copyIf true the data are copied into the engine local buffer, otherwise they are not.
Returns
Tvg_Result enumeration.
Return values
TVG_RESULT_SUCCESSSucceed.
TVG_RESULT_INVALID_ARGUMENTIn case a nullptr is passed as the argument or the size is zero or less.
TVG_RESULT_NOT_SUPPORTEDA file with an unknown extension.
TVG_RESULT_UNKNOWNAn error at a later stage.
Warning
: It's the user responsibility to release the data memory if the copy is true.

◆ tvg_picture_load_raw()

TVG_EXPORT Tvg_Result tvg_picture_load_raw ( Tvg_Paint paint,
uint32_t *  data,
uint32_t  w,
uint32_t  h,
bool  copy 
)

Loads a picture data from a memory block of a given size. (BETA_API)

Returns
Tvg_Result return value
Return values
TVG_RESULT_SUCCESSSucceed.
TVG_RESULT_INVALID_PARAMETERSAn invalid Tvg_Paint.
Warning
Please do not use it, this API is not official one. It can be modified in the next version.

◆ tvg_picture_new()

TVG_EXPORT Tvg_Paint* tvg_picture_new ( )

Creates a new picture object.

Returns
A new picture object.

◆ tvg_picture_set_size()

TVG_EXPORT Tvg_Result tvg_picture_set_size ( Tvg_Paint paint,
float  w,
float  h 
)

Resizes the picture content to the given width and height.

The picture content is resized while keeping the default size aspect ratio. The scaling factor is established for each of dimensions and the smaller value is applied to both of them.

Parameters
[in]paintA Tvg_Paint pointer to the picture object.
[in]wA new width of the image in pixels.
[in]hA new height of the image in pixels.
Returns
Tvg_Result enumeration.
Return values
TVG_RESULT_SUCCESSSucceed.
TVG_RESULT_INVALID_ARGUMENTAn invalid Tvg_Paint pointer.
TVG_RESULT_INSUFFICIENT_CONDITIONAn internal error.