2 * Copyright(c) 2020 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.
19 using System.ComponentModel;
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.
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> 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
41 /// Creates a PixelData object.
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 released at Tizen.NET API Level 5, so currently this would be used as inhouse API.
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, (int)releaseFunction), true)
54 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
58 internal PixelData(global::System.IntPtr cPtr, bool cMemoryOwn) : base(Interop.PixelData.Upcast(cPtr), cMemoryOwn)
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 /// Get URI from pixel data.
84 [EditorBrowsable(EditorBrowsableState.Never)]
90 Uri = Interop.PixelData.GenerateUrl(this.SwigCPtr.Handle);
91 if (NDalicPINVOKE.SWIGPendingException.Pending) throw new InvalidOperationException("FATAL: get Exception", NDalicPINVOKE.SWIGPendingException.Retrieve());
97 /// Gets the width of the buffer in pixels.
99 /// <returns>The width of the buffer in pixels.</returns>
100 /// <since_tizen> 5 </since_tizen>
101 /// This will be released at Tizen.NET API Level 5, so currently this would be used as inhouse API.
102 [EditorBrowsable(EditorBrowsableState.Never)]
103 public uint GetWidth()
105 uint ret = Interop.PixelData.GetWidth(SwigCPtr);
106 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
111 /// Gets the height of the buffer in pixels.
113 /// <returns>The height of the buffer in pixels.</returns>
114 /// <since_tizen> 5 </since_tizen>
115 /// This will be released at Tizen.NET API Level 5, so currently this would be used as inhouse API.
116 [EditorBrowsable(EditorBrowsableState.Never)]
117 public uint GetHeight()
119 uint ret = Interop.PixelData.GetHeight(SwigCPtr);
120 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
125 /// Gets the pixel format.
127 /// <returns>The pixel format.</returns>
128 /// <since_tizen> 5 </since_tizen>
129 /// This will be released at Tizen.NET API Level 5, so currently this would be used as inhouse API.
130 [EditorBrowsable(EditorBrowsableState.Never)]
131 public PixelFormat GetPixelFormat()
133 PixelFormat ret = (PixelFormat)Interop.PixelData.GetPixelFormat(SwigCPtr);
134 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
138 internal static global::System.Runtime.InteropServices.HandleRef getCPtr(PixelData obj)
140 return (obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.SwigCPtr;
143 /// This will not be public opened.
144 [EditorBrowsable(EditorBrowsableState.Never)]
145 protected override void ReleaseSwigCPtr(System.Runtime.InteropServices.HandleRef swigCPtr)
147 Interop.PixelData.DeletePixelData(swigCPtr);