2 * Copyright (c) 2024 Samsung Electronics Co., Ltd.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
19 #include <dali/devel-api/adaptor-framework/pixel-buffer.h>
25 #include <dali/internal/imaging/common/pixel-buffer-impl.h>
31 PixelBuffer PixelBuffer::New(uint32_t width,
33 Dali::Pixel::Format pixelFormat)
35 Internal::Adaptor::PixelBufferPtr internal =
36 Internal::Adaptor::PixelBuffer::New(width, height, pixelFormat);
37 return Devel::PixelBuffer(internal.Get());
40 Dali::PixelData PixelBuffer::Convert(PixelBuffer& pixelBuffer)
42 return Convert(pixelBuffer, false);
45 Dali::PixelData PixelBuffer::Convert(PixelBuffer& pixelBuffer, bool releaseAfterUpload)
47 Dali::PixelData pixelData = Internal::Adaptor::PixelBuffer::Convert(GetImplementation(pixelBuffer), releaseAfterUpload);
52 Dali::PixelData PixelBuffer::CreatePixelData() const
54 return GetImplementation(*this).CreatePixelData();
57 PixelBuffer::PixelBuffer()
61 PixelBuffer::~PixelBuffer()
65 PixelBuffer::PixelBuffer(Internal::Adaptor::PixelBuffer* internal)
66 : BaseHandle(internal)
70 PixelBuffer::PixelBuffer(const PixelBuffer& handle) = default;
72 PixelBuffer& PixelBuffer::operator=(const PixelBuffer& rhs) = default;
74 PixelBuffer::PixelBuffer(PixelBuffer&& handle) = default;
76 PixelBuffer& PixelBuffer::operator=(PixelBuffer&& rhs) = default;
78 uint32_t PixelBuffer::GetWidth() const
80 return GetImplementation(*this).GetWidth();
83 uint32_t PixelBuffer::GetHeight() const
85 return GetImplementation(*this).GetHeight();
88 uint32_t PixelBuffer::GetStride() const
90 return GetImplementation(*this).GetStride();
93 Pixel::Format PixelBuffer::GetPixelFormat() const
95 return GetImplementation(*this).GetPixelFormat();
98 uint8_t* PixelBuffer::GetBuffer()
100 return GetImplementation(*this).GetBuffer();
103 const uint8_t* PixelBuffer::GetBuffer() const
105 return GetImplementation(*this).GetConstBuffer();
108 void PixelBuffer::ApplyMask(PixelBuffer mask, float contentScale, bool cropToMask)
110 GetImplementation(*this).ApplyMask(GetImplementation(mask), contentScale, cropToMask);
113 void PixelBuffer::ApplyGaussianBlur(const float blurRadius)
115 GetImplementation(*this).ApplyGaussianBlur(blurRadius);
118 void PixelBuffer::Crop(uint16_t x, uint16_t y, uint16_t width, uint16_t height)
120 GetImplementation(*this).Crop(x, y, ImageDimensions(width, height));
123 void PixelBuffer::Resize(uint16_t width, uint16_t height)
125 GetImplementation(*this).Resize(ImageDimensions(width, height));
128 void PixelBuffer::MultiplyColorByAlpha()
130 GetImplementation(*this).MultiplyColorByAlpha();
133 bool PixelBuffer::GetMetadata(Property::Map& metadata) const
135 return GetImplementation(*this).GetMetadata(metadata);
138 bool PixelBuffer::Rotate(Degree angle)
140 return GetImplementation(*this).Rotate(angle);
143 bool PixelBuffer::IsAlphaPreMultiplied() const
145 return GetImplementation(*this).IsAlphaPreMultiplied();
148 uint32_t PixelBuffer::GetBrightness() const
150 return GetImplementation(*this).GetBrightness();