Ejemplo n.º 1
0
 /// <summary>
 /// Set the palette data from an external palette file.
 /// </summary>
 /// <param name="palette">A SvpPalette object</param>
 public void SetPalette(SvpPalette palette)
 {
     SetPalette((VpPalette)palette);
 }
Ejemplo n.º 2
0
        public static void Decode(string[] args)
        {
            string inPalettePath = Path.ChangeExtension(args[1], ".svp");
            string outPath = Path.ChangeExtension(args[1], ".png");

            // Get arguments
            for (int i = 2; i < args.Length; i++)
            {
                string arg = args[i].ToLower();

                // Change the output path
                if (arg == "-o" && args.Length > i + 1)
                {
                    outPath = args[i + 1];
                    i++;
                }

                // Palette path
                if (arg == "-p" && args.Length > i + 1)
                {
                    inPalettePath = args[i + 1];
                    i++;
                }
            }

            SvrTexture texture;

            // Initalize the texture
            try
            {
                texture = new SvrTexture(args[1]);
            }
            catch (NotAValidTextureException)
            {
                Console.WriteLine("Error: This is not a valid SVR texture.");
                return;
            }

            // Does this texture need an external palette file?
            if (texture.NeedsExternalPalette)
            {
                if (!File.Exists(inPalettePath))
                {
                    Console.WriteLine("Error: This texture requires an external palette file.");
                    return;
                }

                SvpPalette palette = new SvpPalette(inPalettePath);
                if (!palette.Initalized)
                {
                    Console.WriteLine("Error: {0} is not a valid SVR palette file.", inPalettePath);
                }

                texture.SetPalette(palette);
            }

            Console.WriteLine("Texture Information");
            Console.WriteLine("--------------------");
            Console.WriteLine("Format       : SVR");
            if (texture.HasGlobalIndex)
            {
                Console.WriteLine("Global Index : {0}", texture.GlobalIndex);
            }
            Console.WriteLine("Dimensions   : {0}x{1}", texture.TextureWidth, texture.TextureHeight);
            Console.WriteLine("Pixel Format : {0}", PixelFormatToString(texture.PixelFormat));
            Console.WriteLine("Data Format  : {0}", DataFormatToString(texture.DataFormat));

            // Decode the texture
            try
            {
                texture.Save(outPath);
            }
            catch (CannotDecodeTextureException)
            {
                Console.WriteLine("Error: Unable to decode this texture. The texture's pixel format or data format may not be supported.");
                return;
            }

            Console.WriteLine("\nTexture decoded successfully.");
        }
Ejemplo n.º 3
0
 /// <summary>
 /// Set the palette data from an external palette file.
 /// </summary>
 /// <param name="palette">A SvpPalette object</param>
 public void SetPalette(SvpPalette palette)
 {
     SetPalette((VpPalette)palette);
 }