1 #ifndef __DALI_INTERNAL_BITMAP_H__
2 #define __DALI_INTERNAL_BITMAP_H__
5 * Copyright (c) 2014 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.
24 #include <dali/integration-api/bitmap.h>
31 class BitmapPackedPixel;
32 typedef IntrusivePtr<BitmapPackedPixel> BitmapPackedPixelPtr;
35 * BitmapPackedPixel class.
36 * A container for image data that is packed into individual struct-like
37 * pixels in an addressable 2D array, with each pixel occupying a whole
39 * This is a vanilla Bitmap class, typically used to hold data decompressed
40 * from PNG and JPEG file formats for example.
42 * \sa{Bitmap BitmapCompressed BitmapExternal}
44 class BitmapPackedPixel : public Dali::Integration::Bitmap, Dali::Integration::Bitmap::PackedPixelsProfile
49 * @param[in] discardable Flag to tell the bitmap if it can delete the buffer with the pixel data.
51 BitmapPackedPixel( ResourcePolicy::Discardable discardable = ResourcePolicy::RETAIN, Dali::Integration::PixelBuffer* pixBuf = 0 );
54 virtual const Bitmap::PackedPixelsProfile* GetPackedPixelsProfile() const { return this; }
55 virtual Bitmap::PackedPixelsProfile* GetPackedPixelsProfile() { return this; }
58 * (Re-)Allocate pixel buffer for the Bitmap. Any previously allocated pixel buffer is deleted.
59 * Dali has ownership of the buffer, but its contents can be modified.
60 * Bitmap stores given size information about the image.
61 * @pre bufferWidth, bufferHeight have to be power of two
62 * @param[in] pixelFormat pixel format
63 * @param[in] width Image width in pixels
64 * @param[in] height Image height in pixels
65 * @param[in] bufferWidth Buffer width (stride) in pixels
66 * @param[in] bufferHeight Buffer height in pixels
67 * @return pixel buffer pointer
69 virtual Dali::Integration::PixelBuffer* ReserveBuffer(Pixel::Format pixelFormat,
72 unsigned int bufferWidth = 0,
73 unsigned int bufferHeight = 0);
76 * Assign a pixel buffer. Any previously allocated pixel buffer is deleted.
77 * Dali has ownership of the buffer, but its contents can be modified.
78 * Bitmap stores given size information about the image.
79 * @pre bufferWidth, bufferHeight have to be power of two
80 * @param[in] pixelFormat pixel format
81 * @param[in] buffer the pixel buffer
82 * @param[in] bufferSize size of the pixel buffer
83 * @param[in] width Image width in pixels
84 * @param[in] height Image height in pixels
85 * @param[in] bufferWidth Buffer width (stride) in pixels
86 * @param[in] bufferHeight Buffer height in pixels
88 virtual void AssignBuffer(Pixel::Format pixelFormat,
89 Dali::Integration::PixelBuffer* buffer,
90 std::size_t bufferSize,
93 unsigned int bufferWidth = 0,
94 unsigned int bufferHeight = 0);
97 * Get the width of the buffer (stride)
98 * @return The width of the buffer in pixels
100 virtual unsigned GetBufferWidth() const
106 * Get the height of the buffer
107 * @return The height of the buffer in pixels
109 virtual unsigned GetBufferHeight() const
111 return mBufferHeight;
115 * Get the pixel buffer size in bytes
116 * @return The buffer size in bytes.
118 // unsigned int GetBufferSize() const
119 virtual size_t GetBufferSize() const
121 return mBufferWidth*mBytesPerPixel*mBufferHeight;
125 * Get the pixel buffer stride.
126 * @return The buffer stride (in bytes).
128 virtual unsigned int GetBufferStride() const;
130 // return mBufferWidth*mBytesPerPixel;
134 * Get the pixel format
135 * @return The pixel format
137 Pixel::Format GetPixelFormat() const
143 * Check the bitmap data and test whether it has any transparent pixels.
144 * This property can then be tested for with IsFullyOpaque().
146 virtual void TestForTransparency();
151 * A reference counted object may only be deleted by calling Unreference()
153 virtual ~BitmapPackedPixel();
157 unsigned int mBufferWidth; ///< Buffer width (stride) in pixels
158 unsigned int mBufferHeight; ///< Buffer height in pixels
159 unsigned int mBytesPerPixel; ///< Bytes per pixel
164 * Initializes internal class members
165 * @param[in] pixelFormat pixel format
166 * @param[in] width Image width in pixels
167 * @param[in] height Image height in pixels
168 * @param[in] bufferWidth Buffer width (stride) in pixels
169 * @param[in] bufferHeight Buffer height in pixels
171 void Initialize(Pixel::Format pixelFormat,
174 unsigned int bufferWidth,
175 unsigned int bufferHeight);
178 BitmapPackedPixel(const BitmapPackedPixel& other); ///< defined private to prevent use
179 BitmapPackedPixel& operator = (const BitmapPackedPixel& other); ///< defined private to prevent use
181 // Changes scope, should be at end of class
182 DALI_LOG_OBJECT_STRING_DECLARATION;
185 } // namespace Integration
189 #endif // __DALI_INTERNAL_BITMAP_H__