Support YUV decoding for JPEG
[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) 2022 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, std::vector<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  * @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.
53  * @return The loading task id
54  */
55 DALI_TOOLKIT_API uint32_t LoadAnimatedImage(AsyncImageLoader                         asyncImageLoader,
56                                             Dali::AnimatedImageLoading               animatedImageLoading,
57                                             uint32_t                                 frameIndex,
58                                             DevelAsyncImageLoader::PreMultiplyOnLoad preMultiplyOnLoad);
59
60 /**
61  * @brief Starts an image loading task.
62  * @REMARK_INTERNET
63  * @REMARK_STORAGE
64  * @param[in] asyncImageLoader The ayncImageLoader
65  * @param[in] url The URL of the image file to load
66  * @param[in] dimensions The width and height to fit the loaded image to
67  * @param[in] fittingMode The method used to fit the shape of the image before loading to the shape defined by the size parameter
68  * @param[in] samplingMode The filtering method used when sampling pixels from the input image while fitting it to desired size
69  * @param[in] orientationCorrection Reorient the image to respect any orientation metadata in its header
70  * @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.
71  * @return The loading task id
72  */
73 DALI_TOOLKIT_API uint32_t Load(AsyncImageLoader                         asyncImageLoader,
74                                const std::string&                       url,
75                                ImageDimensions                          dimensions,
76                                FittingMode::Type                        fittingMode,
77                                SamplingMode::Type                       samplingMode,
78                                bool                                     orientationCorrection,
79                                DevelAsyncImageLoader::PreMultiplyOnLoad preMultiplyOnLoad);
80
81 /**
82  * @brief Starts an mask applying task.
83  * @REMARK_INTERNET
84  * @REMARK_STORAGE
85  * @param[in] asyncImageLoader The ayncImageLoader
86  * @param[in] pixelBuffer Pointer to raw pixel data to be masked
87  * @param[in] maskPixelBuffer Pointer to raw masking data
88  * @param[in] contentScale The factor to scale the content
89  * @param[in] cropToMask Whether to crop the content to the mask size
90  * @param[in] preMultiplyOnLoad ON if the image color should be multiplied by it's alpha. Set to OFF if there is no alpha.
91  * @return The masking task id
92  */
93 DALI_TOOLKIT_API uint32_t ApplyMask(AsyncImageLoader                         asyncImageLoader,
94                                     Devel::PixelBuffer                       pixelBuffer,
95                                     Devel::PixelBuffer                       maskPixelBuffer,
96                                     float                                    contentScale,
97                                     bool                                     cropToMask,
98                                     DevelAsyncImageLoader::PreMultiplyOnLoad preMultiplyOnLoad);
99
100 /**
101  * Connect to this signal if you want to load a PixelBuffer instead of a PixelData.
102  * @note Connecting to this signal prevents the emission of the ImageLoadedSignal.
103  */
104 DALI_TOOLKIT_API PixelBufferLoadedSignalType& PixelBufferLoadedSignal(AsyncImageLoader asyncImageLoader);
105
106 } // namespace DevelAsyncImageLoader
107 } // namespace Toolkit
108 } // namespace Dali
109
110 #endif