[NUI] Remove ReleaseFunction enum at PixelData with legacy
[platform/core/csapi/tizenfx.git] / src / Tizen.NUI / src / public / Images / PixelData.cs
1 /*
2  * Copyright(c) 2020 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 ownership 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> 5 </since_tizen>
35     /// This will be released at Tizen.NET API Level 5, so currently this would be used as inhouse API.
36     [EditorBrowsable(EditorBrowsableState.Never)]
37     public class PixelData : BaseHandle
38     {
39
40         /// <summary>
41         /// Creates a PixelData object.
42         /// </summary>
43         /// <param name="buffer">The raw pixel data.</param>
44         /// <param name="bufferSize">The size of the buffer in bytes.</param>
45         /// <param name="width">Buffer width in pixels.</param>
46         /// <param name="height">Buffer height in pixels.</param>
47         /// <param name="pixelFormat">The pixel format.</param>
48         /// <param name="releaseFunction">The function used to release the memory.</param>
49         /// <since_tizen> 5 </since_tizen>
50         /// This will be deprecated after API level 9. ReleaseFunction is not useful in C#.
51         [EditorBrowsable(EditorBrowsableState.Never)]
52         public PixelData(byte[] buffer, uint bufferSize, uint width, uint height, PixelFormat pixelFormat, PixelData.ReleaseFunction releaseFunction) : this(Interop.PixelData.New(buffer, bufferSize, width, height, (int)pixelFormat), true)
53         {
54             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
55
56         }
57         
58         /// <summary>
59         /// Creates a PixelData object.
60         /// </summary>
61         /// <param name="buffer">The raw pixel data.</param>
62         /// <param name="bufferSize">The size of the buffer in bytes.</param>
63         /// <param name="width">Buffer width in pixels.</param>
64         /// <param name="height">Buffer height in pixels.</param>
65         /// <param name="pixelFormat">The pixel format.</param>
66         /// <since_tizen> 5 </since_tizen>
67         /// This will be released at Tizen.NET API Level 5, so currently this would be used as inhouse API.
68         [EditorBrowsable(EditorBrowsableState.Never)]
69         public PixelData(byte[] buffer, uint bufferSize, uint width, uint height, PixelFormat pixelFormat) : this(Interop.PixelData.New(buffer, bufferSize, width, height, (int)pixelFormat), true)
70         {
71             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
72
73         }
74
75         internal PixelData(global::System.IntPtr cPtr, bool cMemoryOwn) : base(cPtr, cMemoryOwn)
76         {
77         }
78
79         /// <summary>
80         /// Enumeration for function to release the pixel buffer.
81         /// </summary>
82         /// <since_tizen> 5 </since_tizen>
83         /// This will be deprecated after API level 9. ReleaseFunction is not useful in C#.
84         [EditorBrowsable(EditorBrowsableState.Never)]
85         public enum ReleaseFunction
86         {
87             /// <summary>
88             /// Use free function to release the pixel buffer.
89             /// </summary>
90             Free,
91
92             /// <summary>
93             /// Use delete[] operator to release the pixel buffer.
94             /// </summary>
95             DeleteArray
96         }
97
98         /// <summary>
99         /// Generate Url from pixel data.
100         /// </summary>
101         [EditorBrowsable(EditorBrowsableState.Never)]
102         public ImageUrl GenerateUrl()
103         {
104             ImageUrl ret = new ImageUrl(Interop.PixelData.GenerateUrl(this.SwigCPtr.Handle), true);
105             if (NDalicPINVOKE.SWIGPendingException.Pending) throw new InvalidOperationException("FATAL: get Exception", NDalicPINVOKE.SWIGPendingException.Retrieve());
106             return ret;
107         }
108
109         /// <summary>
110         /// Gets the width of the buffer in pixels.
111         /// </summary>
112         /// <returns>The width of the buffer in pixels.</returns>
113         /// <since_tizen> 5 </since_tizen>
114         /// This will be released at Tizen.NET API Level 5, so currently this would be used as inhouse API.
115         [EditorBrowsable(EditorBrowsableState.Never)]
116         public uint GetWidth()
117         {
118             uint ret = Interop.PixelData.GetWidth(SwigCPtr);
119             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
120             return ret;
121         }
122
123         /// <summary>
124         /// Gets the height of the buffer in pixels.
125         /// </summary>
126         /// <returns>The height of the buffer in pixels.</returns>
127         /// <since_tizen> 5 </since_tizen>
128         /// This will be released at Tizen.NET API Level 5, so currently this would be used as inhouse API.
129         [EditorBrowsable(EditorBrowsableState.Never)]
130         public uint GetHeight()
131         {
132             uint ret = Interop.PixelData.GetHeight(SwigCPtr);
133             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
134             return ret;
135         }
136
137         /// <summary>
138         /// Gets the pixel format.
139         /// </summary>
140         /// <returns>The pixel format.</returns>
141         /// <since_tizen> 5 </since_tizen>
142         /// This will be released at Tizen.NET API Level 5, so currently this would be used as inhouse API.
143         [EditorBrowsable(EditorBrowsableState.Never)]
144         public PixelFormat GetPixelFormat()
145         {
146             PixelFormat ret = (PixelFormat)Interop.PixelData.GetPixelFormat(SwigCPtr);
147             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
148             return ret;
149         }
150
151         internal static global::System.Runtime.InteropServices.HandleRef getCPtr(PixelData obj)
152         {
153             return (obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.SwigCPtr;
154         }
155
156         /// This will not be public opened.
157         [EditorBrowsable(EditorBrowsableState.Never)]
158         protected override void ReleaseSwigCPtr(System.Runtime.InteropServices.HandleRef swigCPtr)
159         {
160             Interop.PixelData.DeletePixelData(swigCPtr);
161         }
162     }
163 }