1 #ifndef __DALI_PIXEL_DATA_H__
2 #define __DALI_PIXEL_DATA_H__
5 * Copyright (c) 2015 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.
21 #include <dali/public-api/images/pixel.h>
22 #include <dali/public-api/object/ref-object.h>
28 typedef IntrusivePtr<PixelData> PixelDataPtr;
31 * @brief Reference counted pixel data .
33 * The PixelData takes over the ownership of the pixel buffer.
34 * The buffer memory must NOT be released outside of this class, instead, the PixelData object will release it automatically when the reference count falls to zero.
36 class DALI_IMPORT_API PixelData : public RefObject
42 FREE, ///< Use free function to release the pixel buffer
43 DELETE_ARRAY, ///< Use delete[] operator to release the pixel buffer
47 * @brief Create a PixelData object.
49 * @param [in] buffer The raw pixel data.
50 * @param [in] width Buffer width in pixels
51 * @param [in] height Buffer height in pixels
52 * @param [in] pixelFormat The pixel format
53 * @param [in] releaseFunction The function used to release the memory.
55 static PixelDataPtr New( unsigned char* buffer,
58 Pixel::Format pixelFormat,
59 ReleaseFunction releaseFunction);
62 * Get the width of the buffer in pixels.
63 * @return The width of the buffer in pixels
65 unsigned int GetWidth() const;
68 * Get the height of the buffer in pixels
69 * @return The height of the buffer in pixels
71 unsigned int GetHeight() const;
74 * Get the pixel format
75 * @return The pixel format
77 Pixel::Format GetPixelFormat() const;
80 * Get the pixel buffer if it's present.
81 * @return The buffer if exits, or NULL if there is no pixel buffer.
83 unsigned char* GetBuffer() const;
90 * @param [in] buffer The raw pixel data.
91 * @param [in] width Buffer width in pixels
92 * @param [in] height Buffer height in pixels
93 * @param [in] pixelFormat The pixel format
94 * @param [in] releaseFunction The function used to release the memory.
96 PixelData( unsigned char* buffer,
99 Pixel::Format pixelFormat,
100 ReleaseFunction releaseFunction );
105 * Release the pixel buffer if exists.
113 * Undefined copy constructor.
115 PixelData(const PixelData& other);
118 * Undefined assignment operator.
120 PixelData& operator = (const PixelData& other);
124 unsigned char* mBuffer; ///< The raw pixel data.
125 unsigned int mWidth; ///< Buffer width in pixels.
126 unsigned int mHeight; ///< Buffer height in pixels.
127 Pixel::Format mPixelFormat; ///< Pixel format
128 ReleaseFunction mReleaseFunction; ///< Function for releasing memory
134 #endif // __DALI_PIXEL_DATA_H__