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>
35 * @brief The BitmapLoader class is used to load bitmap from the URL synchronously.
37 * As the loading is synchronous, it will block the loop whilst executing.
38 * Therefore, it should be used sparingly in the main event thread, and better to be called in the worker thread.
39 * The Load() API is thread safe, it can be called from any thread without changing the state of DALI.
41 class DALI_IMPORT_API BitmapLoader : public BaseHandle
46 * @brief Create an initialized bitmap loader.
48 * By calling Load(), the synchronous loading is started immediately.
50 * @param [in] url The URL of the image file to load.
51 * @param [in] size The width and height to fit the loaded image to.
52 * @param [in] fittingMode The method used to fit the shape of the image before loading to the shape defined by the size parameter.
53 * @param [in] samplingMode The filtering method used when sampling pixels from the input image while fitting it to desired size.
54 * @param [in] orientationCorrection Reorient the image to respect any orientation metadata in its header.
56 static BitmapLoader New( const std::string& url,
57 ImageDimensions size = ImageDimensions( 0, 0 ),
58 FittingMode::Type fittingMode = FittingMode::DEFAULT,
59 SamplingMode::Type samplingMode = SamplingMode::BOX_THEN_LINEAR,
60 bool orientationCorrection = true);
63 * @brief Create an empty handle.
65 * Use BitmapLoader::New() to create an initialized object.
75 * @brief This copy constructor is required for (smart) pointer semantics.
77 * @param [in] handle A reference to the copied handle
79 BitmapLoader(const BitmapLoader& handle);
82 * @brief This assignment operator is required for (smart) pointer semantics.
84 * @param [in] rhs A reference to the copied handle
85 * @return A reference to this
87 BitmapLoader& operator=(const BitmapLoader& rhs);
92 * @brief Start the synchronous loading.
97 * @brief Query whether the image is loaded.
99 * @reture true if the image is loaded, false otherwise.
104 * Get the raw pixel data.
105 * @return The pixel data. Use the GetHeight(), GetWidth(), GetStride() and GetPixelFormat() methods
106 * to decode the data.
108 unsigned char* GetPixelData() const;
111 * Get the buffer height in pixels
112 * @return the height of the buffer in pixels
114 unsigned int GetImageHeight() const;
117 * Get the buffer width in pixels
118 * @return the width of the buffer in pixels
120 unsigned int GetImageWidth() const;
123 * Get the pixel format of the loaded bitmap.
125 Pixel::Format GetPixelFormat() const;
127 public: // Not intended for application developers
129 explicit DALI_INTERNAL BitmapLoader(Internal::BitmapLoader*);
134 #endif // __DALI_BITMAP_LOADER_H__