Ejemplo n.º 1
0
        private void Initialize()
        {
            mainWin = NUIApplication.GetDefaultWindow();
            mainWin.BackgroundColor = Color.White;
            Size2D windowSize = new Size2D(mainWin.Size.Width, mainWin.Size.Height);

            NativeImageSource source = new NativeImageSource((uint)windowSize.Width, (uint)windowSize.Height, NativeImageSource.ColorDepth.Default);
            var url = source.GenerateUrl();

            int  bufferWidth  = 0;
            int  bufferHeight = 0;
            int  bufferStride = 0;
            var  buffer       = source.AcquireBuffer(ref bufferWidth, ref bufferHeight, ref bufferStride);
            uint size         = (uint)bufferWidth * (uint)bufferHeight * 4;

            unsafe
            {
                byte *ptrData = (byte *)buffer.ToPointer();
                for (int i = 0; i < size; i += 4)
                {
                    ptrData[i]     = 0;
                    ptrData[i + 1] = 255;
                    ptrData[i + 2] = 0;
                    ptrData[i + 3] = 255;
                }
            }

            imageView        = new ImageView(url.ToString());
            imageView.Size2D = new Size2D(imageWidth, imageHeight);
            mainWin.Add(imageView);
        }
Ejemplo n.º 2
0
        public void NativeImageSourceGenerateUrl()
        {
            tlog.Debug(tag, $"NativeImageSourceGenerateUrl START");

            var testingTarget = new NativeImageSource(100, 50, NativeImageSource.ColorDepth.Bits16);

            Assert.IsNotNull(testingTarget, "Can't create success object NativeImageSource");
            Assert.IsInstanceOf <NativeImageSource>(testingTarget, "Should be an instance of NativeImageSource type.");

            var result = testingTarget.GenerateUrl();

            Assert.IsNotNull(result);

            testingTarget.Dispose();
            tlog.Debug(tag, $"NativeImageSourceGenerateUrl END (OK)");
        }