[NUI] Add Obsolete attributes for EditorBrowsable apis
[platform/core/csapi/tizenfx.git] / src / Tizen.NUI / src / public / PixelData.cs
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 using System;
19 using System.ComponentModel;
20
21 namespace Tizen.NUI
22 {
23     /// <summary>
24     ///  The PixelData object holds a pixel buffer.<br />
25     ///  The PixelData takes over the ownership of the pixel buffer.<br />
26     ///  The buffer memory must NOT be released outside of this class, instead,
27     ///  the PixelData object will release it automatically when the reference count falls to zero.
28     /// </summary>
29     /// Please DO NOT use! This will be deprecated!
30     /// PixelData class requires externally allocated pixel memory buffer and this buffer loses its ownershop by native DALi.
31     /// And this would make some problem, because dotnet runtime would change the address of memory allocated.
32     /// So this is required to be removed.
33     /// currently no use. will be added later
34     /// <since_tizen> 3 </since_tizen>
35     [Obsolete("Please do not use! This will be deprecated!")]
36     [EditorBrowsable(EditorBrowsableState.Never)]
37     public class PixelData : BaseHandle
38     {
39         private global::System.Runtime.InteropServices.HandleRef swigCPtr;
40
41         internal PixelData(global::System.IntPtr cPtr, bool cMemoryOwn) : base(NDalicPINVOKE.PixelData_SWIGUpcast(cPtr), cMemoryOwn)
42         {
43             swigCPtr = new global::System.Runtime.InteropServices.HandleRef(this, cPtr);
44         }
45
46         internal static global::System.Runtime.InteropServices.HandleRef getCPtr(PixelData obj)
47         {
48             return (obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.swigCPtr;
49         }
50
51         /// <summary>
52         /// Dispose.
53         /// </summary>
54         /// <since_tizen> 3 </since_tizen>
55         protected override void Dispose(DisposeTypes type)
56         {
57             if (disposed)
58             {
59                 return;
60             }
61
62             if (type == DisposeTypes.Explicit)
63             {
64                 //Called by User
65                 //Release your own managed resources here.
66                 //You should release all of your own disposable objects here.
67
68             }
69
70             //Release your own unmanaged resources here.
71             //You should not access any managed member here except static instance.
72             //because the execution order of Finalizes is non-deterministic.
73
74
75             if (swigCPtr.Handle != global::System.IntPtr.Zero)
76             {
77                 if (swigCMemOwn)
78                 {
79                     swigCMemOwn = false;
80                     NDalicPINVOKE.delete_PixelData(swigCPtr);
81                 }
82                 swigCPtr = new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero);
83             }
84
85             base.Dispose(type);
86         }
87
88         /// <summary>
89         /// Creates a PixelData object.
90         /// </summary>
91         /// <param name="buffer">The raw pixel data.</param>
92         /// <param name="bufferSize">The size of the buffer in bytes.</param>
93         /// <param name="width">Buffer width in pixels.</param>
94         /// <param name="height">Buffer height in pixels.</param>
95         /// <param name="pixelFormat">The pixel format.</param>
96         /// <param name="releaseFunction">The function used to release the memory.</param>
97         /// <since_tizen> 3 </since_tizen>
98         public PixelData(byte[] buffer, uint bufferSize, uint width, uint height, PixelFormat pixelFormat, PixelData.ReleaseFunction releaseFunction) : this(NDalicPINVOKE.PixelData_New(buffer, bufferSize, width, height, (int)pixelFormat, (int)releaseFunction), true)
99         {
100             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
101
102         }
103
104         /// <summary>
105         /// Gets the width of the buffer in pixels.
106         /// </summary>
107         /// <returns>The width of the buffer in pixels.</returns>
108         /// <since_tizen> 3 </since_tizen>
109         public uint GetWidth()
110         {
111             uint ret = NDalicPINVOKE.PixelData_GetWidth(swigCPtr);
112             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
113             return ret;
114         }
115
116         /// <summary>
117         /// Gets the height of the buffer in pixels.
118         /// </summary>
119         /// <returns>The height of the buffer in pixels.</returns>
120         /// <since_tizen> 3 </since_tizen>
121         public uint GetHeight()
122         {
123             uint ret = NDalicPINVOKE.PixelData_GetHeight(swigCPtr);
124             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
125             return ret;
126         }
127
128         /// <summary>
129         /// Gets the pixel format.
130         /// </summary>
131         /// <returns>The pixel format.</returns>
132         /// <since_tizen> 3 </since_tizen>
133         public PixelFormat GetPixelFormat()
134         {
135             PixelFormat ret = (PixelFormat)NDalicPINVOKE.PixelData_GetPixelFormat(swigCPtr);
136             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
137             return ret;
138         }
139
140         /// <summary>
141         /// Enumeration for Function to release the pixel buffer.
142         /// </summary>
143         /// <since_tizen> 3 </since_tizen>
144         public enum ReleaseFunction
145         {
146             /// <summary>
147             /// Use free function to release the pixel buffer.
148             /// </summary>
149             FREE,
150
151             /// <summary>
152             /// Use delete[] operator to release the pixel buffer.
153             /// </summary>
154             DELETE_ARRAY
155         }
156
157     }
158
159 }