Exemplo n.º 1
0
        // Read Functions
        private static void ReadPalette(BinaryReader reader, ArtFile artFile)
        {
            SectionHeader paletteSectionHeader = new SectionHeader(reader);

            paletteSectionHeader.Validate(TagPalette);

            artFile.palettes = new List <Palette>((int)paletteSectionHeader.length);

            for (int i = 0; i < paletteSectionHeader.length; ++i)
            {
                PaletteHeader paletteHeader = new PaletteHeader(reader);

                paletteHeader.Validate();

                Palette palette = new Palette(reader);

                // Rearrange color into standard format. Outpost 2 uses custom color order.
                for (int j = 0; j < palette.colors.Length; ++j)
                {
                    byte temp = palette.colors[j].red;
                    palette.colors[j].red  = palette.colors[j].blue;
                    palette.colors[j].blue = temp;
                }

                artFile.palettes.Add(palette);
            }
        }
Exemplo n.º 2
0
        public void Validate()
        {
            overallHeader.Validate(TagSection);
            sectionHeader.Validate(TagHeader);
            dataHeader.Validate(TagData);

            if (overallHeader.length != SectionHeader.SizeInBytes + sectionHeader.TotalLength() + sizeof(uint) + dataHeader.TotalLength())
            {
                throw new System.Exception("Lengths defined in palette headers do not match.");
            }
        }