A module enabling to create and to load an image in one of the supported formats: svg, png, jpg and raw.
More...
|
TVG_API Tvg_Paint * | tvg_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...
|
|
A module enabling to create and to load an image in one of the supported formats: svg, png, jpg and raw.
◆ tvg_picture_get_size()
Gets the size of the loaded picture.
- Parameters
-
[in] | paint | A Tvg_Paint pointer to the picture object. |
[out] | w | A width of the image in pixels. |
[out] | h | A height of the image in pixels. |
- Returns
- Tvg_Result enumeration.
- Return values
-
TVG_RESULT_SUCCESS | Succeed. |
TVG_RESULT_INVALID_ARGUMENT | An invalid Tvg_Paint pointer. |
◆ tvg_picture_load()
Loads a picture data directly from a file.
- Parameters
-
[in] | paint | A Tvg_Paint pointer to the picture object. |
[in] | path | The absolute path to the image file. |
- Returns
- Tvg_Result enumeration.
- Return values
-
TVG_RESULT_SUCCESS | Succeed. |
TVG_RESULT_INVALID_ARGUMENT | An invalid Tvg_Paint pointer or an empty path . |
TVG_RESULT_NOT_SUPPORTED | A file with an unknown extension. |
TVG_RESULT_UNKNOWN | An 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] | paint | A Tvg_Paint pointer to the picture object. |
[in] | data | A pointer to a memory location where the content of the picture file is stored. |
[in] | size | The size in bytes of the memory occupied by the data . |
[in] | mimetype | Mimetype 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] | copy | If true the data are copied into the engine local buffer, otherwise they are not. |
- Returns
- Tvg_Result enumeration.
- Return values
-
TVG_RESULT_SUCCESS | Succeed. |
TVG_RESULT_INVALID_ARGUMENT | In case a nullptr is passed as the argument or the size is zero or less. |
TVG_RESULT_NOT_SUPPORTED | A file with an unknown extension. |
TVG_RESULT_UNKNOWN | An 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_SUCCESS | Succeed. |
TVG_RESULT_INVALID_ARGUMENT | An invalid Tvg_Paint pointer or no data are provided or the width or height value is zero or less. |
TVG_RESULT_FAILED_ALLOCATION | A problem with memory allocation occurs. |
TVG_RESULT_INSUFFICIENT_CONDITION | An error occurs at a later stage. |
- Since
- 0.9
◆ tvg_picture_new()
Creates a new picture object.
- Returns
- A new picture object.
◆ tvg_picture_set_size()
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] | paint | A Tvg_Paint pointer to the picture object. |
[in] | w | A new width of the image in pixels. |
[in] | h | A new height of the image in pixels. |
- Returns
- Tvg_Result enumeration.
- Return values
-
TVG_RESULT_SUCCESS | Succeed. |
TVG_RESULT_INVALID_ARGUMENT | An invalid Tvg_Paint pointer. |
TVG_RESULT_INSUFFICIENT_CONDITION | An internal error. |