Adaptor refactor
[platform/core/uifw/dali-adaptor.git] / dali / 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
25 #include <dali/devel-api/adaptor-framework/pixel-buffer.h>
26
27 namespace Dali
28 {
29
30 /**
31  * @brief Load an image synchronously from local file.
32  *
33  * @note This method is thread safe, i.e. can be called from any thread.
34  *
35  * @param [in] url The URL of the image file to load.
36  * @param [in] size The width and height to fit the loaded image to, 0.0 means whole image
37  * @param [in] fittingMode The method used to fit the shape of the image before loading to the shape defined by the size parameter.
38  * @param [in] samplingMode The filtering method used when sampling pixels from the input image while fitting it to desired size.
39  * @param [in] orientationCorrection Reorient the image to respect any orientation metadata in its header.
40  * @return handle to the loaded PixelBuffer object or an empty handle in case loading failed.
41  */
42 DALI_IMPORT_API Devel::PixelBuffer LoadImageFromFile(
43   const std::string& url,
44   ImageDimensions size = ImageDimensions( 0, 0 ),
45   FittingMode::Type fittingMode = FittingMode::DEFAULT,
46   SamplingMode::Type samplingMode = SamplingMode::BOX_THEN_LINEAR,
47   bool orientationCorrection = true );
48
49 /**
50  * @brief Determine the size of an image that LoadImageFromFile will provide when
51  * given the same image loading parameters.
52  *
53  * This is a synchronous request.
54  * This function is used to determine the size of an image before it has loaded.
55  * @param[in] filename name of the image.
56  * @param[in] size The requested size for the image.
57  * @param[in] fittingMode The method to use to map the source image to the desired
58  * dimensions.
59  * @param[in] samplingMode The image filter to use if the image needs to be
60  * downsampled to the requested size.
61  * @param[in] orientationCorrection Whether to use image metadata to rotate or
62  * flip the image, e.g., from portrait to landscape.
63  * @return dimensions that image will have if it is loaded with given parameters.
64  */
65 DALI_IMPORT_API ImageDimensions GetClosestImageSize(
66   const std::string& filename,
67   ImageDimensions size = ImageDimensions(0, 0),
68   FittingMode::Type fittingMode = FittingMode::DEFAULT,
69   SamplingMode::Type samplingMode = SamplingMode::BOX_THEN_LINEAR ,
70   bool orientationCorrection = true );
71
72 /**
73  * @brief Load an image synchronously from a remote resource.
74  *
75  * @param [in] url The URL of the image file to load.
76  * @param [in] size The width and height to fit the loaded image to, 0.0 means whole image
77  * @param [in] fittingMode The method used to fit the shape of the image before loading to the shape defined by the size parameter.
78  * @param [in] samplingMode The filtering method used when sampling pixels from the input image while fitting it to desired size.
79  * @param [in] orientationCorrection Reorient the image to respect any orientation metadata in its header.
80  *
81  * @return handle to the loaded PixelBuffer object or an empty handle in case downloading or decoding failed.
82  */
83 DALI_IMPORT_API Devel::PixelBuffer DownloadImageSynchronously(
84   const std::string& url,
85   ImageDimensions size = ImageDimensions( 0, 0 ),
86   FittingMode::Type fittingMode = FittingMode::DEFAULT,
87   SamplingMode::Type samplingMode = SamplingMode::BOX_THEN_LINEAR,
88   bool orientationCorrection = true );
89
90 /**
91  * @brief Set the maximum texture size. Then size can be kwown by GL_MAX_TEXTURE_SIZE.
92  *
93  * @param [in] size The maximum texture size to set
94  */
95 void SetMaxTextureSize( unsigned int size );
96
97 /**
98  * @brief get the maximum texture size.
99  *
100  * @return The maximum texture size
101  */
102 DALI_IMPORT_API unsigned int GetMaxTextureSize();
103
104 } // Dali
105
106 #endif // DALI_IMAGE_LOADING_H