Revert "[3.0] Added EventThreadCallback class & BitmapLoader::Load() API"
[platform/core/uifw/dali-adaptor.git] / adaptors / common / bitmap-loader-impl.h
1 #ifndef __DALI_BITMAP_LOADER_IMPL_H__
2 #define __DALI_BITMAP_LOADER_IMPL_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/images/pixel.h>
23 #include <dali/public-api/object/base-object.h>
24 #include <dali/public-api/common/intrusive-ptr.h>
25 #include <dali/integration-api/bitmap.h>
26
27 // INTERNAL INCLUDES
28 #include <bitmap-loader.h>
29
30 namespace Dali
31 {
32 namespace Internal
33 {
34
35 class BitmapLoader : public BaseObject
36 {
37 public:
38   static IntrusivePtr<BitmapLoader> New(const std::string& filename);
39
40   /**
41    * Create the bitmap loader object.
42    */
43   BitmapLoader();
44
45 protected:
46   /**
47    * Destructor
48    */
49   ~BitmapLoader();
50
51   /**
52    * Second stage initialization - this will load the image synchronously.
53    * @param[in] filename  Filename of the bitmap image to load.
54    */
55   void Initialize(const std::string& filename);
56
57 public:
58
59   /**
60    * Get the raw pixel data.
61    * @return The pixel data. Use the GetHeight(), GetWidth(), GetStride() and GetPixelFormat() methods
62    * to decode the data.
63    */
64   unsigned char* GetPixelData() const;
65
66   /**
67    * Get the buffer height in pixels
68    * @return the height of the buffer in pixels
69    */
70   unsigned int GetImageHeight() const;
71
72   /**
73    * Get the buffer width in pixels
74    * @return the width of the buffer in pixels
75    */
76   unsigned int GetImageWidth() const;
77
78   /**
79    * Get the number of bytes in each row of pixels
80    * @return The buffer stride in bytes.
81    */
82   unsigned int GetBufferStride() const;
83
84   /**
85    * Get the pixel format of the loaded bitmap.
86    */
87   Pixel::Format GetPixelFormat() const;
88
89 private:
90   Integration::BitmapPtr mBitmap;
91 };
92
93 } // Internal
94
95
96 inline Internal::BitmapLoader& GetImplementation(Dali::BitmapLoader& handle)
97 {
98   DALI_ASSERT_ALWAYS( handle && "handle is empty" );
99
100   BaseObject& object = handle.GetBaseObject();
101
102   return static_cast<Internal::BitmapLoader&>(object);
103 }
104
105 inline const Internal::BitmapLoader& GetImplementation(const Dali::BitmapLoader& handle)
106 {
107   DALI_ASSERT_ALWAYS( handle && "handle is empty" );
108
109   const BaseObject& object = handle.GetBaseObject();
110
111   return static_cast<const Internal::BitmapLoader&>(object);
112 }
113
114 } // Dali
115
116 #endif // __DALI_BITMAP_LOADER_IMPL_H__