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.
22 using System.Runtime.InteropServices;
25 internal class Image : BaseHandle
27 private global::System.Runtime.InteropServices.HandleRef swigCPtr;
29 internal Image(global::System.IntPtr cPtr, bool cMemoryOwn) : base(NDalicPINVOKE.Image_SWIGUpcast(cPtr), cMemoryOwn)
31 swigCPtr = new global::System.Runtime.InteropServices.HandleRef(this, cPtr);
34 internal static global::System.Runtime.InteropServices.HandleRef getCPtr(Image obj)
36 return (obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.swigCPtr;
39 protected override void Dispose(DisposeTypes type)
46 if (type == DisposeTypes.Explicit)
49 //Release your own managed resources here.
50 //You should release all of your own disposable objects here.
54 //Release your own unmanaged resources here.
55 //You should not access any managed member here except static instance.
56 //because the execution order of Finalizes is non-deterministic.
58 if (swigCPtr.Handle != global::System.IntPtr.Zero)
63 NDalicPINVOKE.delete_Image(swigCPtr);
65 swigCPtr = new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero);
74 * @brief Event arguments that passed via Uploaded signal
77 /// <since_tizen> 3 </since_tizen>
78 public class UploadedEventArgs : EventArgs
82 * @brief Image - is the image data that gets uploaded to GL.
85 /// <since_tizen> 3 </since_tizen>
99 [UnmanagedFunctionPointer(CallingConvention.StdCall)]
100 private delegate void UploadedEventCallbackDelegate(IntPtr image);
101 private DaliEventHandler<object, UploadedEventArgs> _imageUploadedEventHandler;
102 private UploadedEventCallbackDelegate _imageUploadedEventCallbackDelegate;
105 * @brief Event for Uploaded signal which can be used to subscribe/unsubscribe the event handler
106 * provided by the user. Uploaded signal is emitted when the image data gets uploaded to GL.
108 public event DaliEventHandler<object, UploadedEventArgs> Uploaded
114 // Restricted to only one listener
115 if (_imageUploadedEventHandler == null)
117 _imageUploadedEventHandler += value;
119 _imageUploadedEventCallbackDelegate = new UploadedEventCallbackDelegate(OnUploaded);
120 this.UploadedSignal().Connect(_imageUploadedEventCallbackDelegate);
129 if (_imageUploadedEventHandler != null)
131 this.UploadedSignal().Disconnect(_imageUploadedEventCallbackDelegate);
134 _imageUploadedEventHandler -= value;
139 // Callback for Image UploadedSignal
140 private void OnUploaded(IntPtr data)
142 UploadedEventArgs e = new UploadedEventArgs();
144 // Populate all members of "e" (UploadedEventArgs) with real data
145 e.Image = Image.GetImageFromPtr(data);
147 if (_imageUploadedEventHandler != null)
149 //here we send all data to user event handlers
150 _imageUploadedEventHandler(this, e);
155 public static Image GetImageFromPtr(global::System.IntPtr cPtr)
157 Image ret = new Image(cPtr, false);
158 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
163 public Image() : this(NDalicPINVOKE.new_Image__SWIG_0(), true)
165 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
168 public Image(Image handle) : this(NDalicPINVOKE.new_Image__SWIG_1(Image.getCPtr(handle)), true)
170 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
173 public Image Assign(Image rhs)
175 Image ret = new Image(NDalicPINVOKE.Image_Assign(swigCPtr, Image.getCPtr(rhs)), false);
176 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
180 public static Image DownCast(BaseHandle handle)
182 Image ret = Registry.GetManagedBaseHandleFromNativePtr(handle) as Image;
183 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
187 public uint GetWidth()
189 uint ret = NDalicPINVOKE.Image_GetWidth(swigCPtr);
190 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
194 public uint GetHeight()
196 uint ret = NDalicPINVOKE.Image_GetHeight(swigCPtr);
197 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
201 public ImageSignal UploadedSignal()
203 ImageSignal ret = new ImageSignal(NDalicPINVOKE.Image_UploadedSignal(swigCPtr), false);
204 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();