コード例 #1
0
ファイル: ArtFile.cs プロジェクト: TechCor8/OP2UtilityDotNet
        // 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);
            }
        }
コード例 #2
0
        public OP2BmpLoader(string bmpFilename, string artFilename)
        {
            FileStream fs = new FileStream(bmpFilename, FileMode.Open, FileAccess.Read, FileShare.Read);

            bmpReader = new BinaryReader(fs);

            artFile = ArtFile.Read(artFilename);
        }
コード例 #3
0
        public OP2BmpLoader(string bmpFilename, ArtFile artFile)
        {
            FileStream fs = new FileStream(bmpFilename, FileMode.Open, FileAccess.Read, FileShare.Read);

            bmpReader = new BinaryReader(fs);

            this.artFile = artFile;
        }
コード例 #4
0
ファイル: ArtFile.cs プロジェクト: TechCor8/OP2UtilityDotNet
        public static ArtFile Read(BinaryReader reader)
        {
            ArtFile artFile = new ArtFile();

            ReadPalette(reader, artFile);
            ReadImageMetadata(reader, artFile);
            ReadAnimations(reader, artFile);

            return(artFile);
        }
コード例 #5
0
ファイル: ArtFile.cs プロジェクト: TechCor8/OP2UtilityDotNet
        private static void ReadImageMetadata(BinaryReader reader, ArtFile artFile)
        {
            artFile.imageMetas.Clear();

            uint imageMetasCount = reader.ReadUInt32();

            for (int i = 0; i < imageMetasCount; ++i)
            {
                artFile.imageMetas.Add(new ImageMeta(reader));
            }

            artFile.ValidateImageMetadata();
        }
コード例 #6
0
ファイル: ArtFile.cs プロジェクト: TechCor8/OP2UtilityDotNet
        private static void ReadAnimations(BinaryReader reader, ArtFile artFile)
        {
            uint animationCount = reader.ReadUInt32();

            artFile.animations = new List <Animation>((int)animationCount);

            uint frameCount = reader.ReadUInt32();
            uint layerCount = reader.ReadUInt32();

            artFile.unknownAnimationCount = reader.ReadUInt32();

            for (uint i = 0; i < animationCount; ++i)
            {
                artFile.animations.Add(ReadAnimation(reader));
            }

            VerifyCountsMatchHeader(artFile, (int)frameCount, (int)layerCount, (int)artFile.unknownAnimationCount);
        }
コード例 #7
0
ファイル: ArtFile.cs プロジェクト: TechCor8/OP2UtilityDotNet
        private static void VerifyCountsMatchHeader(ArtFile artFile, int frameCount, int layerCount, int unknownCount)
        {
            int  actualFrameCount;
            int  actualLayerCount;
            uint actualUnknownCount;

            artFile.CountFrames(out actualFrameCount, out actualLayerCount, out actualUnknownCount);

            if (actualFrameCount != frameCount)
            {
                throw new System.Exception("Frame count does not match");
            }

            if (actualLayerCount != layerCount)
            {
                throw new System.Exception("Sub-frame count does not match.");
            }

            if (actualUnknownCount != unknownCount)
            {
                throw new System.Exception("Unknown count does not match.");
            }
        }