| ThorVG v0.1

Public Member Functions | Static Public Member Functions | List of all members
Picturefinal
ThorVG

A class representing an image read in one of the supported formats: raw, svg, png and etc. Besides the methods inherited from the Paint, it provides methods to load & draw images on the canvas. More...

Inheritance diagram for Picture:
[legend]

## Public Member Functions
Result | load (const std::string &path) noexcept
| Loads a picture data directly from a file. More...
Result | load (const char *data, uint32_t size) noexcept
| Loads a picture data from a memory block of a given size. More...
Result | size (float w, float h) noexcept
| Resize the picture content with the given width and height. More...
Result | size (float *w, float *h) const noexcept
| Gets the size of the image. More...
const uint32_t * | data () const noexcept
| Gets the pixels information of the picture. More...
Result | load (uint32_t *data, uint32_t w, uint32_t h, bool copy) noexcept
| Loads a raw data from a memory block with a given size. More...
Result | viewbox (float *x, float *y, float *w, float *h) const noexcept
| Gets the position and the size of the loaded picture. More...
Public Member Functions inherited from Paint
Result | rotate (float degree) noexcept
| Sets the angle by which the object is rotated. More...
Result | scale (float factor) noexcept
| Sets the scale value of the object. More...
Result | translate (float x, float y) noexcept
| Sets the values by which the object is moved in a two-dimensional space. More...
Result | transform (const Matrix &m) noexcept
| Sets the matrix of the affine transformation for the object. More...
Result | opacity (uint8_t o) noexcept
| Sets the opacity of the object. More...
Result | composite (std::unique_ptr< Paint > target, CompositeMethod method) const noexcept
| Sets the composition target object and the composition method. More...
Result | bounds (float *x, float *y, float *w, float *h) const noexcept
| Gets the bounding box of the paint object before any transformation. More...
Paint * | duplicate () const noexcept
| Duplicates the object. More...
uint8_t | opacity () const noexcept
| Gets the opacity value of the object. More...

## Static Public Member Functions
static std::unique_ptr< Picture > | gen () noexcept
| Creates a new Picture object. More...

## Detailed Description

A class representing an image read in one of the supported formats: raw, svg, png and etc. Besides the methods inherited from the Paint, it provides methods to load & draw images on the canvas.

Note
  Supported formats are depended on the available TVG loaders.

## Member Function Documentation

## ◆ data()

const uint32_t* data | ( |  | ) | const
| noexcept

Gets the pixels information of the picture.

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

## ◆ gen()

static std::unique_ptr<Picture> gen | ( |  | ) |
| static noexcept

Creates a new Picture object.

Returns
  A new Picture object.

## ◆ load() [1/3]

Result load | ( | const std::string & | path | ) |
| noexcept

Loads a picture data directly from a file.

Parameters

  [in] | path | A path to the picture file.

Return values

  Result::Success | When succeed.
  Result::InvalidArguments | In case the `path` is empty.
  Result::NonSupport | When trying to load a file with an unknown extension.
  Result::Unknown | If an error occurs at a later stage.

Note
  The Load behavior can be asynchronous if the assigned thread number is greater than zero.

See also
  Initializer::init()

## ◆ load() [2/3]

Result load | ( | const char * | data,
|  | uint32_t | size
| ) |  |
| noexcept

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

Parameters

  [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`.

Return values

  Result::Success | When succeed.
  Result::InvalidArguments | In case no data are provided or the `size` is zero or less.
  Result::NonSupport | When trying to load a file with an unknown extension.
  Result::Unknown | If an error occurs at a later stage.

Note
  : This api supports only SVG format

## ◆ load() [3/3]

Result load | ( | uint32_t * | data,
|  | uint32_t | w,
|  | uint32_t | h,
|  | bool | copy
| ) |  |
| noexcept

Loads a raw data from a memory block with a given size.

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

## ◆ size() [1/2]

Result size | ( | float | w,
|  | float | h
| ) |  |
| noexcept

Resize the picture content with the given width and height.

Resize the picture content 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] | w | A new width of the image in pixels.
  [in] | h | A new height of the image in pixels.

Returns
  Result::Success when succeed, Result::InsufficientCondition otherwise.

## ◆ size() [2/2]

Result size | ( | float * | w,
|  | float * | h
| ) |  | const
| noexcept

Gets the size of the image.

Parameters

  [out] | w | The width of the image in pixels.
  [out] | h | The height of the image in pixels.

Returns
  Result::Success when succeed.

## ◆ viewbox()

Result viewbox | ( | float * | x,
|  | float * | y,
|  | float * | w,
|  | float * | h
| ) |  | const
| noexcept

Gets the position and the size of the loaded picture.

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