Merge "DALi Version 1.4.36" into 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) 2019 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 #include <dali/public-api/signals/dali-signal.h>
21 #include <dali/devel-api/adaptor-framework/pixel-buffer.h>
22 #include <dali-toolkit/public-api/image-loader/async-image-loader.h>
23
24 namespace Dali
25 {
26 namespace Toolkit
27 {
28 namespace DevelAsyncImageLoader
29 {
30
31 typedef Signal< void ( uint32_t, Devel::PixelBuffer, bool ) > PixelBufferLoadedSignalType;
32
33 /**
34  * @brief Whether to multiply alpha into color channels on load
35  */
36 enum class PreMultiplyOnLoad
37 {
38   OFF = 0, ///< Don't modify the image
39   ON           ///< Multiply alpha into color channels on load
40 };
41
42 /**
43  * @brief Starts an image loading task.
44  * @REMARK_INTERNET
45  * @REMARK_STORAGE
46  * @param[in] asyncImageLoader The ayncImageLoader
47  * @param[in] url The URL of the image file to load
48  * @param[in] dimensions The width and height to fit the loaded image to
49  * @param[in] fittingMode The method used to fit the shape of the image before loading to the shape defined by the size parameter
50  * @param[in] samplingMode The filtering method used when sampling pixels from the input image while fitting it to desired size
51  * @param[in] orientationCorrection Reorient the image to respect any orientation metadata in its header
52  * @param[in] preMultiplyOnLoad ON if the image color should be multiplied by it's alpha. Set to OFF if there is no alpha
53  * @return The loading task id
54  */
55 DALI_TOOLKIT_API uint32_t Load( AsyncImageLoader asyncImageLoader,
56                                 const std::string& url,
57                                 ImageDimensions dimensions,
58                                 FittingMode::Type fittingMode,
59                                 SamplingMode::Type samplingMode,
60                                 bool orientationCorrection,
61                                 DevelAsyncImageLoader::PreMultiplyOnLoad preMultiplyOnLoad );
62
63 /**
64  * @brief Starts an mask applying task.
65  * @REMARK_INTERNET
66  * @REMARK_STORAGE
67  * @param[in] asyncImageLoader The ayncImageLoader
68  * @param[in] pixelBuffer Pointer to raw pixel data to be masked
69  * @param[in] maskPixelBuffer Pointer to raw masking data
70  * @param[in] contentScale The factor to scale the content
71  * @param[in] cropToMask Whether to crop the content to the mask size
72  * @return The masking task id
73  */
74 DALI_TOOLKIT_API uint32_t ApplyMask( AsyncImageLoader asyncImageLoader,
75                                      Devel::PixelBuffer pixelBuffer,
76                                      Devel::PixelBuffer maskPixelBuffer,
77                                      float contentScale,
78                                      bool cropToMask );
79
80 /**
81  * Connect to this signal if you want to load a PixelBuffer instead of a PixelData.
82  * @note Connecting to this signal prevents the emission of the ImageLoadedSignal.
83  */
84 DALI_TOOLKIT_API PixelBufferLoadedSignalType&  PixelBufferLoadedSignal( AsyncImageLoader asyncImageLoader );
85
86 }
87 } // Toolkit
88 } // Dali
89
90 #endif