From 5b7f94a527efc527adf4a3c91f196b4286fb705a Mon Sep 17 00:00:00 2001 From: Mira Grudzinska Date: Mon, 4 Oct 2021 21:40:23 +0200 Subject: [PATCH] capi: picture size apis added --- inc/thorvg.h | 4 ++-- src/bindings/capi/thorvg_capi.h | 26 ++++++++++++++++++++++++-- src/bindings/capi/tvgCapi.cpp | 7 +++++++ 3 files changed, 33 insertions(+), 4 deletions(-) diff --git a/inc/thorvg.h b/inc/thorvg.h index 1acfa705..08c6904d 100644 --- a/inc/thorvg.h +++ b/inc/thorvg.h @@ -1065,9 +1065,9 @@ public: 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. * * @param[in] w A new width of the image in pixels. diff --git a/src/bindings/capi/thorvg_capi.h b/src/bindings/capi/thorvg_capi.h index 62b917bd..928f09c7 100644 --- a/src/bindings/capi/thorvg_capi.h +++ b/src/bindings/capi/thorvg_capi.h @@ -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); +/*! +* \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. * -* \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); /*! -* \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. */ diff --git a/src/bindings/capi/tvgCapi.cpp b/src/bindings/capi/tvgCapi.cpp index fbf7971b..7c6eb5d3 100644 --- a/src/bindings/capi/tvgCapi.cpp +++ b/src/bindings/capi/tvgCapi.cpp @@ -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(CCP(paint))->size(w, h); +} + + TVG_EXPORT Tvg_Result tvg_picture_get_size(const Tvg_Paint* paint, float* w, float* h) { if (!paint) return TVG_RESULT_INVALID_ARGUMENT;