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)
63 //Unreference this instance from Registry.
64 Registry.Unregister(this);
66 NDalicPINVOKE.delete_Image(swigCPtr);
68 swigCPtr = new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero);
77 * @brief Event arguments that passed via Uploaded signal
80 public class UploadedEventArgs : EventArgs
84 * @brief Image - is the image data that gets uploaded to GL.
100 [UnmanagedFunctionPointer(CallingConvention.StdCall)]
101 private delegate void UploadedEventCallbackDelegate(IntPtr image);
102 private DaliEventHandler<object, UploadedEventArgs> _imageUploadedEventHandler;
103 private UploadedEventCallbackDelegate _imageUploadedEventCallbackDelegate;
106 * @brief Event for Uploaded signal which can be used to subscribe/unsubscribe the event handler
107 * (in the type of UploadedEventHandler-DaliEventHandler<object,UploadedEventArgs>)
108 * provided by the user. Uploaded signal is emitted when the image data gets uploaded to GL.
110 public event DaliEventHandler<object, UploadedEventArgs> Uploaded
116 // Restricted to only one listener
117 if (_imageUploadedEventHandler == null)
119 _imageUploadedEventHandler += value;
121 _imageUploadedEventCallbackDelegate = new UploadedEventCallbackDelegate(OnUploaded);
122 this.UploadedSignal().Connect(_imageUploadedEventCallbackDelegate);
131 if (_imageUploadedEventHandler != null)
133 this.UploadedSignal().Disconnect(_imageUploadedEventCallbackDelegate);
136 _imageUploadedEventHandler -= value;
141 // Callback for Image UploadedSignal
142 private void OnUploaded(IntPtr data)
144 UploadedEventArgs e = new UploadedEventArgs();
146 // Populate all members of "e" (UploadedEventArgs) with real data
147 e.Image = Image.GetImageFromPtr(data);
149 if (_imageUploadedEventHandler != null)
151 //here we send all data to user event handlers
152 _imageUploadedEventHandler(this, e);
157 public static Image GetImageFromPtr(global::System.IntPtr cPtr)
159 Image ret = new Image(cPtr, false);
160 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
165 public Image() : this(NDalicPINVOKE.new_Image__SWIG_0(), true)
167 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
170 public Image(Image handle) : this(NDalicPINVOKE.new_Image__SWIG_1(Image.getCPtr(handle)), true)
172 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
175 public Image Assign(Image rhs)
177 Image ret = new Image(NDalicPINVOKE.Image_Assign(swigCPtr, Image.getCPtr(rhs)), false);
178 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
182 public static Image DownCast(BaseHandle handle)
184 Image ret = new Image(NDalicPINVOKE.Image_DownCast(BaseHandle.getCPtr(handle)), true);
185 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
189 public uint GetWidth()
191 uint ret = NDalicPINVOKE.Image_GetWidth(swigCPtr);
192 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
196 public uint GetHeight()
198 uint ret = NDalicPINVOKE.Image_GetHeight(swigCPtr);
199 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
203 public ImageSignal UploadedSignal()
205 ImageSignal ret = new ImageSignal(NDalicPINVOKE.Image_UploadedSignal(swigCPtr), false);
206 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();