2 * Copyright(c) 2017 Samsung Electronics Co., Ltd.
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
17 using System.ComponentModel;
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.
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
37 private global::System.Runtime.InteropServices.HandleRef swigCPtr;
40 /// Creates a PixelData object.
42 /// <param name="buffer">The raw pixel data.</param>
43 /// <param name="bufferSize">The size of the buffer in bytes.</param>
44 /// <param name="width">Buffer width in pixels.</param>
45 /// <param name="height">Buffer height in pixels.</param>
46 /// <param name="pixelFormat">The pixel format.</param>
47 /// <param name="releaseFunction">The function used to release the memory.</param>
48 /// <since_tizen> 5 </since_tizen>
49 /// This will be released at Tizen.NET API Level 5, so currently this would be used as inhouse API.
50 [EditorBrowsable(EditorBrowsableState.Never)]
51 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)
53 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
57 internal PixelData(global::System.IntPtr cPtr, bool cMemoryOwn) : base(NDalicPINVOKE.PixelData_SWIGUpcast(cPtr), cMemoryOwn)
59 swigCPtr = new global::System.Runtime.InteropServices.HandleRef(this, cPtr);
63 /// Enumeration for function to release the pixel buffer.
65 /// <since_tizen> 5 </since_tizen>
66 /// This will be released at Tizen.NET API Level 5, so currently this would be used as inhouse API.
67 [EditorBrowsable(EditorBrowsableState.Never)]
68 public enum ReleaseFunction
71 /// Use free function to release the pixel buffer.
76 /// Use delete[] operator to release the pixel buffer.
82 /// Gets the width of the buffer in pixels.
84 /// <returns>The width of the buffer in pixels.</returns>
85 /// <since_tizen> 5 </since_tizen>
86 /// This will be released at Tizen.NET API Level 5, so currently this would be used as inhouse API.
87 [EditorBrowsable(EditorBrowsableState.Never)]
88 public uint GetWidth()
90 uint ret = NDalicPINVOKE.PixelData_GetWidth(swigCPtr);
91 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
96 /// Gets the height of the buffer in pixels.
98 /// <returns>The height of the buffer in pixels.</returns>
99 /// <since_tizen> 5 </since_tizen>
100 /// This will be released at Tizen.NET API Level 5, so currently this would be used as inhouse API.
101 [EditorBrowsable(EditorBrowsableState.Never)]
102 public uint GetHeight()
104 uint ret = NDalicPINVOKE.PixelData_GetHeight(swigCPtr);
105 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
110 /// Gets the pixel format.
112 /// <returns>The pixel format.</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 PixelFormat GetPixelFormat()
118 PixelFormat ret = (PixelFormat)NDalicPINVOKE.PixelData_GetPixelFormat(swigCPtr);
119 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
123 internal static global::System.Runtime.InteropServices.HandleRef getCPtr(PixelData obj)
125 return (obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.swigCPtr;
131 /// <since_tizen> 5 </since_tizen>
132 protected override void Dispose(DisposeTypes type)
139 if (type == DisposeTypes.Explicit)
142 //Release your own managed resources here.
143 //You should release all of your own disposable objects here.
147 //Release your own unmanaged resources here.
148 //You should not access any managed member here except static instance.
149 //Because the execution order of Finalizes is non-deterministic.
152 if (swigCPtr.Handle != global::System.IntPtr.Zero)
157 NDalicPINVOKE.delete_PixelData(swigCPtr);
159 swigCPtr = new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero);