Refactored image loaders, added public API
[platform/core/uifw/dali-adaptor.git] / adaptors / public-api / bitmap-loader.h
1 #ifndef __DALI_BITMAP_LOADER_H__
2 #define __DALI_BITMAP_LOADER_H__
3
4 /*
5  * Copyright (c) 2014 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/pixel.h>
24 #include <dali/public-api/object/base-handle.h>
25
26 namespace Dali
27 {
28 namespace Internal
29 {
30 class BitmapLoader;
31 }
32
33 class BitmapLoader : public BaseHandle
34 {
35 public:
36   /**
37    * @brief Create an initialized bitmap loader. This will automatically load the image.
38    *
39    * @param[in] filename  Filename of the bitmap image to load.
40    */
41   static BitmapLoader New(const std::string& filename);
42
43   /**
44    * @brief Create an empty handle.
45    *
46    * Use BitmapLoader::New() to create an initialized object.
47    */
48   BitmapLoader();
49
50   /**
51    * Destructor
52    */
53   ~BitmapLoader();
54
55   /**
56    * @brief This copy constructor is required for (smart) pointer semantics.
57    *
58    * @param [in] handle A reference to the copied handle
59    */
60   BitmapLoader(const BitmapLoader& handle);
61
62   /**
63    * @brief This assignment operator is required for (smart) pointer semantics.
64    *
65    * @param [in] rhs  A reference to the copied handle
66    * @return A reference to this
67    */
68   BitmapLoader& operator=(const BitmapLoader& rhs);
69
70   /**
71    * @brief This method is defined to allow assignment of the NULL value,
72    * and will throw an exception if passed any other value.
73    *
74    * Assigning to NULL is an alias for Reset().
75    * @param [in] rhs  A NULL pointer
76    * @return A reference to this handle
77    */
78   BitmapLoader& operator=(BaseHandle::NullType* rhs);
79
80 public:
81
82   /**
83    * Get the raw pixel data.
84    * @return The pixel data. Use the GetHeight(), GetWidth(), GetStride() and GetPixelFormat() methods
85    * to decode the data.
86    */
87   unsigned char* GetPixelData() const;
88
89   /**
90    * Get the buffer height in pixels
91    * @return the height of the buffer in pixels
92    */
93   unsigned int GetImageHeight() const;
94
95   /**
96    * Get the buffer width in pixels
97    * @return the width of the buffer in pixels
98    */
99   unsigned int GetImageWidth() const;
100
101   /**
102    * Get the number of bytes in each row of pixels
103    * @return The buffer stride in bytes.
104    */
105   unsigned int GetBufferStride() const;
106
107   /**
108    * Get the pixel format of the loaded bitmap.
109    */
110   Pixel::Format GetPixelFormat() const;
111
112 public: // Not intended for application developers
113
114   explicit DALI_INTERNAL BitmapLoader(Internal::BitmapLoader*);
115 };
116
117 } // Dali
118
119 #endif // __DALI_BITMAP_LOADER_H__