df54151977661a094c6209ef80d03b33be025787
[platform/core/uifw/dali-adaptor.git] / dali / devel-api / adaptor-framework / pixel-buffer.cpp
1 /*
2  * Copyright (c) 2017 Samsung Electronics Co., Ltd.
3  *
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
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
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.
15  *
16  */
17
18 // CLASS HEADER
19 #include <dali/devel-api/adaptor-framework/pixel-buffer.h>
20
21 // EXTERNAL INLCUDES
22 #include <stdlib.h>
23
24 // INTERNAL INCLUDES
25 #include <dali/internal/imaging/common/pixel-buffer-impl.h>
26
27 namespace Dali
28 {
29 namespace Devel
30 {
31
32 PixelBuffer PixelBuffer::New( unsigned int width,
33                               unsigned int height,
34                               Dali::Pixel::Format pixelFormat )
35 {
36   Internal::Adaptor::PixelBufferPtr internal =
37     Internal::Adaptor::PixelBuffer::New( width, height, pixelFormat );
38   return Devel::PixelBuffer( internal.Get() );
39 }
40
41 Dali::PixelData PixelBuffer::Convert( PixelBuffer& pixelBuffer )
42 {
43   Dali::PixelData pixelData =
44     Internal::Adaptor::PixelBuffer::Convert( GetImplementation(pixelBuffer) );
45   pixelBuffer.Reset();
46   return pixelData;
47 }
48
49 Dali::PixelData PixelBuffer::CreatePixelData() const
50 {
51   return GetImplementation(*this).CreatePixelData();
52 }
53
54
55 PixelBuffer::PixelBuffer()
56 {
57 }
58
59 PixelBuffer::~PixelBuffer()
60 {
61 }
62
63 PixelBuffer::PixelBuffer( Internal::Adaptor::PixelBuffer* internal )
64 : BaseHandle( internal )
65 {
66 }
67
68 PixelBuffer::PixelBuffer(const PixelBuffer& handle)
69 : BaseHandle( handle )
70 {
71 }
72
73 PixelBuffer& PixelBuffer::operator=(const PixelBuffer& rhs)
74 {
75   BaseHandle::operator=(rhs);
76   return *this;
77 }
78
79 unsigned int PixelBuffer::GetWidth() const
80 {
81   return GetImplementation(*this).GetWidth();
82 }
83
84 unsigned int PixelBuffer::GetHeight() const
85 {
86   return GetImplementation(*this).GetHeight();
87 }
88
89 Pixel::Format PixelBuffer::GetPixelFormat() const
90 {
91   return GetImplementation(*this).GetPixelFormat();
92 }
93
94 unsigned char* PixelBuffer::GetBuffer()
95 {
96   return GetImplementation(*this).GetBuffer();
97 }
98
99 void PixelBuffer::ApplyMask( PixelBuffer mask, float contentScale, bool cropToMask )
100 {
101   GetImplementation(*this).ApplyMask( GetImplementation( mask ), contentScale, cropToMask );
102 }
103
104 void PixelBuffer::ApplyGaussianBlur( const float blurRadius )
105 {
106   GetImplementation(*this).ApplyGaussianBlur( blurRadius );
107 }
108
109 void PixelBuffer::Crop( uint16_t x, uint16_t y, uint16_t width, uint16_t height )
110 {
111   GetImplementation(*this).Crop( x, y, ImageDimensions( width, height ) );
112 }
113
114 void PixelBuffer::Resize( uint16_t width, uint16_t height )
115 {
116   GetImplementation(*this).Resize( ImageDimensions( width, height ) );
117 }
118
119 void PixelBuffer::MultiplyColorByAlpha()
120 {
121   GetImplementation(*this).MultiplyColorByAlpha();
122 }
123
124 bool PixelBuffer::GetMetadata( Property::Map& metadata ) const
125 {
126   return GetImplementation(*this).GetMetadata(metadata);
127 }
128
129 } // namespace Devel
130
131 } // namespace Dali