mirror of
https://github.com/thorvg/thorvg.git
synced 2025-07-23 14:48:24 +00:00
capi: picture size apis added
This commit is contained in:
parent
aeda0e0ad3
commit
5b7f94a527
3 changed files with 33 additions and 4 deletions
|
@ -1065,9 +1065,9 @@ public:
|
||||||
Result load(const char* data, uint32_t size, const std::string& mimeType, bool copy = false) noexcept;
|
Result load(const char* data, uint32_t size, const std::string& mimeType, bool copy = false) noexcept;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Resize the picture content with the given width and height.
|
* @brief Resizes the picture content to the given width and height.
|
||||||
*
|
*
|
||||||
* Resize the picture content while keeping the default size aspect ratio.
|
* 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.
|
* The scaling factor is established for each of dimensions and the smaller value is applied to both of them.
|
||||||
*
|
*
|
||||||
* @param[in] w A new width of the image in pixels.
|
* @param[in] w A new width of the image in pixels.
|
||||||
|
|
|
@ -1736,16 +1736,38 @@ TVG_EXPORT Tvg_Result tvg_picture_load_raw(Tvg_Paint* paint, uint32_t *data, uin
|
||||||
TVG_EXPORT Tvg_Result tvg_picture_load_data(Tvg_Paint* paint, const char *data, uint32_t size, const char *mimetype, bool copy);
|
TVG_EXPORT Tvg_Result tvg_picture_load_data(Tvg_Paint* paint, const char *data, uint32_t size, const char *mimetype, bool copy);
|
||||||
|
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief 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.
|
||||||
|
*
|
||||||
|
* \param[in] w A new width of the image in pixels.
|
||||||
|
* \param[in] h A new height of the image in pixels.
|
||||||
|
*
|
||||||
|
* \return Tvg_Result enumeration.
|
||||||
|
* \retval TVG_RESULT_SUCCESS Succeed.
|
||||||
|
* \retval TVG_RESULT_INVALID_ARGUMENT An invalid Tvg_Paint pointer.
|
||||||
|
* \retval TVG_RESULT_INSUFFICIENT_CONDITION An internal error.
|
||||||
|
*/
|
||||||
|
TVG_EXPORT Tvg_Result tvg_picture_set_size(Tvg_Paint* paint, float w, float h);
|
||||||
|
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* \brief Gets the size of the loaded picture.
|
* \brief Gets the size of the loaded picture.
|
||||||
*
|
*
|
||||||
* \warning Please do not use it, this API is not official one. It can be modified in the next version.
|
* \param[out] w A width of the image in pixels.
|
||||||
|
* \param[out] h A height of the image in pixels.
|
||||||
|
*
|
||||||
|
* \return Tvg_Result enumeration.
|
||||||
|
* \retval TVG_RESULT_SUCCESS Succeed.
|
||||||
|
* \retval TVG_RESULT_INVALID_ARGUMENT An invalid Tvg_Paint pointer.
|
||||||
*/
|
*/
|
||||||
TVG_EXPORT Tvg_Result tvg_picture_get_size(const Tvg_Paint* paint, float* w, float* h);
|
TVG_EXPORT Tvg_Result tvg_picture_get_size(const Tvg_Paint* paint, float* w, float* h);
|
||||||
|
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* \brief Gets the position and the size of the loaded picture. (BETA version)
|
* \brief 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.
|
* \warning Please do not use it, this API is not official one. It can be modified in the next version.
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -478,6 +478,13 @@ TVG_EXPORT Tvg_Result tvg_picture_load_data(Tvg_Paint* paint, const char *data,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
TVG_EXPORT Tvg_Result tvg_picture_set_size(Tvg_Paint* paint, float w, float h)
|
||||||
|
{
|
||||||
|
if (!paint) return TVG_RESULT_INVALID_ARGUMENT;
|
||||||
|
return (Tvg_Result) reinterpret_cast<Picture*>(CCP(paint))->size(w, h);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
TVG_EXPORT Tvg_Result tvg_picture_get_size(const Tvg_Paint* paint, float* w, float* h)
|
TVG_EXPORT Tvg_Result tvg_picture_get_size(const Tvg_Paint* paint, float* w, float* h)
|
||||||
{
|
{
|
||||||
if (!paint) return TVG_RESULT_INVALID_ARGUMENT;
|
if (!paint) return TVG_RESULT_INVALID_ARGUMENT;
|
||||||
|
|
Loading…
Add table
Reference in a new issue