Fix regression with BitmapImage (width/height variety)
[platform/core/uifw/dali-core.git] / dali / internal / event / images / bitmap-external.h
1 #ifndef __DALI_INTERNAL_BITMAP_EXTERNAL_H__
2 #define __DALI_INTERNAL_BITMAP_EXTERNAL_H__
3
4 //
5 // Copyright (c) 2014 Samsung Electronics Co., Ltd.
6 //
7 // Licensed under the Flora License, Version 1.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://floralicense.org/license/
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
22 // INTERNAL INCLUDES
23 #include <dali/internal/event/images/bitmap-packed-pixel.h>
24
25 namespace Dali
26 {
27
28 namespace Internal
29 {
30
31 /**
32  * Bitmap class.
33  * A container for external image data
34  */
35 class BitmapExternal : public BitmapPackedPixel
36 {
37 public:
38   /**
39    * Constructor
40    */
41
42   /**
43    * Creates new BitmapExternal instance with pixel buffer pointer and details.
44    * Application has ownership of the buffer, its contents can be modified.
45    * Bitmap stores given size information about the image.
46    * @pre bufferWidth, bufferHeight have to be power of two
47    * @param[in] pixBuf        pointer to external pixel buffer
48    * @param[in] width         Image width in pixels
49    * @param[in] height        Image height in pixels
50    * @param[in] pixelformat   pixel format
51    * @param[in] bufferWidth   Buffer width in pixels
52    * @param[in] bufferHeight  Buffer height in pixels
53    */
54   BitmapExternal(Dali::Integration::PixelBuffer* pixBuf,
55                  unsigned int width,
56                  unsigned int height,
57                  Pixel::Format pixelformat,
58                  unsigned int bufferWidth  = 0,
59                  unsigned int bufferHeight = 0);
60
61   /**
62    * This does nothing, data is owned by external application.
63    */
64   virtual Dali::Integration::PixelBuffer* ReserveBuffer(Pixel::Format pixelFormat,
65                                      unsigned int width,
66                                      unsigned int height,
67                                      unsigned int bufferWidth = 0,
68                                      unsigned int bufferHeight = 0)
69   {
70     return NULL;
71   }
72
73   /**
74    * Get the pixel buffer
75    * @return The buffer. You can modify its contents.
76    */
77   virtual Dali::Integration::PixelBuffer* GetBuffer()
78   {
79     return mExternalData;
80   }
81
82 protected:
83   /**
84    * A reference counted object may only be deleted by calling Unreference()
85    */
86   virtual ~BitmapExternal();
87
88 private:
89
90   Dali::Integration::PixelBuffer* mExternalData; ///< Externally owned pixel data
91
92 private:
93   BitmapExternal();  ///< defined private to prevent use
94   BitmapExternal(const BitmapExternal& other);  ///< defined private to prevent use
95   BitmapExternal& operator = (const BitmapExternal& other); ///< defined private to prevent use
96
97   // Changes scope, should be at end of class
98   DALI_LOG_OBJECT_STRING_DECLARATION;
99 };
100
101 } // namespace Internal
102
103 } // namespace Dali
104
105 #endif // __DALI_INTERNAL_BITMAP_EXTERNAL_H__