[NUI] Add Url property to convert image buffer to URL for ImageView (#2286)
authorbshsqa <32317749+bshsqa@users.noreply.github.com>
Mon, 7 Dec 2020 06:59:19 +0000 (15:59 +0900)
committerdongsug-song <35130733+dongsug-song@users.noreply.github.com>
Tue, 8 Dec 2020 06:23:12 +0000 (15:23 +0900)
Signed-off-by: Seungho Baek <sbsh.baek@samsung.com>
src/Tizen.NUI/src/internal/Interop/Interop.Capture.cs
src/Tizen.NUI/src/internal/Interop/Interop.NativeImageSource.cs
src/Tizen.NUI/src/internal/Interop/Interop.PixelData.cs
src/Tizen.NUI/src/public/Capture.cs
src/Tizen.NUI/src/public/NativeImageSource.cs
src/Tizen.NUI/src/public/PixelData.cs
test/Tizen.NUI.Samples/Tizen.NUI.Samples/Samples/CaptureTest.cs

index d5ea812..a5de041 100755 (executable)
@@ -69,7 +69,7 @@ namespace Tizen.NUI
             public static extern IntPtr GetNativeImageSourcePtr(HandleRef jarg1);
 
             [DllImport(NDalicPINVOKE.Lib, EntryPoint = "CSharp_Dali_Capture_GenerateUrl")]
-            public static extern string GenerageUrl(HandleRef capture);
+            public static extern string GenerateUrl(HandleRef capture);
 
         }
     }
index d74c248..d107bbf 100755 (executable)
@@ -27,6 +27,9 @@ namespace Tizen.NUI
 
             [global::System.Runtime.InteropServices.DllImport(NDalicPINVOKE.Lib, EntryPoint = "CSharp_Dali_NativeImageSource_ReleaseBuffer")]
             public static extern bool ReleaseBuffer(IntPtr jarg1);
+
+            [global::System.Runtime.InteropServices.DllImport(NDalicPINVOKE.Lib, EntryPoint = "CSharp_Dali_NativeImageSource_GenerateUrl")]
+            public static extern string GenerateUrl(IntPtr handle);
         }
     }
-}
\ No newline at end of file
+}
index cfa6cf3..27dc9cb 100755 (executable)
@@ -34,6 +34,9 @@ namespace Tizen.NUI
 
             [global::System.Runtime.InteropServices.DllImport(NDalicPINVOKE.Lib, EntryPoint = "CSharp_Dali_PixelData_GetPixelFormat")]
             public static extern int PixelData_GetPixelFormat(global::System.Runtime.InteropServices.HandleRef jarg1);
+
+            [global::System.Runtime.InteropServices.DllImport(NDalicPINVOKE.Lib, EntryPoint = "CSharp_Dali_PixelData_GenerateUrl")]
+            public static extern string GenerateUrl(IntPtr handle);
         }
     }
 }
\ No newline at end of file
index c31514a..aa39654 100755 (executable)
@@ -342,7 +342,7 @@ namespace Tizen.NUI
         public string GenerateUrl()
         {
             string url = "";
-            url = Interop.Capture.GenerageUrl(swigCPtr);
+            url = Interop.Capture.GenerateUrl(swigCPtr);
             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
             return url;
         }
index e58a6be..04b5e7d 100755 (executable)
@@ -1,4 +1,21 @@
+/*
+ * Copyright(c) 2020 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
 
+using System;
 using System.ComponentModel;
 using System.Runtime.InteropServices;
 
@@ -22,6 +39,22 @@ namespace Tizen.NUI
             Handle = cPtr;
         }
 
+
+        /// <summary>
+        /// Get URL from native image source.
+        /// </summary>
+        [EditorBrowsable(EditorBrowsableState.Never)]
+        public Uri Url
+        {
+            get
+            {
+                string url = "";
+                url = Interop.NativeImageSource.GenerateUrl(this.swigCPtr.Handle);
+                if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
+                return new Uri(url);
+            }
+        }
+
         [EditorBrowsable(EditorBrowsableState.Never)]
         protected override void ReleaseSwigCPtr(System.Runtime.InteropServices.HandleRef swigCPtr)
         {
@@ -60,4 +93,4 @@ namespace Tizen.NUI
             return ret;
         }
     }
-}
\ No newline at end of file
+}
index 4dd4f2d..f5b00c0 100755 (executable)
@@ -1,5 +1,5 @@
 /*
- * Copyright(c) 2017 Samsung Electronics Co., Ltd.
+ * Copyright(c) 2020 Samsung Electronics Co., Ltd.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -14,6 +14,8 @@
  * limitations under the License.
  *
  */
+
+using System;
 using System.ComponentModel;
 
 namespace Tizen.NUI
@@ -77,6 +79,21 @@ namespace Tizen.NUI
         }
 
         /// <summary>
+        /// Get URL from pixel data.
+        /// </summary>
+        [EditorBrowsable(EditorBrowsableState.Never)]
+        public Uri Url
+        {
+            get
+            {
+                string url = "";
+                url = Interop.PixelData.GenerateUrl(this.swigCPtr.Handle);
+                if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
+                return new Uri(url);
+            }
+        }
+
+        /// <summary>
         /// Gets the width of the buffer in pixels.
         /// </summary>
         /// <returns>The width of the buffer in pixels.</returns>
@@ -130,4 +147,4 @@ namespace Tizen.NUI
             Interop.PixelData.delete_PixelData(swigCPtr);
         }
     }
-}
\ No newline at end of file
+}
index ccf0f33..1702f3b 100755 (executable)
@@ -58,11 +58,11 @@ namespace Tizen.NUI.Samples
             if (sender is Capture)
             {
                 log.Debug(tag, $"sender is Capture \n");
-                var url = capture.GenerateUrl();
-                capturedImage = new ImageView(url);
+                var url = capture.GetNativeImageSource().Url;
+                capturedImage = new ImageView(url.AbsoluteUri);
                 log.Debug(tag, $"url={url} \n");
 
-                capturedImage.Size = new Size(300, 300);
+                capturedImage.Size = new Size(510, 510);
                 capturedImage.Position = new Position(10, 10);
                 root.Add(capturedImage);
                 done = false;
@@ -77,7 +77,7 @@ namespace Tizen.NUI.Samples
                 {
                     done = true;
                     capture = new Capture();
-                    capture.Start(root, new Size(345, 543), @"/opt/usr/nui_captured.jpg");
+                    capture.Start(root, new Size(510, 510), @"/opt/usr/nui_captured.jpg");
                     capture.Finished += onCaptureFinished;
                     log.Debug(tag, $"capture done \n");
                 }