コード例 #1
0
ファイル: UnitTest1.cs プロジェクト: mcraiha/CSharp-PVRTCgen
        public void GenerationTest()
        {
            // Arrange
            PvrtcGen.InitRandomSeed(1337 /* Magic value*/);
            int       width          = 256;
            int       height         = 256;
            PvrtcType pvrtcType      = PvrtcType.Transparent4bit;
            bool      generateHeader = true;

            byte[] pvrtcBytes = PvrtcGen.GeneratePvrtcByteArray(width, height, pvrtcType, generateHeader);

            // Act

            // Assert
            Assert.AreEqual(256 * 256 / 2 + 52, pvrtcBytes.Length);
        }
コード例 #2
0
ファイル: Program.cs プロジェクト: mcraiha/CSharp-PVRTCgen
        private static void RunTest()
        {
            // Generates output with following settings:
            PvrtcGen.InitRandomSeed(1337 /* Magic value*/);
            Program.width          = 256;
            Program.height         = 256;
            Program.pvrtcType      = PvrtcType.Transparent4bit;
            Program.generateHeader = true;

            byte[] pvrtcBytes = PvrtcGen.GeneratePvrtcByteArray(width, height, pvrtcType, generateHeader);

            // Write bytes to output stream
            using (Stream outputStream = Console.OpenStandardOutput())
            {
                outputStream.Write(pvrtcBytes, 0, pvrtcBytes.Length);
            }
        }
コード例 #3
0
ファイル: Program.cs プロジェクト: mcraiha/CSharp-PVRTCgen
        public static void Main(string[] args)
        {
            // Check that there is at least one paramater
            if (args.Length < 1)
            {
                Console.WriteLine("You have to give parameters! (use -help to show possible parameters)");
                return;
            }

            // Parse commandline/terminal commands, check simple options first
            Action simpleCommand = null;

            for (int i = 0; i < args.Length; i++)
            {
                // Check if simpleoptions includes the parameter
                if (simpleOptions.ContainsKey(args[i]))
                {
                    // Since it contains the parameter, do the simple command from it
                    simpleCommand = simpleOptions[args[i]].Item2;
                    break;
                }
            }

            if (simpleCommand != null)
            {
                // With simple command we just execute that command and exit out
                simpleCommand.Invoke();
                return;
            }

            // If there were no simple options, do more complex stuff next
            for (int i = 0; i < args.Length; i++)
            {
                // Check if normalOptions includes the parameter
                if (normalOptions.ContainsKey(args[i]))
                {
                    // Check that there is at least one more parameter
                    if (i < (args.Length - 1))
                    {
                        normalOptions[args[i]].Item2(args[i + 1]);
                    }
                    else
                    {
                        // Complain about missing parameter and exit
                        Console.WriteLine("Missing parameter for " + args[i]);
                        return;
                    }

                    // Check after every loop that given parameter was valid
                    if (errorInParsingParameters)
                    {
                        // Complain about error and exit
                        Console.WriteLine(lastError);
                        return;
                    }
                }
            }

            // Do actual generate since everything seems to be OK
            if (outputFilename != null)
            {
                byte[] pvrtcBytes = PvrtcGen.GeneratePvrtcByteArray(width, height, pvrtcType, generateHeader);

                // Write file if we have something to write
                if (pvrtcBytes != null)
                {
                    File.WriteAllBytes(outputFilename, pvrtcBytes);
                }
                else
                {
                    Console.WriteLine("Could not generate PVRTC data, most likely an incorrect resolution value");
                }
            }
            else
            {
                Console.WriteLine("Missing -file parameter");
            }
        }