Exemplo n.º 1
0
        private static void CompressDXT(TextureContent content)
        {
            var texData = content.Faces[0][0];

            if (!IsPowerOfTwo(texData.Width) || !IsPowerOfTwo(texData.Height))
            {
                throw new PipelineException("DXT Compressed textures width and height must be powers of two.");
            }

            var _dxtCompressor = new Compressor();
            var inputOptions   = new InputOptions();

            inputOptions.SetAlphaMode(AlphaMode.Transparency);
            inputOptions.SetTextureLayout(TextureType.Texture2D, texData.Width, texData.Height, 1);

            var pixelData = texData.GetPixelData();

            // Small hack here. NVTT wants 8bit data in BGRA. Flip the B and R channels
            // again here.
            GraphicsUtil.BGRAtoRGBA(pixelData);
            var dataHandle = GCHandle.Alloc(pixelData, GCHandleType.Pinned);
            var dataPtr    = dataHandle.AddrOfPinnedObject();

            inputOptions.SetMipmapData(dataPtr, texData.Width, texData.Height, 1, 0, 0);
            inputOptions.SetMipmapGeneration(false);

            var containsFracAlpha = ContainsFractionalAlpha(pixelData);
            var outputOptions     = new OutputOptions();

            outputOptions.SetOutputHeader(false);

            var outputFormat = containsFracAlpha ? Format.DXT5 : Format.DXT1;

            var handler = new DXTDataHandler(content, outputFormat);

            outputOptions.SetOutputHandler(handler.BeginImage, handler.WriteData);

            var compressionOptions = new CompressionOptions();

            compressionOptions.SetFormat(outputFormat);

            _dxtCompressor.Compress(inputOptions, compressionOptions, outputOptions);

            dataHandle.Free();
        }
        private void ValidateInputOptions(InputOptions _inputOptions)
        {
            var validationResults = new InputOptionsValidator().Validate(_inputOptions);

            if (validationResults.IsValid)
            {
                return;
            }

            foreach (var error in validationResults.Errors)
            {
                _commandLineAccess.WriteToConsole(error.ErrorMessage, _messages.Types.Failure);
            }

            _commandLineAccess.WriteToConsole(_messages.Stages.Argument.Failure, _messages.Types.Error);

            throw new InvalidOperationException(_messages.Stages.Argument.Failure);
        }
Exemplo n.º 3
0
        public bool RenameLoadout(LoadoutViewModel loadoutViewModel)
        {
            var inputOptions = new InputOptions
            {
                WindowTitle        = $"Rename skill loadout",
                WindowPrompt       = $"Rename skill loadout '{loadoutViewModel.Name}'",
                WindowDefaultValue = loadoutViewModel.Name,
                IsInputMandatory   = true,
                IsValid            = x => Loadouts.Where(l => l != loadoutViewModel).All(l => l.Name != x)
            };

            if (InputUtils.Show(inputOptions, out string newName))
            {
                loadoutViewModel.Name = newName;
                return(true);
            }

            return(false);
        }
        public void DevOpsAccess_GetTestCasesWorkItems_EmptyWorkItems()
        {
            // Arrange
            var testManagementHttpClient   = new Mock <TestManagementHttpClient>(new Uri("http://dummy.url"), new VssCredentials());
            var workItemTrackingHttpClient = new Mock <WorkItemTrackingHttpClient>(new Uri("http://dummy.url"), new VssCredentials());

            var outputAccess = new Mock <IOutputAccess>();
            var messages     = new Messages();

            const int    testPlanId  = 51;
            const string projectName = "projectNameWithNoTestPlans";

            var options = new InputOptions()
            {
                ValidationOnly = true,
                VerboseLogging = true,
                ProjectName    = projectName,
                TestPlanId     = testPlanId
            };
            var counter = new Counter();

            testManagementHttpClient
            .Setup(x => x.GetPointsAsync(It.IsAny <string>(), It.IsAny <int>(), It.IsAny <int>(), null, null, null, null, null, null, null, null, default))
            .ReturnsAsync(new List <TestPoint>());

            var azureDevOpsHttpClients = new AzureDevOpsHttpClients()
            {
                TestManagementHttpClient   = testManagementHttpClient.Object,
                WorkItemTrackingHttpClient = workItemTrackingHttpClient.Object
            };

            var target = new DevOpsAccessFactory(azureDevOpsHttpClients, messages, outputAccess.Object, options, counter).Create();

            // Act
            var actual = target.GetTestCaseWorkItems();

            // Assert
            actual.Length.Should().Be(0);
        }
        public void DevOpsAccess_ListDuplicateTestCases_NotEmptyDuplicateTestCases()
        {
            // Arrange
            var testManagementHttpClient   = new Mock <TestManagementHttpClient>(new Uri("http://dummy.url"), new VssCredentials());
            var workItemTrackingHttpClient = new Mock <WorkItemTrackingHttpClient>(new Uri("http://dummy.url"), new VssCredentials());

            var outputAccess = new Mock <IOutputAccess>();
            var messages     = new Messages();

            var fixture   = new Fixture();
            var testCases = new List <TestCase>();
            var testCasesToBeDuplicated = fixture.Create <TestCase[]>();

            testCases.AddRange(testCasesToBeDuplicated);
            testCases.AddRange(testCasesToBeDuplicated);

            var options = new InputOptions()
            {
                ValidationOnly = true,
                VerboseLogging = true
            };
            var counter = new Counter();

            var azureDevOpsHttpClients = new AzureDevOpsHttpClients()
            {
                TestManagementHttpClient   = testManagementHttpClient.Object,
                WorkItemTrackingHttpClient = workItemTrackingHttpClient.Object
            };

            var target = new DevOpsAccessFactory(azureDevOpsHttpClients, messages, outputAccess.Object, options, counter).Create();

            // Act
            var actual = target.ListDuplicateTestCases(testCases.ToArray());

            // Assert
            actual.Count.Should().Be(testCases.Count / 2);
        }
Exemplo n.º 6
0
        /// <summary>
        ///     Converts an RGBAImage object into a byte array that can be loaded into a texture.
        /// </summary>
        /// <param name="image">The Imgae object to convert.</param>
        /// <param name="format">The resulting texture format/compression.</param>
        /// <param name="mipmaps">Whether to generate mipmaps for the texture.</param>
        /// <returns>
        ///     A byte array that can be loaded into a Unity Texture2D.
        /// </returns>
        public static byte[] ImageToTexture(RGBAImage image, TextureCompressionFormat format = TextureCompressionFormat.DXT5, bool mipmaps = true)
        {
            // Retrieve the raw pixel data from the image.
            byte[] srcBytes = new byte[image.Size];
            image.CopyRawData(srcBytes);

            /*
             * Allocate a handle for the pixel data so that it doesn't get garbage collected.
             * This will allow a the pixel array to be reprsented as an pointer so that it
             * can be used by the Nvidia Texture Tools.
             */
            GCHandle pinnedArray = GCHandle.Alloc(srcBytes, GCHandleType.Pinned);
            IntPtr   srcBytesPtr = pinnedArray.AddrOfPinnedObject();

            /*
             * Initialize an array to store the generated data with a size of zero. The array
             * will be resized as needed. A wrapper is used so that the array can be resized
             * within the lambda callback expression in the OutputOptions.
             */
            BytesWrapper destBytes = new BytesWrapper()
            {
                Bytes = new byte[0]
            };

            InputOptions       inputOptions       = GenerateInputOptions(srcBytesPtr, image.Width, image.Height, mipmaps);
            CompressionOptions compressionOptions = GenerateCompressionOptions(format);
            OutputOptions      outputOptions      = GenerateOutputOptions(destBytes);

            Compressor compressor = new Compressor();

            compressor.Compress(inputOptions, compressionOptions, outputOptions);

            // Free the allocated handle so that it be garbage collected.
            pinnedArray.Free();

            return(destBytes.Bytes);
        }
        public void DevOpsAccess_Associate_TestCaseIsNull()
        {
            // Arrange
            var testManagementHttpClient   = new Mock <TestManagementHttpClient>(new Uri("http://dummy.url"), new VssCredentials());
            var workItemTrackingHttpClient = new Mock <WorkItemTrackingHttpClient>(new Uri("http://dummy.url"), new VssCredentials());

            var outputAccess = new Mock <IOutputAccess>();

            var fixture     = new Fixture();
            var messages    = new Messages();
            var testCases   = fixture.Create <TestCase[]>();
            var testMethods = fixture.Create <TestMethod[]>();

            var options = new InputOptions()
            {
                ValidationOnly = true,
                VerboseLogging = true
            };
            var counter = new Counter();

            var azureDevOpsHttpClients = new AzureDevOpsHttpClients()
            {
                TestManagementHttpClient   = testManagementHttpClient.Object,
                WorkItemTrackingHttpClient = workItemTrackingHttpClient.Object
            };

            var target = new DevOpsAccessFactory(azureDevOpsHttpClients, messages, outputAccess.Object, options, counter).Create();

            // Act
            var errorCount = target.Associate(testMethods, testCases.ToDictionary(v => v.Title, t => t));

            // Assert
            errorCount.Should().Be(testMethods.Length);
            counter.Error.Total.Should().Be(testMethods.Length);
            counter.Error.TestCaseNotFound.Should().Be(testMethods.Length);
            outputAccess.Verify(x => x.WriteToConsole(It.IsAny <string>(), It.IsAny <string>(), It.IsAny <string>()), Times.Exactly(testMethods.Length));
        }
Exemplo n.º 8
0
        /// <summary>
        /// Sends the specified text to be spoken to the TTS service and saves the response audio to a file.
        /// </summary>
        /// <param name="cancellationToken">The cancellation token.</param>
        /// <returns>A Task</returns>
        public async Task <Stream> Speak(CancellationToken cancellationToken, InputOptions inputOptions, string mes)
        {
            client.DefaultRequestHeaders.Clear();
            foreach (var header in inputOptions.Headers)
            {
                client.DefaultRequestHeaders.TryAddWithoutValidation(header.Key, header.Value);
            }

            var genderValue = "";

            switch (inputOptions.VoiceType)
            {
            case Gender.Male:
                genderValue = "Male";
                break;

            case Gender.Female:
            default:
                genderValue = "Female";
                break;
            }

            var request = new HttpRequestMessage(HttpMethod.Post, inputOptions.RequestUri)
            {
                //此处修改为自定义语音库
                Content = new StringContent(/*GenerateSsml(inputOptions.Locale, genderValue, inputOptions.VoiceName, inputOptions.Text, inputOptions.PitchDelta)*/ personalVoice(mes))
            };

            var httpMsg = await client.SendAsync(request, HttpCompletionOption.ResponseContentRead, cancellationToken);

            Debug.Log($"Response status code: [{httpMsg.StatusCode}]");

            Stream httpStream = await httpMsg.Content.ReadAsStreamAsync();

            return(httpStream);
        }
        public void DevOpsAccess_ListTestCasesWithNotAvailableTestMethods_EmptyListTestCasesWithNotAvailableTestMethodsWhereAutomationStatusIsNotEqualToAutomatedName()
        {
            // Arrange
            var testManagementHttpClient   = new Mock <TestManagementHttpClient>(new Uri("http://dummy.url"), new VssCredentials());
            var workItemTrackingHttpClient = new Mock <WorkItemTrackingHttpClient>(new Uri("http://dummy.url"), new VssCredentials());

            var outputAccess = new Mock <IOutputAccess>();

            var fixture  = new Fixture();
            var messages = new Messages();

            fixture.Customize <TestCase>(c => c.With(x => x.AutomationStatus, NotAutomatedName));
            var testCases   = fixture.Create <TestCase[]>();
            var testMethods = fixture.Create <TestMethod[]>();

            var options = new InputOptions()
            {
                ValidationOnly = true,
                VerboseLogging = true
            };
            var counter = new Counter();

            var azureDevOpsHttpClients = new AzureDevOpsHttpClients()
            {
                TestManagementHttpClient   = testManagementHttpClient.Object,
                WorkItemTrackingHttpClient = workItemTrackingHttpClient.Object
            };

            var target = new DevOpsAccessFactory(azureDevOpsHttpClients, messages, outputAccess.Object, options, counter).Create();

            // Act
            var actual = target.ListTestCasesWithNotAvailableTestMethods(testMethods, testCases);

            // Assert
            actual.Count.Should().Be(0);
        }
Exemplo n.º 10
0
 public static HtmlString FormControl(this IHtmlHelper html, Dictionary <string, object> inputAttrs, string tagName, InputOptions inputOptions) =>
 ViewUtils.FormControl(html.GetRequest(), inputAttrs, tagName, inputOptions).ToHtmlString();
Exemplo n.º 11
0
 public static HtmlString FormInput(this IHtmlHelper html, Dictionary <string, object> inputAttrs, InputOptions inputOptions) =>
 FormControl(html, inputAttrs, "input", inputOptions);
Exemplo n.º 12
0
 public static HtmlString FormInput(this IHtmlHelper html, object inputAttrs, InputOptions inputOptions) =>
 FormControl(html, inputAttrs.ToObjectDictionary(), "input", inputOptions);
Exemplo n.º 13
0
 public static HtmlString FormTextarea(this HtmlHelper html, object inputAttrs, InputOptions inputOptions) =>
 FormControl(html, inputAttrs.ToObjectDictionary(), "textarea", inputOptions);
Exemplo n.º 14
0
 /// <summary>
 /// Initializes a new instance of the <see cref="Synthesize"/> class.
 /// </summary>
 /// <param name="input">The input.</param>
 public Synthesize(InputOptions input)
 {
     this.inputOptions = input;
 }
Exemplo n.º 15
0
 /// <summary>
 /// Create a new console options
 /// </summary>
 /// <param name="renderOptions">Rendering options</param>
 /// <param name="inputOptions">Input handling options</param>
 /// <param name="position">Position of the console</param>
 /// <param name="size">Size of the window</param>
 public ConsoleOptions(RenderOptions renderOptions, InputOptions inputOptions, int textSpacing, Point?position, Size?size)
 {
     TextSpacing   = textSpacing;
     RenderOptions = renderOptions;
     Container     = new Rectangle(position ?? Point.Empty, size ?? Size.Empty);
 }
Exemplo n.º 16
0
 public int EstimateSize(InputOptions input, CompressionOptions compression)
 {
     return(nvttEstimateSize(compressor, input.options, compression.options));
 }
Exemplo n.º 17
0
        protected override bool TryCopyFrom(BitmapContent sourceBitmap, Rectangle sourceRegion, Rectangle destinationRegion)
        {
            if (!sourceBitmap.TryGetFormat(out SurfaceFormat sourceFormat))
            {
                return(false);
            }

            TryGetFormat(out SurfaceFormat format);

            // A shortcut for copying the entire bitmap to another bitmap of the same type and format
            if (format == sourceFormat &&
                sourceRegion == new Rectangle(0, 0, Width, Height) &&
                sourceRegion == destinationRegion)
            {
                SetPixelData(sourceBitmap.GetPixelData());
                return(true);
            }

            // TODO: Add a XNA unit test to see what it does
            // my guess is that this is invalid for DXT.
            //
            // Destination region copy is not yet supported
            if (destinationRegion != new Rectangle(0, 0, Width, Height))
            {
                return(false);
            }

            if (sourceBitmap is PixelBitmapContent <RgbaVector> &&
                sourceRegion.Width == destinationRegion.Width &&
                sourceRegion.Height == destinationRegion.Height)
            {
                // NVTT wants 8bit data in BGRA format.
                var colorBitmap = new PixelBitmapContent <Bgra32>(sourceBitmap.Width, sourceBitmap.Height);
                Copy(sourceBitmap, colorBitmap);
                var sourceData = colorBitmap.GetPixelData();

                AlphaMode alphaMode;
                Format    outputFormat;
                bool      alphaDither = false;
                switch (format)
                {
                case SurfaceFormat.Dxt1:
                case SurfaceFormat.Dxt1SRgb:
                {
                    PrepareNVTT_DXT1(sourceData, out bool hasTransparency);
                    outputFormat = hasTransparency ? Format.DXT1a : Format.DXT1;
                    alphaMode    = hasTransparency ? AlphaMode.Transparency : AlphaMode.None;
                    alphaDither  = true;
                    break;
                }

                case SurfaceFormat.Dxt3:
                case SurfaceFormat.Dxt3SRgb:
                {
                    //PrepareNVTT(sourceData);
                    outputFormat = Format.DXT3;
                    alphaMode    = AlphaMode.Transparency;
                    break;
                }

                case SurfaceFormat.Dxt5:
                case SurfaceFormat.Dxt5SRgb:
                {
                    //PrepareNVTT(sourceData);
                    outputFormat = Format.DXT5;
                    alphaMode    = AlphaMode.Transparency;
                    break;
                }

                default:
                    throw new InvalidOperationException("Invalid DXT surface format!");
                }

                // Do all the calls to the NVTT wrapper within this handler
                // so we properly clean up if things blow up.
                var dataHandle = GCHandle.Alloc(sourceData, GCHandleType.Pinned);
                try
                {
                    var dataPtr = dataHandle.AddrOfPinnedObject();

                    var inputOptions = new InputOptions();
                    inputOptions.SetTextureLayout(TextureType.Texture2D, colorBitmap.Width, colorBitmap.Height, 1);
                    inputOptions.SetMipmapData(dataPtr, colorBitmap.Width, colorBitmap.Height, 1, 0, 0);
                    inputOptions.SetMipmapGeneration(false);
                    inputOptions.SetGamma(1.0f, 1.0f);
                    inputOptions.SetAlphaMode(alphaMode);

                    var compressionOptions = new CompressionOptions();
                    compressionOptions.SetFormat(outputFormat);
                    compressionOptions.SetQuality(Quality.Normal);

                    // TODO: This isn't working which keeps us from getting the
                    // same alpha dither behavior on DXT1 as XNA.
                    //
                    // See https://github.com/MonoGame/MonoGame/issues/6259
                    //
                    //if (alphaDither)
                    //compressionOptions.SetQuantization(false, false, true);

                    var outputOptions = new OutputOptions();
                    outputOptions.SetOutputHeader(false);
                    outputOptions.SetOutputOptionsOutputHandler(NvttBeginImage, NvttWriteImage, NvttEndImage);

                    var dxtCompressor = new Compressor();
                    dxtCompressor.Compress(inputOptions, compressionOptions, outputOptions);
                }
                finally
                {
                    dataHandle.Free();
                }
                return(true);
            }

            try
            {
                Copy(sourceBitmap, sourceRegion, this, destinationRegion);
                return(true);
            }
            catch (InvalidOperationException)
            {
                return(false);
            }
        }
Exemplo n.º 18
0
        public static unsafe bool Compress(this Texture2DInfo tex, TextureFormat format)
        {
            var data = tex.RawData;
            int width = tex.Width, height = tex.Height, pos, outPos;

            switch (format)
            {
            case TextureFormat.Alpha8:
            {
                pos = 0; outPos = 0;
                var out_ = new byte[width * height];

                fixed(byte *pOut = out_, pData = data)
                for (var y = 0; y < height; y++)
                {
                    for (var x = 0; x < width; x++)
                    {
                        var fR = pData[pos];
                        var fG = pData[pos + 1];
                        var fB = pData[pos + 2];
                        var fA = pData[pos + 3];
                        pOut[outPos] = (byte)(((fR + fB + fG) / 3) & 0XFF);
                        pos         += 4;
                        outPos      += 1;
                    }
                }
                tex.RawData = out_;

                return(true);
            }

            case TextureFormat.ARGB4444:
            case TextureFormat.RGB565:
            {
                pos = 0; outPos = 0;
                using (var pvrTexture = PVRTexture.CreateTexture(data, (uint)width, (uint)height, 1, PixelFormat.RGBA8888, true, VariableType.UnsignedByte, ColourSpace.sRGB))
                {
                    var doDither = true;
                    pvrTexture.Transcode(PixelFormat.RGBA4444, VariableType.UnsignedByte, ColourSpace.sRGB, format == TextureFormat.ARGB4444 ? CompressorQuality.PVRTCNormal : CompressorQuality.ETCMedium, doDither);
                    var texDataSize = pvrTexture.GetTextureDataSize(0);
                    var out_        = new byte[texDataSize];
                    pvrTexture.GetTextureData(out_, texDataSize);
                    if (format == TextureFormat.RGB565)
                    {
                        var data2 = out_;
                        out_ = new byte[texDataSize];

                        fixed(byte *pOut = out_, pData = data2)
                        for (var y = 0; y < height; y++)
                        {
                            for (var x = 0; x < width; x++)
                            {
                                var v0 = pData[pos];
                                var v1 = pData[pos + 1];
                                // 4bit little endian {A, B},{G, R}
                                var sA = v0 & 0xF0 >> 4;
                                var sB = (v0 & 0xF0) >> 4;
                                var sG = v1 & 0xF0 >> 4;
                                var sR = (v1 & 0xF0) >> 4;
                                // swap to little endian {B, G, R, A }
                                var fB = sB & 0xf;
                                var fG = sG & 0xf;
                                var fR = sR & 0xf;
                                var fA = sA & 0xf;
                                pOut[outPos]     = (byte)((fG << 4) + fB);
                                pOut[outPos + 1] = (byte)((fA << 4) + fR);
                                pos    += 2;
                                outPos += 2;
                            }
                        }
                    }
                    tex.RawData = out_;
                    return(true);
                }
            }

            case TextureFormat.RGB24:
            {
                pos = 0; outPos = 0;
                var out_ = new byte[width * height * 3];

                fixed(byte *pOut = out_, pData = data)
                for (var y = 0; y < height; y++)
                {
                    for (var x = 0; x < width; x++)
                    {
                        // 4bit little endian {A, B},{G, R}
                        var fR = pData[pos];
                        var fG = pData[pos + 1];
                        var fB = pData[pos + 2];
                        var fA = pData[pos + 3];
                        pOut[outPos]     = fR;
                        pOut[outPos + 1] = fG;
                        pOut[outPos + 2] = fB;
                        pos    += 4;
                        outPos += 3;
                    }
                }
                tex.RawData = out_;

                return(true);
            }

            case TextureFormat.RGBA32:
                return(true);

            case TextureFormat.ARGB32:
            {
                pos = 0; outPos = 0;
                var out_ = new byte[width * height * 4];

                fixed(byte *pOut = out_, pData = data)
                for (var y = 0; y < height; y++)
                {
                    for (var x = 0; x < width; x++)
                    {
                        var fA = pData[pos];
                        var fR = pData[pos + 1];
                        var fG = pData[pos + 2];
                        var fB = pData[pos + 3];
                        out_[outPos]     = fR;
                        out_[outPos + 1] = fG;
                        out_[outPos + 2] = fB;
                        out_[outPos + 3] = fA;
                        pos    += 4;
                        outPos += 4;
                    }
                }
                tex.RawData = out_;

                return(true);
            }

            //case TextureFormat.ATC_RGBA8:
            //case TextureFormat.ATC_RGB4:
            case TextureFormat.ETC2_RGBA8:
            case TextureFormat.ETC_RGB4:
                TextureConverterWrapper.CompressionFormat format2;
                switch (format)
                {
                //case TextureFormat.ATC_RGBA8: format2 = TextureConverterWrapper.CompressionFormat.AtcRgbaExplicitAlpha; break;
                //case TextureFormat.ATC_RGB4: format2 = TextureConverterWrapper.CompressionFormat.AtcRgb; break;
                case TextureFormat.ETC2_RGBA8: format2 = TextureConverterWrapper.CompressionFormat.Etc2Rgba; break;

                case TextureFormat.ETC_RGB4: format2 = TextureConverterWrapper.CompressionFormat.Etc1; break;

                default: throw new ArgumentOutOfRangeException(nameof(format), format.ToString());
                }
                tex.RawData = TextureConverterWrapper.Compress(data, width, height, format2);
                return(true);

            case TextureFormat.DXT1:
            case TextureFormat.DXT5:
            {
                var dxtCompressor = new Compressor();
                var inputOptions  = new InputOptions();
                inputOptions.SetAlphaMode(format == TextureFormat.DXT1 ? AlphaMode.None : AlphaMode.Premultiplied);
                inputOptions.SetTextureLayout(TextureType.Texture2D, width, height, 1);
                fixed(byte *pData = data)
                for (var x = 0; x < data.Length; x += 4)
                {
                    pData[x]     ^= pData[x + 2];
                    pData[x + 2] ^= pData[x];
                    pData[x]     ^= pData[x + 2];
                }

                var dataHandle = GCHandle.Alloc(data, GCHandleType.Pinned);
                try
                {
                    var dataPtr = dataHandle.AddrOfPinnedObject();
                    inputOptions.SetMipmapData(dataPtr, width, height, 1, 0, 0);
                    inputOptions.SetMipmapGeneration(false);
                    inputOptions.SetGamma(1.0f, 1.0f);
                    var compressionOptions = new CompressionOptions();
                    compressionOptions.SetFormat(format == TextureFormat.DXT1 ? Nvidia.TextureTools.Format.DXT1 : Nvidia.TextureTools.Format.DXT5);
                    compressionOptions.SetQuality(Quality.Normal);
                    var outputOptions = new OutputOptions();
                    outputOptions.SetOutputHeader(false);
                    var out_ = new byte[0];
                    using (var handler = new DxtDataHandler(out_, outputOptions))
                    {
                        dxtCompressor.Compress(inputOptions, compressionOptions, outputOptions);
                        out_ = handler.dst;
                    }
                    tex.RawData = out_;
                    return(true);
                }
                finally { dataHandle.Free(); }
            }

            case TextureFormat.ASTC_RGBA_4x4:
            case TextureFormat.ASTC_RGB_4x4:
                AstcencWrapper.EncodeASTC(data, width, height, 4, 4, out tex.RawData);
                return(true);

            default: throw new ArgumentOutOfRangeException(nameof(format), format.ToString());
            }
        }
Exemplo n.º 19
0
        public InputForm(InputOptions options)
        {
            _defaultValue = Optional <T> .Create(options.DefaultValue);

            _options = options;
        }
Exemplo n.º 20
0
 public PBuildTool()
 {
     Options         = new InputOptions();
     CurrentSolution = new PSolutionInfo();
 }
Exemplo n.º 21
0
 internal ControllerStateMapper(InputOptions inputOptions)
 {
     _inputOptions = inputOptions;
 }
Exemplo n.º 22
0
 public bool Compress(InputOptions input, CompressionOptions compression, OutputOptions output)
 {
     return(nvttCompress(compressor, input.options, compression.options, output.options));
 }
Exemplo n.º 23
0
        /// <summary>
        /// Sends the specified text to be spoken to the TTS service and saves the response audio to a file.
        /// </summary>
        /// <param name="cancellationToken">The cancellation token.</param>
        /// <returns>A Task</returns>
        public Task Speak(CancellationToken cancellationToken, InputOptions inputOptions)
        {
            client.DefaultRequestHeaders.Clear();
            foreach (var header in inputOptions.Headers)
            {
                client.DefaultRequestHeaders.TryAddWithoutValidation(header.Key, header.Value);
            }

            var genderValue = "";

            switch (inputOptions.VoiceType)
            {
            case Gender.Male:
                genderValue = "Male";
                break;

            case Gender.Female:
            default:
                genderValue = "Female";
                break;
            }

            var request = new HttpRequestMessage(HttpMethod.Post, inputOptions.RequestUri)
            {
                Content = new StringContent(GenerateSsml(inputOptions.Locale, genderValue, inputOptions.VoiceName, inputOptions.Text))
            };

            var httpTask = client.SendAsync(request, HttpCompletionOption.ResponseHeadersRead, cancellationToken);

            Console.WriteLine("Response status code: [{0}]", httpTask.Result.StatusCode);

            var saveTask = httpTask.ContinueWith(
                async(responseMessage, token) =>
            {
                try
                {
                    if (responseMessage.IsCompleted && responseMessage.Result != null && responseMessage.Result.IsSuccessStatusCode)
                    {
                        var httpStream = await responseMessage.Result.Content.ReadAsStreamAsync().ConfigureAwait(false);
                        this.AudioAvailable(new GenericEventArgs <Stream>(httpStream));
                    }
                    else
                    {
                        this.Error(new GenericEventArgs <Exception>(new Exception(String.Format("Service returned {0}", responseMessage.Result.StatusCode))));
                    }
                }
                catch (Exception e)
                {
                    this.Error(new GenericEventArgs <Exception>(e.GetBaseException()));
                }
                finally
                {
                    responseMessage.Dispose();
                    request.Dispose();
                }
            },
                TaskContinuationOptions.AttachedToParent,
                cancellationToken);

            return(saveTask);
        }
Exemplo n.º 24
0
 /// <summary>
 /// Create a new console options
 /// </summary>
 /// <param name="renderOptions">Rendering options</param>
 /// <param name="inputOptions">Input handling options</param>
 public ConsoleOptions(RenderOptions renderOptions, InputOptions inputOptions) : this(renderOptions, inputOptions, _defaultTextSpacing, null, null)
 {
 }
Exemplo n.º 25
0
 public Options(HardwareOptions hardwareOptions, GraphicsOptions graphicsOptions, InputOptions inputOptions)
 {
     HardwareOptions = hardwareOptions;
     Graphics        = graphicsOptions;
     Input           = inputOptions;
 }
        public void DevOpsAccess_GetTestCaseWorkItems_NotEmptyTestCaseWorkItems()
        {
            // Arrange
            var testManagementHttpClient   = new Mock <TestManagementHttpClient>(new Uri("http://dummy.url"), new VssCredentials());
            var workItemTrackingHttpClient = new Mock <WorkItemTrackingHttpClient>(new Uri("http://dummy.url"), new VssCredentials());

            var outputAccess = new Mock <IOutputAccess>();
            var messages     = new Messages();

            var fixture    = new Fixture();
            var testPoints = new List <TestPoint>()
            {
                fixture.Build <TestPoint>()
                .Without(x => x.LastUpdatedBy)
                .Without(x => x.AssignedTo)
                .Without(x => x.LastResultDetails)
                .With(x => x.TestCase, fixture.Build <WorkItemReference>().With(y => y.Id, fixture.Create <int>().ToString()).Create())
                .Create(),
                fixture.Build <TestPoint>()
                .Without(x => x.LastUpdatedBy)
                .Without(x => x.AssignedTo)
                .Without(x => x.LastResultDetails)
                .With(x => x.TestCase, fixture.Build <WorkItemReference>().With(y => y.Id, fixture.Create <int>().ToString()).Create())
                .Create(),
                fixture.Build <TestPoint>()
                .Without(x => x.LastUpdatedBy)
                .Without(x => x.AssignedTo)
                .Without(x => x.LastResultDetails)
                .With(x => x.TestCase, fixture.Build <WorkItemReference>().With(y => y.Id, fixture.Create <int>().ToString()).Create())
                .Create()
            };
            var workItems = new List <WorkItem>()
            {
                fixture.Build <WorkItem>().With(x => x.Id, fixture.Create <int>())
                .With(y => y.Fields, new Dictionary <string, object>()
                {
                    { SystemTitle, fixture.Create <string>() }, { AutomationStatusName, fixture.Create <string>() }, { AutomatedTestName, fixture.Create <string>() }
                })
                .Create(),
                fixture.Build <WorkItem>()
                .With(x => x.Id, fixture.Create <int>())
                .With(y => y.Fields, new Dictionary <string, object>()
                {
                    { SystemTitle, fixture.Create <string>() }, { AutomationStatusName, fixture.Create <string>() }, { AutomatedTestName, fixture.Create <string>() }
                })
                .Create(),
                fixture.Build <WorkItem>()
                .With(x => x.Id, fixture.Create <int>())
                .With(y => y.Fields, new Dictionary <string, object>()
                {
                    { SystemTitle, fixture.Create <string>() }, { AutomationStatusName, fixture.Create <string>() }, { AutomatedTestName, fixture.Create <string>() }
                })
                .Create(),
            };

            var options = new InputOptions()
            {
                ValidationOnly = true,
                VerboseLogging = true
            };
            var counter = new Counter();

            testManagementHttpClient
            .Setup(x => x.GetPointsAsync(It.IsAny <string>(), It.IsAny <int>(), It.IsAny <int>(), null, null, null, null, null, null, null, null, default))
            .ReturnsAsync(testPoints);
            workItemTrackingHttpClient
            .Setup(x => x.GetWorkItemsAsync(It.IsAny <int[]>(), null, null, null, null, null, default))
            .ReturnsAsync(workItems);

            var azureDevOpsHttpClients = new AzureDevOpsHttpClients()
            {
                TestManagementHttpClient   = testManagementHttpClient.Object,
                WorkItemTrackingHttpClient = workItemTrackingHttpClient.Object
            };

            var target = new DevOpsAccessFactory(azureDevOpsHttpClients, messages, outputAccess.Object, options, counter).Create();

            // Act
            var actual = target.GetTestCaseWorkItems();

            // Assert
            actual.Length.Should().Be(3);
        }
Exemplo n.º 27
0
 public Options(GraphicsOptions graphicsOptions, InputOptions inputOptions)
 {
     Graphics = graphicsOptions;
     Input    = inputOptions;
 }
Exemplo n.º 28
0
 /// <summary>
 /// Initializes a new instance of the <see cref="Synthesize"/> class.
 /// </summary>
 /// <param name="input">The input.</param>
 public Synthesize(InputOptions input)
 {
     this.inputOptions = input;
 }
Exemplo n.º 29
0
    private void ImportTexture(string name, TextureProcessingSettings settings)
    {
        string destinationPath = Path.Combine(destinationFolder.FullName, name + ".dds");

        if (new FileInfo(destinationPath).Exists)
        {
            return;
        }

        Console.WriteLine($"importing texture '{name}'...");

        using (var image = UnmanagedRgbaImage.Load(settings.File))  {
            using (var dilator = new TextureDilator(device, shaderCache)) {
                dilator.Dilate(settings.Mask, image.Size, settings.IsLinear, image.DataBox);
            }

            InputOptions input = new InputOptions();
            input.SetFormat(InputFormat.BGRA_8UB);
            input.SetTextureLayout(TextureType.Texture2D, image.Size.Width, image.Size.Height, 1);
            float gamma = settings.IsLinear ? 1f : 2.2f;
            input.SetGamma(gamma, gamma);
            input.SetMipmapData(image.PixelData, image.Size.Width, image.Size.Height, 1, 0, 0);
            input.SetAlphaMode(AlphaMode.None);

            input.SetMipmapGeneration(true);
            input.SetMipmapFilter(MipmapFilter.Kaiser);
            input.SetKaiserParameters(3, 4, 1);

            if (settings.Type == TextureProcessingType.Bump)
            {
                input.SetConvertToNormalMap(true);
                input.SetNormalFilter(1, 0, 0, 0);
                input.SetHeightEvaluation(1, 1, 1, 0);
            }
            else if (settings.Type == TextureProcessingType.Normal)
            {
                input.SetNormalMap(true);
            }

            CompressionOptions compression = new CompressionOptions();
            compression.SetQuality(Quality.Highest);
            compression.SetFormat(Format.RGBA);

            OutputOptions output = new OutputOptions();
            destinationFolder.CreateWithParents();
            output.SetFileName(destinationPath);
            output.SetContainer(Container.Container_DDS10);
            output.SetSrgbFlag(!settings.IsLinear);

            var  compressor = new Compressor();
            bool succeeded  = compressor.Compress(input, compression, output);
            if (!succeeded)
            {
                throw new InvalidOperationException("texture conversion failed");
            }

            //force the previous output handler to be destructed so that the file is flushed and closed
            output.SetFileName("nul");

            if (compress)
            {
                CompressTexture(new FileInfo(destinationPath), settings.Type, settings.IsLinear);
            }
        }
    }
        public AzureDevOpsAccess(AzureDevOpsHttpClients azureDevOpsHttpClients, Messages messages, IOutputAccess outputAccess, InputOptions options, Counter.Counter counter)
        {
            _azureDevOpsHttpClients = azureDevOpsHttpClients;

            _messages     = messages;
            _outputAccess = outputAccess;

            _inputOptions = options;
            _counter      = counter;
        }
Exemplo n.º 31
0
        static void Main(string[] args)
        {
            AppDomain.CurrentDomain.UnhandledException += (sender, e) =>
            {
                Console.WriteLine(e.ExceptionObject);
            };

            PrintNameVersionAndCopyright();

            using (var consoleIconSwapper = new ConsoleIconSwapper())
            {
                consoleIconSwapper.ShowConsoleIcon(CoreResources.FavIcon);

                try
                {
                    var options = new ArgOptions(args);

                    if (options.ShowHelp)
                    {
                        ArgOptions.ShowHelpMessage(Console.Out, options);
                        return;
                    }

                    if (!options.XapPaths.Any() && !options.Dlls.Any())
                    {
                        throw new StatLightException("No xap or silverlight dll's specified.");
                    }

                    var inputOptions = new InputOptions()
                                       .SetWindowGeometry(options.WindowGeometry)
                                       .SetUseRemoteTestPage(options.UseRemoteTestPage)
                                       .SetMethodsToTest(options.MethodsToTest)
                                       .SetMicrosoftTestingFrameworkVersion(options.MicrosoftTestingFrameworkVersion)
                                       .SetTagFilters(options.TagFilters)
                                       .SetUnitTestProviderType(options.UnitTestProviderType)
                                       .SetNumberOfBrowserHosts(options.NumberOfBrowserHosts)
                                       .SetQueryString(options.QueryString)
                                       .SetWebBrowserType(options.WebBrowserType)
                                       .SetForceBrowserStart(options.ForceBrowserStart)
                                       .SetXapPaths(options.XapPaths)
                                       .SetDllPaths(options.Dlls)
                                       .SetReportOutputPath(options.XmlReportOutputPath)
                                       .SetReportOutputFileType(options.ReportOutputFileType)
                                       .SetContinuousIntegrationMode(options.ContinuousIntegrationMode)
                                       .SetOutputForTeamCity(options.OutputForTeamCity)
                                       .SetStartWebServerOnly(options.StartWebServerOnly)
                                       .SetIsRequestingDebug(options.IsRequestingDebug)
                    ;

                    TestReportCollection testReports = null;

                    try
                    {
                        TinyIoCContainer ioc = BootStrapper.Initialize(inputOptions);

                        var commandLineExecutionEngine = ioc.Resolve <RunnerExecutionEngine>();

                        testReports = commandLineExecutionEngine.Run();
                    }
                    catch (TinyIoCResolutionException tinyIoCResolutionException)
                    {
                        if (options.IsRequestingDebug)
                        {
                            throw;
                        }

                        throw ResolveNonTinyIocException(tinyIoCResolutionException);
                    }

                    if (testReports.FinalResult == RunCompletedState.Failure)
                    {
                        Environment.ExitCode = ExitFailed;
                    }
                    else
                    {
                        Environment.ExitCode = ExitSucceeded;
                    }
                }
                catch (AddressAccessDeniedException addressAccessDeniedException)
                {
                    Environment.ExitCode = ExitFailed;
                    var helpMessage = @"
Cannot run StatLight. The current account does not have the correct privilages.

Exception:
{0}

Try: (the following two steps that should allow StatLight to start a web server on the requested port)
     1. Run cmd.exe as Administrator.
     2. Enter the following command in the command prompt.
          netsh http add urlacl url=http://+:8887/ user=DOMAIN\user
".FormatWith(addressAccessDeniedException.Message);

                    WriteErrorToConsole(helpMessage, "Error");
                }
                catch (FileNotFoundException fileNotFoundException)
                {
                    HandleKnownError(fileNotFoundException);
                }
                catch (StatLightException statLightException)
                {
                    HandleKnownError(statLightException);
                }

                catch (Exception exception)
                {
                    HandleUnknownError(exception);
                }
            }
        }