Release 4.0.0-preview1-00051
[platform/core/csapi/tizenfx.git] / src / Tizen.NUI / src / internal / BufferImage.cs
1 /** Copyright (c) 2017 Samsung Electronics Co., Ltd.
2 *
3 * Licensed under the Apache License, Version 2.0 (the "License");
4 * you may not use this file except in compliance with the License.
5 * You may obtain a copy of the License at
6 *
7 * http://www.apache.org/licenses/LICENSE-2.0
8 *
9 * Unless required by applicable law or agreed to in writing, software
10 * distributed under the License is distributed on an "AS IS" BASIS,
11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 * See the License for the specific language governing permissions and
13 * limitations under the License.
14 *
15 */
16
17 namespace Tizen.NUI
18 {
19
20     internal class BufferImage : Image
21     {
22         private global::System.Runtime.InteropServices.HandleRef swigCPtr;
23
24         internal BufferImage(global::System.IntPtr cPtr, bool cMemoryOwn) : base(NDalicPINVOKE.BufferImage_SWIGUpcast(cPtr), cMemoryOwn)
25         {
26             swigCPtr = new global::System.Runtime.InteropServices.HandleRef(this, cPtr);
27         }
28
29         internal static global::System.Runtime.InteropServices.HandleRef getCPtr(BufferImage obj)
30         {
31             return (obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.swigCPtr;
32         }
33
34         protected override void Dispose(DisposeTypes type)
35         {
36             if (disposed)
37             {
38                 return;
39             }
40
41             if (type == DisposeTypes.Explicit)
42             {
43                 //Called by User
44                 //Release your own managed resources here.
45                 //You should release all of your own disposable objects here.
46
47             }
48
49             //Release your own unmanaged resources here.
50             //You should not access any managed member here except static instance.
51             //because the execution order of Finalizes is non-deterministic.
52
53
54             if (swigCPtr.Handle != global::System.IntPtr.Zero)
55             {
56                 if (swigCMemOwn)
57                 {
58                     swigCMemOwn = false;
59                     NDalicPINVOKE.delete_BufferImage(swigCPtr);
60                 }
61                 swigCPtr = new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero);
62             }
63
64             base.Dispose(type);
65         }
66
67
68
69         public BufferImage(uint width, uint height, PixelFormat pixelformat) : this(NDalicPINVOKE.BufferImage_New__SWIG_0(width, height, (int)pixelformat), true)
70         {
71             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
72
73         }
74         public BufferImage(uint width, uint height) : this(NDalicPINVOKE.BufferImage_New__SWIG_1(width, height), true)
75         {
76             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
77
78         }
79         public BufferImage(byte[] pixelBuffer, uint width, uint height, PixelFormat pixelFormat, uint stride) : this(NDalicPINVOKE.BufferImage_New__SWIG_2(pixelBuffer, width, height, (int)pixelFormat, stride), true)
80         {
81             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
82
83         }
84         public BufferImage(byte[] pixelBuffer, uint width, uint height, PixelFormat pixelFormat) : this(NDalicPINVOKE.BufferImage_New__SWIG_3(pixelBuffer, width, height, (int)pixelFormat), true)
85         {
86             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
87
88         }
89         public BufferImage(byte[] pixelBuffer, uint width, uint height) : this(NDalicPINVOKE.BufferImage_New__SWIG_4(pixelBuffer, width, height), true)
90         {
91             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
92
93         }
94         public new static BufferImage DownCast(BaseHandle handle)
95         {
96             BufferImage ret = Registry.GetManagedBaseHandleFromNativePtr(handle) as BufferImage;
97             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
98             return ret;
99         }
100
101         public BufferImage(BufferImage handle) : this(NDalicPINVOKE.new_BufferImage__SWIG_1(BufferImage.getCPtr(handle)), true)
102         {
103             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
104         }
105
106         public BufferImage Assign(BufferImage rhs)
107         {
108             BufferImage ret = new BufferImage(NDalicPINVOKE.BufferImage_Assign(swigCPtr, BufferImage.getCPtr(rhs)), false);
109             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
110             return ret;
111         }
112
113         public static BufferImage WHITE()
114         {
115             BufferImage ret = new BufferImage(NDalicPINVOKE.BufferImage_WHITE(), true);
116             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
117             return ret;
118         }
119
120         public SWIGTYPE_p_unsigned_char GetBuffer()
121         {
122             global::System.IntPtr cPtr = NDalicPINVOKE.BufferImage_GetBuffer(swigCPtr);
123             SWIGTYPE_p_unsigned_char ret = (cPtr == global::System.IntPtr.Zero) ? null : new SWIGTYPE_p_unsigned_char(cPtr, false);
124             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
125             return ret;
126         }
127
128         public uint GetBufferSize()
129         {
130             uint ret = NDalicPINVOKE.BufferImage_GetBufferSize(swigCPtr);
131             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
132             return ret;
133         }
134
135         public uint GetBufferStride()
136         {
137             uint ret = NDalicPINVOKE.BufferImage_GetBufferStride(swigCPtr);
138             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
139             return ret;
140         }
141
142         public PixelFormat GetPixelFormat()
143         {
144             PixelFormat ret = (PixelFormat)NDalicPINVOKE.BufferImage_GetPixelFormat(swigCPtr);
145             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
146             return ret;
147         }
148
149         public void Update()
150         {
151             NDalicPINVOKE.BufferImage_Update__SWIG_0(swigCPtr);
152             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
153         }
154
155         public void Update(SWIGTYPE_p_Dali__RectT_unsigned_int_t updateArea)
156         {
157             NDalicPINVOKE.BufferImage_Update__SWIG_1(swigCPtr, SWIGTYPE_p_Dali__RectT_unsigned_int_t.getCPtr(updateArea));
158             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
159         }
160
161         public bool IsDataExternal()
162         {
163             bool ret = NDalicPINVOKE.BufferImage_IsDataExternal(swigCPtr);
164             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
165             return ret;
166         }
167
168     }
169
170 }