From: Eunki Hong Date: Sun, 29 Jan 2023 07:49:13 +0000 (+0900) Subject: [NUI] Add EncodedImageBuffer sample X-Git-Tag: accepted/tizen/unified/20231205.024657~478 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=a84eb4165a7ab719c90009412e8caf4c294fe7bd;p=platform%2Fcore%2Fcsapi%2Ftizenfx.git [NUI] Add EncodedImageBuffer sample Add sample to use EncodedImageBuffer. Signed-off-by: Eunki Hong --- diff --git a/test/Tizen.NUI.Samples/Tizen.NUI.Samples/Samples/EncodedImageSample.cs b/test/Tizen.NUI.Samples/Tizen.NUI.Samples/Samples/EncodedImageSample.cs new file mode 100755 index 0000000..4900772 --- /dev/null +++ b/test/Tizen.NUI.Samples/Tizen.NUI.Samples/Samples/EncodedImageSample.cs @@ -0,0 +1,50 @@ + +using Tizen.NUI.BaseComponents; +using Tizen.NUI.Components; + +namespace Tizen.NUI.Samples +{ + public class EncodedImageTest : IExample + { + Window win; + ImageView imageView; + + static public string DEMO_IMAGE_DIR = CommonResource.GetDaliResourcePath() + "DaliDemo/"; + + public void Activate() + { + win = NUIApplication.GetDefaultWindow(); + + EncodedImageBuffer buffer; + ImageUrl imageUrl; + + buffer = CreateEncodedImageBuffer(DEMO_IMAGE_DIR + "Logo-for-demo.png"); + + imageUrl = buffer?.GenerateUrl(); + + imageView = new ImageView() + { + WidthResizePolicy = ResizePolicyType.FillToParent, + HeightResizePolicy = ResizePolicyType.FillToParent, + + ResourceUrl = imageUrl?.ToString(), + }; + + win.GetDefaultLayer().Add(imageView); + } + + private EncodedImageBuffer CreateEncodedImageBuffer(string filename) + { + EncodedImageBuffer buffer = null; + global::System.IO.Stream stream = new global::System.IO.FileStream(filename, global::System.IO.FileMode.Open); + buffer = new EncodedImageBuffer(stream); + return buffer; + } + + public void Deactivate() + { + imageView?.Unparent(); + imageView?.Dispose(); + } + } +}