1 #ifndef DALI_IMAGE_LOADING_H
2 #define DALI_IMAGE_LOADING_H
5 * Copyright (c) 2017 Samsung Electronics Co., Ltd.
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
11 * http://www.apache.org/licenses/LICENSE-2.0
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.
22 #include <dali/public-api/common/dali-common.h>
23 #include <dali/public-api/images/image-operations.h>
25 #ifdef DALI_ADAPTOR_COMPILATION // full path doesn't exist until adaptor is installed so we have to use relative
26 // @todo Make dali-adaptor code folder structure mirror the folder structure installed to dali-env
27 #include <pixel-buffer.h>
29 #include <dali/devel-api/adaptor-framework/pixel-buffer.h>
36 * @brief Load an image synchronously from local file.
38 * @note This method is thread safe, i.e. can be called from any thread.
40 * @param [in] url The URL of the image file to load.
41 * @param [in] size The width and height to fit the loaded image to, 0.0 means whole image
42 * @param [in] fittingMode The method used to fit the shape of the image before loading to the shape defined by the size parameter.
43 * @param [in] samplingMode The filtering method used when sampling pixels from the input image while fitting it to desired size.
44 * @param [in] orientationCorrection Reorient the image to respect any orientation metadata in its header.
45 * @return handle to the loaded PixelBuffer object or an empty handle in case loading failed.
47 DALI_IMPORT_API Devel::PixelBuffer LoadImageFromFile(
48 const std::string& url,
49 ImageDimensions size = ImageDimensions( 0, 0 ),
50 FittingMode::Type fittingMode = FittingMode::DEFAULT,
51 SamplingMode::Type samplingMode = SamplingMode::BOX_THEN_LINEAR,
52 bool orientationCorrection = true );
55 * @brief Determine the size of an image that LoadImageFromFile will provide when
56 * given the same image loading parameters.
58 * This is a synchronous request.
59 * This function is used to determine the size of an image before it has loaded.
60 * @param[in] filename name of the image.
61 * @param[in] size The requested size for the image.
62 * @param[in] fittingMode The method to use to map the source image to the desired
64 * @param[in] samplingMode The image filter to use if the image needs to be
65 * downsampled to the requested size.
66 * @param[in] orientationCorrection Whether to use image metadata to rotate or
67 * flip the image, e.g., from portrait to landscape.
68 * @return dimensions that image will have if it is loaded with given parameters.
70 DALI_IMPORT_API ImageDimensions GetClosestImageSize(
71 const std::string& filename,
72 ImageDimensions size = ImageDimensions(0, 0),
73 FittingMode::Type fittingMode = FittingMode::DEFAULT,
74 SamplingMode::Type samplingMode = SamplingMode::BOX_THEN_LINEAR ,
75 bool orientationCorrection = true );
78 * @brief Load an image synchronously from a remote resource.
80 * @param [in] url The URL of the image file to load.
81 * @param [in] size The width and height to fit the loaded image to, 0.0 means whole image
82 * @param [in] fittingMode The method used to fit the shape of the image before loading to the shape defined by the size parameter.
83 * @param [in] samplingMode The filtering method used when sampling pixels from the input image while fitting it to desired size.
84 * @param [in] orientationCorrection Reorient the image to respect any orientation metadata in its header.
86 * @return handle to the loaded PixelBuffer object or an empty handle in case downloading or decoding failed.
88 DALI_IMPORT_API Devel::PixelBuffer DownloadImageSynchronously(
89 const std::string& url,
90 ImageDimensions size = ImageDimensions( 0, 0 ),
91 FittingMode::Type fittingMode = FittingMode::DEFAULT,
92 SamplingMode::Type samplingMode = SamplingMode::BOX_THEN_LINEAR,
93 bool orientationCorrection = true );
98 #endif // DALI_IMAGE_LOADING_H