[NUI] Make Capture return ImageUrl
authorSeungho Baek <sbsh.baek@samsung.com>
Tue, 2 Jul 2024 06:34:00 +0000 (15:34 +0900)
committerEunki Hong <h.pichulia@gmail.com>
Wed, 10 Jul 2024 09:12:11 +0000 (18:12 +0900)
Signed-off-by: Seungho Baek <sbsh.baek@samsung.com>
src/Tizen.NUI/src/internal/Interop/Interop.Capture.cs
src/Tizen.NUI/src/public/Utility/Capture.cs
test/Tizen.NUI.Samples/Tizen.NUI.Samples/Samples/CaptureTest.cs

index fd1ae38..180827d 100644 (file)
@@ -65,6 +65,9 @@ namespace Tizen.NUI
             [DllImport(NDalicPINVOKE.Lib, EntryPoint = "CSharp_Dali_Capture_Signal_Get")]
             public static extern IntPtr Get(HandleRef jarg1);
 
+            [DllImport(NDalicPINVOKE.Lib, EntryPoint = "CSharp_Dali_Capture_GetImageUrl")]
+            public static extern IntPtr GetImageUrl(HandleRef capture);
+
             [DllImport(NDalicPINVOKE.Lib, EntryPoint = "CSharp_Dali_Capture_GetNativeImageSource")]
             public static extern IntPtr GetNativeImageSourcePtr(HandleRef jarg1);
 
index db08cb3..885da7e 100755 (executable)
@@ -324,6 +324,27 @@ namespace Tizen.NUI
         }
 
         /// <summary>
+        /// Gets ImageUrl that is saved captured image.
+        /// </summary>
+        /// <returns>ImageUrl that is saved captured image.</returns>
+        [EditorBrowsable(EditorBrowsableState.Never)]
+        public ImageUrl GetImageUrl()
+        {
+            IntPtr cPtr = Interop.Capture.GetImageUrl(SwigCPtr);
+            ImageUrl ret = Registry.GetManagedBaseHandleFromNativePtr(cPtr) as ImageUrl;
+            if (ret != null)
+            {
+                Interop.BaseHandle.DeleteBaseHandle(new HandleRef(this, cPtr));
+            }
+            else
+            {
+                ret = new ImageUrl(cPtr, true);
+            }
+            NDalicPINVOKE.ThrowExceptionIfExists();
+            return ret;
+        }
+
+        /// <summary>
         /// Get NativeImageSource that is saved captured image.
         /// </summary>
         /// <returns>NativeImageSource that is saved captured image.</returns>
index 28d8876..ad6e53f 100755 (executable)
@@ -58,13 +58,9 @@ namespace Tizen.NUI.Samples
             if (sender is Capture)
             {
                 log.Debug(tag, $"sender is Capture \n");
-                PixelBuffer pixelBuffer = capture.GetCapturedBuffer();
-                PixelData pixelData = PixelBuffer.Convert(pixelBuffer);
-                //var imageUrl = pixelData.GenerateUrl();//capture.GetNativeImageSource().Url;
-                //capturedImage = new ImageView(imageUrl.ToString());
-                var url = pixelData.GenerateUrl();
-                capturedImage = new ImageView(url.ToString());
-                log.Debug(tag, $"url={url} \n");
+                ImageUrl imageUrl = capture.GetImageUrl();
+                capturedImage = new ImageView(imageUrl.ToString());
+                log.Debug(tag, $"url={imageUrl.ToString()} \n");
 
                 capturedImage.Size = new Size(510, 510);
                 capturedImage.Position = new Position(10, 10);
@@ -81,7 +77,7 @@ namespace Tizen.NUI.Samples
                 {
                     done = true;
                     capture = new Capture();
-                    capture.Start(root, new Size(510, 510), @"/opt/usr/nui_captured.jpg");
+                    capture.Start(root, new Size(510, 510), "");
                     capture.Finished += onCaptureFinished;
                     log.Debug(tag, $"capture done \n");
                 }