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.
21 /// The PixelData object holds a pixel buffer.<br />
22 /// The PixelData takes over the ownership of the pixel buffer.<br />
23 /// The buffer memory must NOT be released outside of this class, instead,
24 /// the PixelData object will release it automatically when the reference count falls to zero.
26 public class PixelData : BaseHandle
28 private global::System.Runtime.InteropServices.HandleRef swigCPtr;
30 internal PixelData(global::System.IntPtr cPtr, bool cMemoryOwn) : base(NDalicPINVOKE.PixelData_SWIGUpcast(cPtr), cMemoryOwn)
32 swigCPtr = new global::System.Runtime.InteropServices.HandleRef(this, cPtr);
35 internal static global::System.Runtime.InteropServices.HandleRef getCPtr(PixelData obj)
37 return (obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.swigCPtr;
43 /// <since_tizen> 3 </since_tizen>
44 protected override void Dispose(DisposeTypes type)
51 if (type == DisposeTypes.Explicit)
54 //Release your own managed resources here.
55 //You should release all of your own disposable objects here.
59 //Release your own unmanaged resources here.
60 //You should not access any managed member here except static instance.
61 //because the execution order of Finalizes is non-deterministic.
64 if (swigCPtr.Handle != global::System.IntPtr.Zero)
69 NDalicPINVOKE.delete_PixelData(swigCPtr);
71 swigCPtr = new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero);
78 /// Creates a PixelData object.
80 /// <param name="buffer">The raw pixel data.</param>
81 /// <param name="bufferSize">The size of the buffer in bytes.</param>
82 /// <param name="width">Buffer width in pixels.</param>
83 /// <param name="height">Buffer height in pixels.</param>
84 /// <param name="pixelFormat">The pixel format.</param>
85 /// <param name="releaseFunction">The function used to release the memory.</param>
86 /// <since_tizen> 3 </since_tizen>
87 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)
89 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
94 /// Gets the width of the buffer in pixels.
96 /// <returns>The width of the buffer in pixels.</returns>
97 /// <since_tizen> 3 </since_tizen>
98 public uint GetWidth()
100 uint ret = NDalicPINVOKE.PixelData_GetWidth(swigCPtr);
101 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
106 /// Gets the height of the buffer in pixels.
108 /// <returns>The height of the buffer in pixels.</returns>
109 /// <since_tizen> 3 </since_tizen>
110 public uint GetHeight()
112 uint ret = NDalicPINVOKE.PixelData_GetHeight(swigCPtr);
113 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
118 /// Gets the pixel format.
120 /// <returns>The pixel format.</returns>
121 /// <since_tizen> 3 </since_tizen>
122 public PixelFormat GetPixelFormat()
124 PixelFormat ret = (PixelFormat)NDalicPINVOKE.PixelData_GetPixelFormat(swigCPtr);
125 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
130 /// Enumeration for Function to release the pixel buffer.
132 /// <since_tizen> 3 </since_tizen>
133 public enum ReleaseFunction
136 /// Use free function to release the pixel buffer.
141 /// Use delete[] operator to release the pixel buffer.