From: seungho Date: Tue, 22 Jun 2021 06:24:22 +0000 (+0900) Subject: [NUI] Add GetCapturedBuffer api for Capture X-Git-Tag: submit/tizen_6.0/20210705.151755~1^2 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=1719d7a152f517c365e445f61731eb07129a929e;p=platform%2Fcore%2Fcsapi%2Ftizenfx.git [NUI] Add GetCapturedBuffer api for Capture This reverts commit 1eed99c679ddd617652fd5a0bf668e28aecc067b. --- diff --git a/src/Tizen.NUI/src/internal/Interop/Interop.Capture.cs b/src/Tizen.NUI/src/internal/Interop/Interop.Capture.cs index 7423c000e..cd5f1d628 100755 --- a/src/Tizen.NUI/src/internal/Interop/Interop.Capture.cs +++ b/src/Tizen.NUI/src/internal/Interop/Interop.Capture.cs @@ -71,6 +71,9 @@ namespace Tizen.NUI [DllImport(NDalicPINVOKE.Lib, EntryPoint = "CSharp_Dali_Capture_GenerateUrl")] public static extern string GenerateUrl(HandleRef capture); + [DllImport(NDalicPINVOKE.Lib, EntryPoint = "CSharp_Dali_Capture_GetCapturedBuffer")] + public static extern IntPtr GetCapturedBuffer(HandleRef capture); + } } } diff --git a/src/Tizen.NUI/src/public/Capture.cs b/src/Tizen.NUI/src/public/Capture.cs index f855ef950..f0c1730af 100755 --- a/src/Tizen.NUI/src/public/Capture.cs +++ b/src/Tizen.NUI/src/public/Capture.cs @@ -105,22 +105,39 @@ namespace Tizen.NUI /// If path is empty string, the captured result is not be saved as a file. /// background color of captured scene. /// This exception can be due to the invalid size values, of when width or height is lower than zero. - /// This exception is due to the path is null. + /// This exception is due to the some arguments are null. [EditorBrowsable(EditorBrowsableState.Never)] public void Start(Container source, Position position, Size size, string path, Color color) { - if (size.Width <= 0 || size.Height <= 0) + if (position == null) { - throw new InvalidOperationException("size should larger than zero"); + throw new ArgumentNullException(nameof(position)); + } + else if (size == null) + { + throw new ArgumentNullException(nameof(size)); + } + else if (path == null) + { + throw new ArgumentNullException(nameof(path)); + } + else if (color == null) + { + throw new ArgumentNullException(nameof(color)); } - else if (null == path) + if (size.Width <= 0 || size.Height <= 0) { - throw new ArgumentNullException("path should not be null"); + throw new InvalidOperationException("size should larger than zero"); } if (source is View || source is Layer) { - Interop.Capture.Start4(swigCPtr, source.SwigCPtr, new Vector2(position.X, position.Y).SwigCPtr, new Vector2(size.Width, size.Height).SwigCPtr, path, new Vector4(color.R, color.G, color.B, color.A).SwigCPtr); + using (Vector2 positionVector = new Vector2(position.X, position.Y)) + using (Vector2 sizeVector = new Vector2(size.Width, size.Height)) + using (Vector4 colorVector = new Vector4(color.R, color.G, color.B, color.A)) + { + Interop.Capture.Start4(swigCPtr, source.SwigCPtr, positionVector.SwigCPtr, sizeVector.SwigCPtr, path, colorVector.SwigCPtr); + } if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve(); } @@ -141,13 +158,21 @@ namespace Tizen.NUI [EditorBrowsable(EditorBrowsableState.Never)] public void Start(Container source, Size size, string path, Color color, uint quality) { - if (size.Width <= 0 || size.Height <= 0) + if (size == null) { - throw new InvalidOperationException("size should larger than zero"); + throw new ArgumentNullException(nameof(size)); + } + else if (path == null) + { + throw new ArgumentNullException(nameof(path)); + } + else if (color == null) + { + throw new ArgumentNullException(nameof(color)); } - else if (null == path) + if (size.Width <= 0 || size.Height <= 0) { - throw new ArgumentNullException("path should not be null"); + throw new InvalidOperationException("size should larger than zero"); } else if (quality > 100) { @@ -156,7 +181,11 @@ namespace Tizen.NUI if (source is View || source is Layer) { - Interop.Capture.Start3(swigCPtr, source.SwigCPtr, new Vector2(size.Width, size.Height).SwigCPtr, path, new Vector4(color.R, color.G, color.B, color.A).SwigCPtr, quality); + using (Vector2 sizeVector = new Vector2(size.Width, size.Height)) + using (Vector4 colorVector = new Vector4(color.R, color.G, color.B, color.A)) + { + Interop.Capture.Start3(swigCPtr, source.SwigCPtr, sizeVector.SwigCPtr, path, colorVector.SwigCPtr, quality); + } if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve(); } @@ -176,18 +205,30 @@ namespace Tizen.NUI [EditorBrowsable(EditorBrowsableState.Never)] public void Start(Container source, Size size, string path, Color color) { - if (size.Width <= 0 || size.Height <= 0) + if (size == null) { - throw new InvalidOperationException("size should larger than zero"); + throw new ArgumentNullException(nameof(size)); + } + else if (path == null) + { + throw new ArgumentNullException(nameof(path)); } - else if (null == path) + else if (color == null) + { + throw new ArgumentNullException(nameof(color)); + } + if (size.Width <= 0 || size.Height <= 0) { - throw new ArgumentNullException("path should not be null"); + throw new InvalidOperationException("size should larger than zero"); } if (source is View || source is Layer) { - Interop.Capture.Start1(swigCPtr, source.SwigCPtr, new Vector2(size.Width, size.Height).SwigCPtr, path, new Vector4(color.R, color.G, color.B, color.A).SwigCPtr); + using (Vector2 sizeVector = new Vector2(size.Width, size.Height)) + using (Vector4 colorVector = new Vector4(color.R, color.G, color.B, color.A)) + { + Interop.Capture.Start1(swigCPtr, source.SwigCPtr, sizeVector.SwigCPtr, path, colorVector.SwigCPtr); + } if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve(); } @@ -209,18 +250,25 @@ namespace Tizen.NUI [EditorBrowsable(EditorBrowsableState.Never)] public void Start(Container source, Size size, string path) { - if (size.Width <= 0 || size.Height <= 0) + if (size == null) { - throw new InvalidOperationException("size should larger than zero"); + throw new ArgumentNullException(nameof(size)); } - else if (null == path) + else if (path == null) { - throw new ArgumentNullException("path should not be null"); + throw new ArgumentNullException(nameof(path)); + } + if (size.Width <= 0 || size.Height <= 0) + { + throw new InvalidOperationException("size should larger than zero"); } if (source is View || source is Layer) { - Interop.Capture.Start2(swigCPtr, source.SwigCPtr, new Vector2(size.Width, size.Height).SwigCPtr, path); + using (Vector2 sizeVector = new Vector2(size.Width, size.Height)) + { + Interop.Capture.Start2(swigCPtr, source.SwigCPtr, sizeVector.SwigCPtr, path); + } if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve(); } @@ -320,6 +368,7 @@ namespace Tizen.NUI /// /// The Url string representing this captured image source [EditorBrowsable(EditorBrowsableState.Never)] + [System.Diagnostics.CodeAnalysis.SuppressMessage("Design", "CA1056:Uri properties should not be strings", Justification = "")] public string GenerateUrl() { string url = ""; @@ -328,6 +377,15 @@ namespace Tizen.NUI return url; } + /// + /// Get Captured buffer. + /// + /// PixelBuffer of captured buffer + [EditorBrowsable(EditorBrowsableState.Never)] + public PixelBuffer GetCapturedBuffer() + { + return new PixelBuffer(Interop.Capture.GetCapturedBuffer(SwigCPtr), true); + } } ///