1 #ifndef DALI_PIXEL_DATA_H
2 #define DALI_PIXEL_DATA_H
5 * Copyright (c) 2020 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 <cstdint> // uint8_t, uint32_t
25 #include <dali/public-api/images/pixel.h>
26 #include <dali/public-api/object/base-handle.h>
31 * @addtogroup dali_core_images
41 * @brief The PixelData object holds a pixel buffer .
42 * The PixelData takes over the ownership of the pixel buffer.
43 * 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.
47 class DALI_CORE_API PixelData : public BaseHandle
52 * @brief Enumeration for Function to release the pixel buffer.
57 FREE, ///< Use free function to release the pixel buffer @SINCE_1_1.43
58 DELETE_ARRAY, ///< Use delete[] operator to release the pixel buffer @SINCE_1_1.43
62 * @brief Creates a PixelData object.
65 * @param[in] buffer The raw pixel data
66 * @param[in] bufferSize The size of the buffer in bytes
67 * @param[in] width Buffer width in pixels
68 * @param[in] height Buffer height in pixels
69 * @param[in] pixelFormat The pixel format
70 * @param[in] releaseFunction The function used to release the memory
71 * @return A handle to the PixelData
73 static PixelData New( uint8_t* buffer,
77 Pixel::Format pixelFormat,
78 ReleaseFunction releaseFunction);
81 * @brief Creates an empty handle.
82 * Use PixelData::New() to create an initialized object.
96 * @brief This copy constructor is required for (smart) pointer semantics.
99 * @param[in] handle A reference to the copied handle
101 PixelData(const PixelData& handle);
104 * @brief This assignment operator is required for (smart) pointer semantics.
107 * @param[in] rhs A reference to the copied handle
108 * @return A reference to this object
110 PixelData& operator=(const PixelData& rhs);
113 * @brief Move constructor.
116 * @param[in] rhs A reference to the moved handle
118 PixelData( PixelData&& rhs );
121 * @brief Move assignment operator.
124 * @param[in] rhs A reference to the moved handle
125 * @return A reference to this handle
127 PixelData& operator=( PixelData&& rhs );
130 * @brief Gets the width of the buffer in pixels.
133 * @return The width of the buffer in pixels
135 uint32_t GetWidth() const;
138 * @brief Gets the height of the buffer in pixels.
141 * @return The height of the buffer in pixels
143 uint32_t GetHeight() const;
146 * @brief Gets the pixel format.
149 * @return The pixel format
151 Pixel::Format GetPixelFormat() const;
156 * @brief The constructor.
157 * @note Not intended for application developers.
159 * @param[in] pointer A pointer to a newly allocated PixelData
161 explicit DALI_INTERNAL PixelData( Internal::PixelData* pointer );
169 #endif // DALI_PIXEL_DATA_H