[dali_2.3.19] Merge branch 'devel/master'
[platform/core/uifw/dali-toolkit.git] / dali-toolkit / public-api / image-loader / sync-image-loader.h
1 #ifndef DALI_TOOLKIT_SYNC_IMAGE_LOADER_H
2 #define DALI_TOOLKIT_SYNC_IMAGE_LOADER_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 INCLUDES
21 #include <dali/public-api/images/image-operations.h>
22 #include <dali/public-api/images/pixel-data.h>
23 #include <string>
24
25 // INTERNAL INCLUDES
26 #include <dali-toolkit/public-api/dali-toolkit-common.h>
27
28 namespace Dali
29 {
30 namespace Toolkit
31 {
32 /**
33  * @addtogroup dali_toolkit_image_loader
34  * @{
35  */
36
37 namespace SyncImageLoader
38 {
39 /**
40  * @brief The methods in the SyncImageLoader namespace are used to load pixel data from a URL synchronously.
41  *
42  * Example:
43  *
44  * @code
45  * PixelData pixelData = Toolkit::SyncImageLoader::Load( "image_url.jpg" );
46  *
47  * // Check the image was loaded without error.
48  * if( pixelData )
49  * {
50  *   // Do work...
51  * }
52  *
53  * @endcode
54  */
55
56 /**
57  * @brief Loads an image synchronously.
58  * Note: When using this method, the following defaults will be used:
59  * fittingMode = FittingMode::DEFAULT
60  * samplingMode = SamplingMode::BOX_THEN_LINEAR
61  * orientationCorrection = true
62  *
63  * @SINCE_1_2_14
64  * @REMARK_INTERNET
65  * @REMARK_STORAGE
66  * @param[in] url The URL of the image file to load
67  * @return A PixelData object containing the image, or an invalid object on failure
68  */
69 DALI_TOOLKIT_API PixelData Load(const std::string& url);
70
71 /**
72  * @brief Loads an image synchronously by specifying the target dimensions.
73  * Note: When using this method, the following defaults will be used:
74  * fittingMode = FittingMode::DEFAULT
75  * samplingMode = SamplingMode::BOX_THEN_LINEAR
76  * orientationCorrection = true
77  *
78  * @SINCE_1_2_14
79  * @REMARK_INTERNET
80  * @REMARK_STORAGE
81  * @param[in] url The URL of the image file to load
82  * @param[in] dimensions The width and height to fit the loaded image to
83  * @return A PixelData object containing the image, or an invalid object on failure
84  */
85 DALI_TOOLKIT_API PixelData Load(const std::string& url, ImageDimensions dimensions);
86
87 /**
88  * @brief Loads an image synchronously by specifying the target dimensions and options.
89  * @SINCE_1_2_14
90  * @REMARK_INTERNET
91  * @REMARK_STORAGE
92  * @param[in] url The URL of the image file to load
93  * @param[in] dimensions The width and height to fit the loaded image to
94  * @param[in] fittingMode The method used to fit the shape of the image before loading to the shape defined by the size parameter
95  * @param[in] samplingMode The filtering method used when sampling pixels from the input image while fitting it to desired size
96  * @param[in] orientationCorrection Reorient the image to respect any orientation metadata in its header
97  * @return A PixelData object containing the image, or an invalid object on failure
98  */
99 DALI_TOOLKIT_API PixelData Load(const std::string& url,
100                                 ImageDimensions    dimensions,
101                                 FittingMode::Type  fittingMode,
102                                 SamplingMode::Type samplingMode,
103                                 bool               orientationCorrection);
104
105 } // namespace SyncImageLoader
106
107 /**
108  * @}
109  */
110 } // namespace Toolkit
111
112 } // namespace Dali
113
114 #endif // DALI_TOOLKIT_SYNC_IMAGE_LOADER_H