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