diff --git a/inc/thorvg.h b/inc/thorvg.h index a8f1f829..56101a4b 100644 --- a/inc/thorvg.h +++ b/inc/thorvg.h @@ -343,6 +343,21 @@ public: */ Result composite(std::unique_ptr target, CompositeMethod method) noexcept; + /** + * @brief Gets the bounding box of the paint object before any transformation. + * + * @param[out] x The x coordinate of the upper left corner of the object. + * @param[out] y The y coordinate of the upper left corner of the object. + * @param[out] w The width of the object. + * @param[out] h The height of the object. + * + * @return Result::Success when succeed, Result::InsufficientCondition otherwise. + * + * @note The bounding box doesn't indicate the final rendered region. It's the smallest rectangle that encloses the object. + * @see Paint::bounds(float* x, float* y, float* w, float* h, bool transformed); + */ + TVG_DEPRECATED Result bounds(float* x, float* y, float* w, float* h) const noexcept; + /** * @brief Gets the axis-aligned bounding box of the paint object. * @@ -1153,6 +1168,24 @@ public: */ Result load(const std::string& path) noexcept; + /** + * @brief Loads a picture data from a memory block of a given size. + * + * @param[in] data A pointer to a memory location where the content of the picture file is stored. + * @param[in] size The size in bytes of the memory occupied by the @p data. + * @param[in] copy Decides whether the data should be copied into the engine local buffer. + * + * @retval Result::Success When succeed. + * @retval Result::InvalidArguments In case no data are provided or the @p size is zero or less. + * @retval Result::NonSupport When trying to load a file with an unknown extension. + * @retval Result::Unknown If an error occurs at a later stage. + * + * @warning: you have responsibility to release the @p data memory if the @p copy is true + * @deprecated Use load(const char* data, uint32_t size, const std::string& mimeType, bool copy) instead. + * @see Result load(const char* data, uint32_t size, const std::string& mimeType, bool copy = false) noexcept + */ + TVG_DEPRECATED Result load(const char* data, uint32_t size, bool copy = false) noexcept; + /** * @brief Loads a picture data from a memory block of a given size. * diff --git a/src/lib/tvgPaint.cpp b/src/lib/tvgPaint.cpp index 450a221d..a2685b33 100644 --- a/src/lib/tvgPaint.cpp +++ b/src/lib/tvgPaint.cpp @@ -356,6 +356,12 @@ Matrix Paint::transform() noexcept } +TVG_DEPRECATED Result Paint::bounds(float* x, float* y, float* w, float* h) const noexcept +{ + return this->bounds(x, y, w, h, false); +} + + Result Paint::bounds(float* x, float* y, float* w, float* h, bool transform) const noexcept { if (pImpl->bounds(x, y, w, h, transform)) return Result::Success; diff --git a/src/lib/tvgPicture.cpp b/src/lib/tvgPicture.cpp index 7de38b2c..fd324a94 100644 --- a/src/lib/tvgPicture.cpp +++ b/src/lib/tvgPicture.cpp @@ -67,6 +67,12 @@ Result Picture::load(const char* data, uint32_t size, const string& mimeType, bo } +TVG_DEPRECATED Result Picture::load(const char* data, uint32_t size, bool copy) noexcept +{ + return load(data, size, "", copy); +} + + Result Picture::load(uint32_t* data, uint32_t w, uint32_t h, bool copy) noexcept { if (!data || w <= 0 || h <= 0) return Result::InvalidArguments;