[dali_2.1.23] Merge branch 'devel/master'
[platform/core/uifw/dali-toolkit.git] / dali-toolkit / devel-api / image-loader / async-image-loader-devel.h
1 #ifndef DALI_TOOLKIT_DEVEL_API_IMAGE_LOADER_ASYNC_IMAGE_LOADER_DEVEL_H
2 #define DALI_TOOLKIT_DEVEL_API_IMAGE_LOADER_ASYNC_IMAGE_LOADER_DEVEL_H
3
4 /*
5  * Copyright (c) 2020 Samsung Electronics Co., Ltd.
6  *
7  * Licensed under the Apache License, Version 2.0 (the "License");
8  * you may not use this file except in compliance with the License.
9  * You may obtain a copy of the License at
10  *
11  * http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing, software
14  * distributed under the License is distributed on an "AS IS" BASIS,
15  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16  * See the License for the specific language governing permissions and
17  * limitations under the License.
18  */
19
20 // EXTERNAL HEADER
21 #include <dali/devel-api/adaptor-framework/animated-image-loading.h>
22 #include <dali/devel-api/adaptor-framework/pixel-buffer.h>
23 #include <dali/public-api/signals/dali-signal.h>
24
25 // INTERNAL HEADER
26 #include <dali-toolkit/public-api/image-loader/async-image-loader.h>
27
28 namespace Dali
29 {
30 namespace Toolkit
31 {
32 namespace DevelAsyncImageLoader
33 {
34 typedef Signal<void(uint32_t, Devel::PixelBuffer)> PixelBufferLoadedSignalType;
35
36 /**
37  * @brief Whether to multiply alpha into color channels on load
38  */
39 enum class PreMultiplyOnLoad
40 {
41   OFF = 0, ///< Don't modify the image
42   ON       ///< Multiply alpha into color channels on load
43 };
44
45 /**
46  * @brief Starts an animated image loading task.
47  * @REMARK_INTERNET
48  * @REMARK_STORAGE
49  * @param[in] asyncImageLoader The ayncImageLoader
50  * @param[in] animatedImageLoading The AnimatedImageLoading to load animated image
51  * @param[in] frameIndex The frame index of a frame to be loaded frame
52  * @return The loading task id
53  */
54 DALI_TOOLKIT_API uint32_t LoadAnimatedImage(AsyncImageLoader           asyncImageLoader,
55                                             Dali::AnimatedImageLoading animatedImageLoading,
56                                             uint32_t                   frameIndex);
57
58 /**
59  * @brief Starts an image loading task.
60  * @REMARK_INTERNET
61  * @REMARK_STORAGE
62  * @param[in] asyncImageLoader The ayncImageLoader
63  * @param[in] url The URL of the image file to load
64  * @param[in] dimensions The width and height to fit the loaded image to
65  * @param[in] fittingMode The method used to fit the shape of the image before loading to the shape defined by the size parameter
66  * @param[in] samplingMode The filtering method used when sampling pixels from the input image while fitting it to desired size
67  * @param[in] orientationCorrection Reorient the image to respect any orientation metadata in its header
68  * @param[in] preMultiplyOnLoad ON if the image color should be multiplied by it's alpha. Set to OFF if there is no alpha or if the image need to be applied alpha mask.
69  * @return The loading task id
70  */
71 DALI_TOOLKIT_API uint32_t Load(AsyncImageLoader                         asyncImageLoader,
72                                const std::string&                       url,
73                                ImageDimensions                          dimensions,
74                                FittingMode::Type                        fittingMode,
75                                SamplingMode::Type                       samplingMode,
76                                bool                                     orientationCorrection,
77                                DevelAsyncImageLoader::PreMultiplyOnLoad preMultiplyOnLoad);
78
79 /**
80  * @brief Starts an mask applying task.
81  * @REMARK_INTERNET
82  * @REMARK_STORAGE
83  * @param[in] asyncImageLoader The ayncImageLoader
84  * @param[in] pixelBuffer Pointer to raw pixel data to be masked
85  * @param[in] maskPixelBuffer Pointer to raw masking data
86  * @param[in] contentScale The factor to scale the content
87  * @param[in] cropToMask Whether to crop the content to the mask size
88  * @param[in] preMultiplyOnLoad ON if the image color should be multiplied by it's alpha. Set to OFF if there is no alpha.
89  * @return The masking task id
90  */
91 DALI_TOOLKIT_API uint32_t ApplyMask(AsyncImageLoader                         asyncImageLoader,
92                                     Devel::PixelBuffer                       pixelBuffer,
93                                     Devel::PixelBuffer                       maskPixelBuffer,
94                                     float                                    contentScale,
95                                     bool                                     cropToMask,
96                                     DevelAsyncImageLoader::PreMultiplyOnLoad preMultiplyOnLoad);
97
98 /**
99  * Connect to this signal if you want to load a PixelBuffer instead of a PixelData.
100  * @note Connecting to this signal prevents the emission of the ImageLoadedSignal.
101  */
102 DALI_TOOLKIT_API PixelBufferLoadedSignalType& PixelBufferLoadedSignal(AsyncImageLoader asyncImageLoader);
103
104 } // namespace DevelAsyncImageLoader
105 } // namespace Toolkit
106 } // namespace Dali
107
108 #endif