1 #ifndef __DALI_BITMAP_LOADER_H__
2 #define __DALI_BITMAP_LOADER_H__
5 * Copyright (c) 2015 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/pixel.h>
24 #include <dali/public-api/images/image-operations.h>
25 #include <dali/public-api/object/base-handle.h>
26 #include <dali/devel-api/images/pixel-data.h>
36 * @brief The BitmapLoader class is used to load bitmap from the URL synchronously.
38 * As the loading is synchronous, it will block the loop whilst executing.
39 * Therefore, it should be used sparingly in the main event thread, and better to be called in the worker thread.
40 * The Load() API is thread safe, it can be called from any thread without changing the state of DALI.
42 class DALI_IMPORT_API BitmapLoader : public BaseHandle
47 * @brief Create an initialized bitmap loader.
49 * By calling Load(), the synchronous loading is started immediately.
51 * @param [in] url The URL of the image file to load.
52 * @param [in] size The width and height to fit the loaded image to.
53 * @param [in] fittingMode The method used to fit the shape of the image before loading to the shape defined by the size parameter.
54 * @param [in] samplingMode The filtering method used when sampling pixels from the input image while fitting it to desired size.
55 * @param [in] orientationCorrection Reorient the image to respect any orientation metadata in its header.
57 static BitmapLoader New( const std::string& url,
58 ImageDimensions size = ImageDimensions( 0, 0 ),
59 FittingMode::Type fittingMode = FittingMode::DEFAULT,
60 SamplingMode::Type samplingMode = SamplingMode::BOX_THEN_LINEAR,
61 bool orientationCorrection = true);
64 * @brief Create an empty handle.
66 * Use BitmapLoader::New() to create an initialized object.
76 * @brief This copy constructor is required for (smart) pointer semantics.
78 * @param [in] handle A reference to the copied handle
80 BitmapLoader(const BitmapLoader& handle);
83 * @brief This assignment operator is required for (smart) pointer semantics.
85 * @param [in] rhs A reference to the copied handle
86 * @return A reference to this
88 BitmapLoader& operator=(const BitmapLoader& rhs);
93 * @brief Start the synchronous loading.
98 * @brief Query whether the image is loaded.
100 * @reture true if the image is loaded, false otherwise.
105 * @brief Returns the URL of the image.
107 * @return The URL of the image file.
109 std::string GetUrl() const;
112 * @brief Get the pixel data.
114 * The returned pixel data is still valid after the BitmapLoader been destroyed.
116 * @return The pixel data.
118 PixelDataPtr GetPixelData() const;
120 public: // Not intended for application developers
122 explicit DALI_INTERNAL BitmapLoader(Internal::BitmapLoader*);
127 #endif // __DALI_BITMAP_LOADER_H__