1 /** Copyright (c) 2017 Samsung Electronics Co., Ltd.
3 * Licensed under the Apache License, Version 2.0 (the "License");
4 * you may not use this file except in compliance with the License.
5 * You may obtain a copy of the License at
7 * http://www.apache.org/licenses/LICENSE-2.0
9 * Unless required by applicable law or agreed to in writing, software
10 * distributed under the License is distributed on an "AS IS" BASIS,
11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 * See the License for the specific language governing permissions and
13 * limitations under the License.
21 using System.Runtime.InteropServices;
24 internal class Image : BaseHandle
26 private global::System.Runtime.InteropServices.HandleRef swigCPtr;
28 internal Image(global::System.IntPtr cPtr, bool cMemoryOwn) : base(NDalicPINVOKE.Image_SWIGUpcast(cPtr), cMemoryOwn)
30 swigCPtr = new global::System.Runtime.InteropServices.HandleRef(this, cPtr);
33 internal static global::System.Runtime.InteropServices.HandleRef getCPtr(Image obj)
35 return (obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.swigCPtr;
38 protected override void Dispose(DisposeTypes type)
45 if (type == DisposeTypes.Explicit)
48 //Release your own managed resources here.
49 //You should release all of your own disposable objects here.
53 //Release your own unmanaged resources here.
54 //You should not access any managed member here except static instance.
55 //because the execution order of Finalizes is non-deterministic.
57 if (swigCPtr.Handle != global::System.IntPtr.Zero)
62 NDalicPINVOKE.delete_Image(swigCPtr);
64 swigCPtr = new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero);
73 * @brief Event arguments that passed via Uploaded signal
76 public class UploadedEventArgs : EventArgs
80 * @brief Image - is the image data that gets uploaded to GL.
96 [UnmanagedFunctionPointer(CallingConvention.StdCall)]
97 private delegate void UploadedEventCallbackDelegate(IntPtr image);
98 private DaliEventHandler<object, UploadedEventArgs> _imageUploadedEventHandler;
99 private UploadedEventCallbackDelegate _imageUploadedEventCallbackDelegate;
102 * @brief Event for Uploaded signal which can be used to subscribe/unsubscribe the event handler
103 * (in the type of UploadedEventHandler-DaliEventHandler<object,UploadedEventArgs>)
104 * provided by the user. Uploaded signal is emitted when the image data gets uploaded to GL.
106 public event DaliEventHandler<object, UploadedEventArgs> Uploaded
112 // Restricted to only one listener
113 if (_imageUploadedEventHandler == null)
115 _imageUploadedEventHandler += value;
117 _imageUploadedEventCallbackDelegate = new UploadedEventCallbackDelegate(OnUploaded);
118 this.UploadedSignal().Connect(_imageUploadedEventCallbackDelegate);
127 if (_imageUploadedEventHandler != null)
129 this.UploadedSignal().Disconnect(_imageUploadedEventCallbackDelegate);
132 _imageUploadedEventHandler -= value;
137 // Callback for Image UploadedSignal
138 private void OnUploaded(IntPtr data)
140 UploadedEventArgs e = new UploadedEventArgs();
142 // Populate all members of "e" (UploadedEventArgs) with real data
143 e.Image = Image.GetImageFromPtr(data);
145 if (_imageUploadedEventHandler != null)
147 //here we send all data to user event handlers
148 _imageUploadedEventHandler(this, e);
153 public static Image GetImageFromPtr(global::System.IntPtr cPtr)
155 Image ret = new Image(cPtr, false);
156 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
161 public Image() : this(NDalicPINVOKE.new_Image__SWIG_0(), true)
163 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
166 public Image(Image handle) : this(NDalicPINVOKE.new_Image__SWIG_1(Image.getCPtr(handle)), true)
168 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
171 public Image Assign(Image rhs)
173 Image ret = new Image(NDalicPINVOKE.Image_Assign(swigCPtr, Image.getCPtr(rhs)), false);
174 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
178 public static Image DownCast(BaseHandle handle)
180 Image ret = Registry.GetManagedBaseHandleFromNativePtr(handle) as Image;
181 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
185 public uint GetWidth()
187 uint ret = NDalicPINVOKE.Image_GetWidth(swigCPtr);
188 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
192 public uint GetHeight()
194 uint ret = NDalicPINVOKE.Image_GetHeight(swigCPtr);
195 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
199 public ImageSignal UploadedSignal()
201 ImageSignal ret = new ImageSignal(NDalicPINVOKE.Image_UploadedSignal(swigCPtr), false);
202 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();