public void Serialize(BinaryWriter writer)
 {
     overallHeader.Serialize(writer);
     sectionHeader.Serialize(writer);
     writer.Write(remainingTagCount);
     dataHeader.Serialize(writer);
 }
 public void Serialize(BinaryWriter writer)
 {
     sectionHead.Serialize(writer);
     writer.Write(tagCount);
     writer.Write(pixelWidth);
     writer.Write(pixelHeight);
     writer.Write(bitDepth);
     writer.Write(flags);
 }
        // Write tileset in Outpost 2's custom bitmap format.
        // To write tileset in standard bitmap format, use BitmapFile::WriteIndexed
        public static void WriteCustomTileset(Stream streamToWrite, BitmapFile tileset)
        {
            tileset = tileset.Clone();

            ValidateTileset(tileset);

            // OP2 Custom Tileset assumes a positive height and TopDown Scan Line (Contradicts Windows Bitmap File Format)
            if (tileset.GetScanLineOrientation() == ScanLineOrientation.BottomUp)
            {
                tileset.InvertScanLines();
            }
            uint absoluteHeight = (uint)tileset.AbsoluteHeight();

            SectionHeader fileSignature = new SectionHeader(TagFileSignature, CalculatePbmpSectionSize(absoluteHeight));
            TilesetHeader tilesetHeader = TilesetHeader.Create(absoluteHeight / TilesetHeader.DefaultPixelHeightMultiple);
            PpalHeader    ppalHeader    = PpalHeader.Create();

            SectionHeader paletteHeader = new SectionHeader(TilesetCommon.DefaultTagData, TilesetCommon.DefaultPaletteHeaderSize);

            SwapPaletteRedAndBlue(tileset.palette);

            SectionHeader pixelHeader = new SectionHeader(TilesetCommon.DefaultTagData, CalculatePixelHeaderLength(absoluteHeight));

            using (BinaryWriter writer = new BinaryWriter(streamToWrite, System.Text.Encoding.UTF8, true))
            {
                fileSignature.Serialize(writer);
                tilesetHeader.Serialize(writer);
                ppalHeader.Serialize(writer);
                paletteHeader.Serialize(writer);
                for (int i = 0; i < tileset.palette.Length; ++i)
                {
                    tileset.palette[i].Serialize(writer);
                }
                pixelHeader.Serialize(writer);
                writer.Write(tileset.pixels);
            }
        }
 public void Serialize(BinaryWriter writer)
 {
     ppal.Serialize(writer);
     head.Serialize(writer);
     writer.Write(tagCount);
 }