From 5f4c25221528107633975bbcbd32249ac1941fa1 Mon Sep 17 00:00:00 2001 From: seungho Date: Tue, 28 Dec 2021 17:29:02 +0900 Subject: [PATCH] Add DesiredWidth/Height for animated image loading Change-Id: Iddf7e031f0c7dc646649b5a9f47bd648910d4b46 --- .../adaptor-framework/animated-image-loading.cpp | 8 ++++-- .../adaptor-framework/animated-image-loading.h | 11 ++++++-- .../imaging/common/animated-image-loading-impl.h | 32 ++++++++++++++++++++-- 3 files changed, 45 insertions(+), 6 deletions(-) diff --git a/dali/devel-api/adaptor-framework/animated-image-loading.cpp b/dali/devel-api/adaptor-framework/animated-image-loading.cpp index 6f8b3b9..1a5cc0d 100644 --- a/dali/devel-api/adaptor-framework/animated-image-loading.cpp +++ b/dali/devel-api/adaptor-framework/animated-image-loading.cpp @@ -60,9 +60,13 @@ AnimatedImageLoading AnimatedImageLoading::DownCast(BaseHandle handle) AnimatedImageLoading::~AnimatedImageLoading() { } -Dali::Devel::PixelBuffer AnimatedImageLoading::LoadFrame(uint32_t frameIndex) + +Dali::Devel::PixelBuffer AnimatedImageLoading::LoadFrame(uint32_t frameIndex, + ImageDimensions size, + Dali::FittingMode::Type fittingMode, + Dali::SamplingMode::Type samplingMode) { - return GetImplementation(*this).LoadFrame(frameIndex); + return GetImplementation(*this).LoadFrame(frameIndex, size, fittingMode, samplingMode); } ImageDimensions AnimatedImageLoading::GetImageSize() const diff --git a/dali/devel-api/adaptor-framework/animated-image-loading.h b/dali/devel-api/adaptor-framework/animated-image-loading.h index 4becd1f..2f07eb9 100644 --- a/dali/devel-api/adaptor-framework/animated-image-loading.h +++ b/dali/devel-api/adaptor-framework/animated-image-loading.h @@ -22,6 +22,7 @@ #include #include #include +#include // INTERNAL INCLUDES #include @@ -119,10 +120,16 @@ public: * * @note This function will load the entire animated image into memory if not already loaded. * @param[in] frameIndex The frame index to load. + * @param[in] size The width and height to fit the loaded image to. + * @param[in] fittingMode The FittingMode of the resource to load + * @param[in] samplingMode The SamplingMode of the resource to load + * * @return Dali::Devel::PixelBuffer The loaded PixelBuffer. If loading is fail, return empty handle. */ - - Dali::Devel::PixelBuffer LoadFrame(uint32_t frameIndex); + Dali::Devel::PixelBuffer LoadFrame(uint32_t frameIndex, + ImageDimensions size = ImageDimensions(), + Dali::FittingMode::Type fittingMode = Dali::FittingMode::SCALE_TO_FILL, + Dali::SamplingMode::Type samplingMode = Dali::SamplingMode::BOX_THEN_LINEAR); /** * @brief Get the size of a animated image. diff --git a/dali/internal/imaging/common/animated-image-loading-impl.h b/dali/internal/imaging/common/animated-image-loading-impl.h index 5517fc9..a240b1d 100644 --- a/dali/internal/imaging/common/animated-image-loading-impl.h +++ b/dali/internal/imaging/common/animated-image-loading-impl.h @@ -27,6 +27,7 @@ // INTERNAL INCLUDES #include #include +#include namespace Dali { @@ -66,9 +67,26 @@ public: ~AnimatedImageLoading() override = default; /** - * @copydoc Dali::AnimatedImageLoading::LoadFrame() + * @brief Load a frame of the animated image. + * + * @note This function will load the entire animated image into memory if not already loaded. + * @param[in] frameIndex The frame index to load. + * @param[in] size The width and height to fit the loaded image to. + * @param[in] fittingMode The FittingMode of the resource to load + * @param[in] samplingMode The SamplingMode of the resource to load + * + * @return Dali::Devel::PixelBuffer The loaded PixelBuffer. If loading is fail, return empty handle. */ - virtual Dali::Devel::PixelBuffer LoadFrame(uint32_t frameIndex) = 0; + Dali::Devel::PixelBuffer LoadFrame(uint32_t frameIndex, + ImageDimensions size, + Dali::FittingMode::Type fittingMode, + Dali::SamplingMode::Type samplingMode) + { + Dali::Devel::PixelBuffer pixelBuffer = LoadFrame(frameIndex); + return Dali::Internal::Platform::ApplyAttributesToBitmap(pixelBuffer, size, fittingMode, samplingMode); + } + +public: /** * @copydoc Dali::AnimatedImageLoading::GetImageSize() @@ -94,6 +112,16 @@ public: * @copydoc Dali::AnimatedImageLoading::HasLoadingSucceeded() */ virtual bool HasLoadingSucceeded() const = 0; + +private: + /** + * @brief Load a frame of the animated image. + * + * @note This function will load the entire animated image into memory if not already loaded. + * @param[in] frameIndex The frame index to load. + * @return Dali::Devel::PixelBuffer The loaded PixelBuffer. If loading is fail, return empty handle. + */ + virtual Dali::Devel::PixelBuffer LoadFrame(uint32_t frameIndex) = 0; }; } // namespace Adaptor -- 2.7.4