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>
24 #include <dali/public-api/images/pixel-data.h>
30 * @brief Load an image synchronously from local file.
32 * @note This method is thread safe, i.e. can be called from any thread.
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.
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 );
49 * @brief Determine the size of an image that LoadImageFromFile will provide when
50 * given the same image loading parameters.
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
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.
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 );
72 * @brief Load an image synchronously from a remote resource.
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.
80 * @return handle to the loaded PixelData object or an empty handle in case downloading or decoding failed.
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 );
92 #endif // DALI_IMAGE_LOADING_H