1 #ifndef DALI_INTERNAL_PIXEL_DATA_H
2 #define DALI_INTERNAL_PIXEL_DATA_H
5 * Copyright (c) 2016 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.
22 #include <dali/public-api/images/pixel-data.h>
23 #include <dali/public-api/object/base-object.h>
32 typedef IntrusivePtr<PixelData> PixelDataPtr;
34 class PixelData : public BaseObject
39 * @brief Create a PixelData object.
41 * @param [in] buffer The raw pixel data.
42 * @param [in] bufferSize The size of the buffer in bytes
43 * @param [in] width Buffer width in pixels
44 * @param [in] height Buffer height in pixels
45 * @param [in] pixelFormat The pixel format
46 * @param [in] releaseFunction The function used to release the memory.
48 static PixelDataPtr New( unsigned char* buffer,
49 unsigned int bufferSize,
52 Pixel::Format pixelFormat,
53 Dali::PixelData::ReleaseFunction releaseFunction);
58 * @param [in] buffer The raw pixel data.
59 * @param [in] bufferSize The size of the buffer in bytes
60 * @param [in] width Buffer width in pixels
61 * @param [in] height Buffer height in pixels
62 * @param [in] pixelFormat The pixel format
63 * @param [in] releaseFunction The function used to release the memory.
65 PixelData( unsigned char* buffer,
66 unsigned int bufferSize,
69 Pixel::Format pixelFormat,
70 Dali::PixelData::ReleaseFunction releaseFunction );
77 * Release the pixel buffer if exists.
84 * Get the width of the buffer in pixels.
85 * @return The width of the buffer in pixels
87 unsigned int GetWidth() const;
90 * Get the height of the buffer in pixels
91 * @return The height of the buffer in pixels
93 unsigned int GetHeight() const;
96 * Get the pixel format
97 * @return The pixel format
99 Pixel::Format GetPixelFormat() const;
102 * Get the pixel buffer if it's present.
103 * @return The buffer if exists, or NULL if there is no pixel buffer.
105 unsigned char* GetBuffer() const;
108 * Get the size of the buffer in bytes
109 * @return The size of the buffer
111 unsigned int GetBufferSize() const;
116 * Undefined copy constructor.
118 PixelData(const PixelData& other);
121 * Undefined assignment operator.
123 PixelData& operator = (const PixelData& other);
127 unsigned char* mBuffer; ///< The raw pixel data
128 unsigned int mBufferSize; ///< Buffer sized in bytes
129 unsigned int mWidth; ///< Buffer width in pixels
130 unsigned int mHeight; ///< Buffer height in pixels
131 Pixel::Format mPixelFormat; ///< Pixel format
132 Dali::PixelData::ReleaseFunction mReleaseFunction; ///< Function for releasing memory
135 } // namespace Internal
138 * Helper methods for public API
140 inline Internal::PixelData& GetImplementation( Dali::PixelData& handle )
142 DALI_ASSERT_ALWAYS( handle && "handle is empty" );
144 BaseObject& object = handle.GetBaseObject();
146 return static_cast<Internal::PixelData&>( object );
149 inline const Internal::PixelData& GetImplementation( const Dali::PixelData& handle )
151 DALI_ASSERT_ALWAYS( handle && "handle is empty" );
153 const BaseObject& object = handle.GetBaseObject();
155 return static_cast<const Internal::PixelData&>( object );
160 #endif // __DALI_INTERNAL_PIXEL_DATA_H__