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/devel-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] width Buffer width in pixels
43 * @param [in] height Buffer height in pixels
44 * @param [in] pixelFormat The pixel format
45 * @param [in] releaseFunction The function used to release the memory.
47 static PixelDataPtr New( unsigned char* buffer,
50 Pixel::Format pixelFormat,
51 Dali::PixelData::ReleaseFunction releaseFunction);
56 * @param [in] buffer The raw pixel data.
57 * @param [in] width Buffer width in pixels
58 * @param [in] height Buffer height in pixels
59 * @param [in] pixelFormat The pixel format
60 * @param [in] releaseFunction The function used to release the memory.
62 PixelData( unsigned char* buffer,
65 Pixel::Format pixelFormat,
66 Dali::PixelData::ReleaseFunction releaseFunction );
73 * Release the pixel buffer if exists.
80 * Get the width of the buffer in pixels.
81 * @return The width of the buffer in pixels
83 unsigned int GetWidth() const;
86 * Get the height of the buffer in pixels
87 * @return The height of the buffer in pixels
89 unsigned int GetHeight() const;
92 * Get the pixel format
93 * @return The pixel format
95 Pixel::Format GetPixelFormat() const;
98 * Get the pixel buffer if it's present.
99 * @return The buffer if exists, or NULL if there is no pixel buffer.
101 unsigned char* GetBuffer() const;
106 * Undefined copy constructor.
108 PixelData(const PixelData& other);
111 * Undefined assignment operator.
113 PixelData& operator = (const PixelData& other);
117 unsigned char* mBuffer; ///< The raw pixel data.
118 unsigned int mWidth; ///< Buffer width in pixels.
119 unsigned int mHeight; ///< Buffer height in pixels.
120 Pixel::Format mPixelFormat; ///< Pixel format
121 Dali::PixelData::ReleaseFunction mReleaseFunction; ///< Function for releasing memory
124 } // namespace Internal
127 * Helper methods for public API
129 inline Internal::PixelData& GetImplementation( Dali::PixelData& handle )
131 DALI_ASSERT_ALWAYS( handle && "handle is empty" );
133 BaseObject& object = handle.GetBaseObject();
135 return static_cast<Internal::PixelData&>( object );
138 inline const Internal::PixelData& GetImplementation( const Dali::PixelData& handle )
140 DALI_ASSERT_ALWAYS( handle && "handle is empty" );
142 const BaseObject& object = handle.GetBaseObject();
144 return static_cast<const Internal::PixelData&>( object );
149 #endif // __DALI_INTERNAL_PIXEL_DATA_H__