ThorVG  v0.10

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_API Tvg_Painttvg_picture_new ()
 Creates a new picture object. More...
 
TVG_API Tvg_Result tvg_picture_load (Tvg_Paint *paint, const char *path)
 Loads a picture data directly from a file. More...
 
TVG_API 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. More...
 
TVG_API 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_API 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_API Tvg_Result tvg_picture_get_size (const Tvg_Paint *paint, float *w, float *h)
 Gets the size of the loaded picture. 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_API 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_load()

TVG_API 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_API 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_API 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.

Returns
Tvg_Result enumeration.
Return values
TVG_RESULT_SUCCESSSucceed.
TVG_RESULT_INVALID_ARGUMENTAn invalid Tvg_Paint pointer or no data are provided or the width or height value is zero or less.
TVG_RESULT_FAILED_ALLOCATIONA problem with memory allocation occurs.
TVG_RESULT_INSUFFICIENT_CONDITIONAn error occurs at a later stage.
Since
0.9

◆ tvg_picture_new()

TVG_API Tvg_Paint* tvg_picture_new ( )

Creates a new picture object.

Returns
A new picture object.

◆ tvg_picture_set_size()

TVG_API 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.