Merge "Fix svace issue - uninitialized class member" into devel/master
[platform/core/uifw/dali-adaptor.git] / adaptors / devel-api / adaptor-framework / image-loading.h
1 #ifndef DALI_IMAGE_LOADING_H
2 #define DALI_IMAGE_LOADING_H
3
4 /*
5  * Copyright (c) 2017 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 <string>
22 #include <dali/public-api/common/dali-common.h>
23 #include <dali/public-api/images/image-operations.h>
24 #include <dali/public-api/images/pixel-data.h>
25
26 namespace Dali
27 {
28
29 /**
30  * @brief Load an image synchronously from local file.
31  *
32  * @note This method is thread safe, i.e. can be called from any thread.
33  *
34  * @param [in] url The URL of the image file to load.
35  * @param [in] size The width and height to fit the loaded image to, 0.0 means whole image
36  * @param [in] fittingMode The method used to fit the shape of the image before loading to the shape defined by the size parameter.
37  * @param [in] samplingMode The filtering method used when sampling pixels from the input image while fitting it to desired size.
38  * @param [in] orientationCorrection Reorient the image to respect any orientation metadata in its header.
39  * @return handle to the loaded PixelData object or an empty handle in case loading failed.
40  */
41 DALI_IMPORT_API PixelData LoadImageFromFile(
42   const std::string& url,
43   ImageDimensions size = ImageDimensions( 0, 0 ),
44   FittingMode::Type fittingMode = FittingMode::DEFAULT,
45   SamplingMode::Type samplingMode = SamplingMode::BOX_THEN_LINEAR,
46   bool orientationCorrection = true );
47
48 /**
49  * @brief Determine the size of an image that LoadImageFromFile will provide when
50  * given the same image loading parameters.
51  *
52  * This is a synchronous request.
53  * This function is used to determine the size of an image before it has loaded.
54  * @param[in] filename name of the image.
55  * @param[in] size The requested size for the image.
56  * @param[in] fittingMode The method to use to map the source image to the desired
57  * dimensions.
58  * @param[in] samplingMode The image filter to use if the image needs to be
59  * downsampled to the requested size.
60  * @param[in] orientationCorrection Whether to use image metadata to rotate or
61  * flip the image, e.g., from portrait to landscape.
62  * @return dimensions that image will have if it is loaded with given parameters.
63  */
64 DALI_IMPORT_API ImageDimensions GetClosestImageSize(
65   const std::string& filename,
66   ImageDimensions size = ImageDimensions(0, 0),
67   FittingMode::Type fittingMode = FittingMode::DEFAULT,
68   SamplingMode::Type samplingMode = SamplingMode::BOX_THEN_LINEAR ,
69   bool orientationCorrection = true );
70
71 /**
72  * @brief Load an image synchronously from a remote resource.
73  *
74  * @param [in] url The URL of the image file to load.
75  * @param [in] size The width and height to fit the loaded image to, 0.0 means whole image
76  * @param [in] fittingMode The method used to fit the shape of the image before loading to the shape defined by the size parameter.
77  * @param [in] samplingMode The filtering method used when sampling pixels from the input image while fitting it to desired size.
78  * @param [in] orientationCorrection Reorient the image to respect any orientation metadata in its header.
79  *
80  * @return handle to the loaded PixelData object or an empty handle in case downloading or decoding failed.
81  */
82 DALI_IMPORT_API PixelData DownloadImageSynchronously(
83   const std::string& url,
84   ImageDimensions size = ImageDimensions( 0, 0 ),
85   FittingMode::Type fittingMode = FittingMode::DEFAULT,
86   SamplingMode::Type samplingMode = SamplingMode::BOX_THEN_LINEAR,
87   bool orientationCorrection = true );
88
89
90 } // Dali
91
92 #endif // DALI_IMAGE_LOADING_H