コード例 #1
0
        public void Export(TextureFormat texture, MetadataWriter metadata, string directory, string basename)
        {
            PE3DATTexture dat = texture as PE3DATTexture;

            if (dat == null)
            {
                throw new TextureFormatException("Not a valid PE3 DAT texture!");
            }

            metadata.BeginSection("PE3DAT");
            metadata.PutAttribute("Textures", dat.FramesCount);
            metadata.PutAttribute("Basename", basename);

            int oldSelected = dat.SelectedFrame;

            for (int i = 0; i < dat.FramesCount; i++)
            {
                dat.SelectedFrame = i;

                metadata.BeginSection("PE3DATSegment");
                metadata.Put("Position1", dat.Position1);
                metadata.Put("Position2", dat.Position2);
                metadata.Put("Bpp", dat.Bpp);
                metadata.EndSection();

                dat.GetImage().Save(Path.Combine(directory, basename + "_" + i + ".png"));
            }
            dat.SelectedFrame = oldSelected;
            metadata.EndSection();
        }
コード例 #2
0
        public void Save(TextureFormat texture, System.IO.Stream outFormatData)
        {
            PE3DATTexture dat = texture as PE3DATTexture;

            if (dat == null)
            {
                throw new TextureFormatException("Not a valid PE3 DAT texture!");
            }
            BinaryWriter writer = new BinaryWriter(outFormatData);

            writer.Write((uint)dat.FramesCount);
            for (int i = 0; i < 3; i++)
            {
                writer.Write((uint)0);
            }

            int oldSelected = dat.SelectedFrame;

            for (int i = 0; i < dat.FramesCount; i++)
            {
                dat.SelectedFrame = i;
                writer.Write(dat.Position1);
                writer.Write((ushort)dat.Width);
                writer.Write((ushort)dat.Height);
                writer.Write(dat.Position2);
                writer.Write(dat.Bpp == 8 ? (uint)2 : (uint)1);
            }
            dat.SelectedFrame = oldSelected;

            IList <byte[]> imagesData   = dat.GetImagesData();
            IList <byte[]> palettesData = dat.GetPalettesData();

            for (int i = 0; i < dat.FramesCount; i++)
            {
                writer.Write(palettesData[i]);
                writer.Write(imagesData[i]);
            }
        }