Example #1
0
        public static PaletteFile ParseFromData(byte[] data)
        {
            if (data.Length % 2 != 0)
            {
                throw new ArgumentException($"Palette has invalid length of {data.Length} -- must be even number");
            }

            PaletteFile paletteFile = new PaletteFile();

            paletteFile.LoadColors(data);

            return(paletteFile);
        }
        private void TplToRiffPaletteButton_Click(object sender, RoutedEventArgs e)
        {
            OpenFileDialog openFileDialog = new OpenFileDialog
            {
                Filter = "Decompressed TPL File|*.TPL.decompressed"
            };

            if (openFileDialog.ShowDialog() == true)
            {
                var            tileFile       = PaletteFile.ParseFromFile(openFileDialog.FileName);
                SaveFileDialog saveFileDialog = new SaveFileDialog
                {
                    Filter = "RIFF Palette File|*.pal"
                };
                if (saveFileDialog.ShowDialog() == true)
                {
                    tileFile.WriteRiffPaletteFile(saveFileDialog.FileName);
                }
            }
        }