From a84eb4165a7ab719c90009412e8caf4c294fe7bd Mon Sep 17 00:00:00 2001 From: Eunki Hong Date: Sun, 29 Jan 2023 16:49:13 +0900 Subject: [PATCH] [NUI] Add EncodedImageBuffer sample Add sample to use EncodedImageBuffer. Signed-off-by: Eunki Hong --- .../Samples/EncodedImageSample.cs | 50 ++++++++++++++++++++++ 1 file changed, 50 insertions(+) create mode 100755 test/Tizen.NUI.Samples/Tizen.NUI.Samples/Samples/EncodedImageSample.cs 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(); + } + } +} -- 2.7.4