1 #ifndef __DALI_INTERNAL_BITMAP_H__
2 #define __DALI_INTERNAL_BITMAP_H__
5 // Copyright (c) 2014 Samsung Electronics Co., Ltd.
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
11 // http://floralicense.org/license/
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.
23 #include <dali/integration-api/bitmap.h>
30 class BitmapPackedPixel;
31 typedef IntrusivePtr<BitmapPackedPixel> BitmapPackedPixelPtr;
34 * BitmapPackedPixel class.
35 * A container for image data that is packed into individual struct-like
36 * pixels in an addressable 2D array, with each pixel occupying a whole
38 * This is a vanilla Bitmap class, typically used to hold data decompressed
39 * from PNG and JPEG file formats for example.
41 * \sa{Bitmap BitmapCompressed BitmapExternal}
43 class DALI_IMPORT_API BitmapPackedPixel : public Dali::Integration::Bitmap, Dali::Integration::Bitmap::PackedPixelsProfile
48 * @param[in] discardable Flag to tell the bitmap if it can delete the buffer with the pixel data.
50 BitmapPackedPixel( bool discardable = false, Dali::Integration::PixelBuffer* pixBuf = 0 );
53 virtual const Bitmap::PackedPixelsProfile* GetPackedPixelsProfile() const { return this; }
54 virtual Bitmap::PackedPixelsProfile* GetPackedPixelsProfile() { return this; }
57 * (Re-)Allocate pixel buffer for the Bitmap. Any previously allocated pixel buffer is deleted.
58 * Dali has ownership of the buffer, but its contents can be modified.
59 * Bitmap stores given size information about the image.
60 * @pre bufferWidth, bufferHeight have to be power of two
61 * @param[in] pixelFormat pixel format
62 * @param[in] width Image width in pixels
63 * @param[in] height Image height in pixels
64 * @param[in] bufferWidth Buffer width (stride) in pixels
65 * @param[in] bufferHeight Buffer height in pixels
66 * @return pixel buffer pointer
68 virtual Dali::Integration::PixelBuffer* ReserveBuffer(Pixel::Format pixelFormat,
71 unsigned int bufferWidth = 0,
72 unsigned int bufferHeight = 0);
75 * Assign a pixel buffer. Any previously allocated pixel buffer is deleted.
76 * Dali has ownership of the buffer, but its contents can be modified.
77 * Bitmap stores given size information about the image.
78 * @pre bufferWidth, bufferHeight have to be power of two
79 * @param[in] pixelFormat pixel format
80 * @param[in] buffer the pixel buffer
81 * @param[in] bufferSize size of the pixel buffer
82 * @param[in] width Image width in pixels
83 * @param[in] height Image height in pixels
84 * @param[in] bufferWidth Buffer width (stride) in pixels
85 * @param[in] bufferHeight Buffer height in pixels
87 virtual void AssignBuffer(Pixel::Format pixelFormat,
88 Dali::Integration::PixelBuffer* buffer,
89 std::size_t bufferSize,
92 unsigned int bufferWidth = 0,
93 unsigned int bufferHeight = 0);
96 * Get the width of the buffer (stride)
97 * @return The width of the buffer in pixels
99 virtual unsigned GetBufferWidth() const
105 * Get the height of the buffer
106 * @return The height of the buffer in pixels
108 virtual unsigned GetBufferHeight() const
110 return mBufferHeight;
114 * Get the pixel buffer size in bytes
115 * @return The buffer size in bytes.
117 // unsigned int GetBufferSize() const
118 virtual size_t GetBufferSize() const
120 return mBufferWidth*mBytesPerPixel*mBufferHeight;
124 * Get the pixel buffer stride.
125 * @return The buffer stride (in bytes).
127 virtual unsigned int GetBufferStride() const;
129 // return mBufferWidth*mBytesPerPixel;
133 * Get the pixel format
134 * @return The pixel format
136 Pixel::Format GetPixelFormat() const
142 * Check the bitmap data and test whether it has any transparent pixels.
143 * This property can then be tested for with IsFullyOpaque().
145 virtual void TestForTransparency();
150 * A reference counted object may only be deleted by calling Unreference()
152 virtual ~BitmapPackedPixel();
156 unsigned int mBufferWidth; ///< Buffer width (stride) in pixels
157 unsigned int mBufferHeight; ///< Buffer height in pixels
158 unsigned int mBytesPerPixel; ///< Bytes per pixel
163 * Initializes internal class members
164 * @param[in] pixelFormat pixel format
165 * @param[in] width Image width in pixels
166 * @param[in] height Image height in pixels
167 * @param[in] bufferWidth Buffer width (stride) in pixels
168 * @param[in] bufferHeight Buffer height in pixels
170 void Initialize(Pixel::Format pixelFormat,
173 unsigned int bufferWidth,
174 unsigned int bufferHeight);
177 BitmapPackedPixel(const BitmapPackedPixel& other); ///< defined private to prevent use
178 BitmapPackedPixel& operator = (const BitmapPackedPixel& other); ///< defined private to prevent use
180 // Changes scope, should be at end of class
181 DALI_LOG_OBJECT_STRING_DECLARATION;
184 } // namespace Integration
188 #endif // __DALI_INTERNAL_BITMAP_H__