Exemple #1
0
 public static Palette256 FromArchive(string file, bool ignoreCase, DATArchive archive)
 {
     if (!archive.Contains(file, ignoreCase))
     {
         return((Palette256)null);
     }
     return(Palette256.FromRawData(archive.ExtractFile(file, ignoreCase)));
 }
Exemple #2
0
 public static EPFImage FromArchive(string file, bool ignoreCase, DATArchive archive)
 {
     if (!archive.Contains(file, ignoreCase))
     {
         return((EPFImage)null);
     }
     return(EPFImage.FromRawData(archive.ExtractFile(file, ignoreCase), file));
 }
Exemple #3
0
        /// <summary>
        /// Loads an EPF image file from an archive.
        /// </summary>
        /// <param name="file">EPF image to load.</param>
        /// <param name="ignoreCase">Ignore case (noncase-sensitive).</param>
        /// <param name="archive">Data archive to load from.</param>
        /// <returns>EPF image.</returns>
        public static EPFImage FromArchive(string file, bool ignoreCase, DATArchive archive)
        {
            // Check if File Exists
            if (!archive.Contains(file, ignoreCase))
            {
                return(null);
            }

            // Extract and Create File
            return(FromRawData(archive.ExtractFile(file, ignoreCase)));
        }
Exemple #4
0
        /// <summary>
        /// Loads a palette file from an archive (case-sensitive).
        /// </summary>
        /// <param name="file">Palette file to load.</param>
        /// <param name="archive">Data archive to load from.</param>
        /// <returns>256 color palette.</returns>
        public static Palette256 FromArchive(string file, DATArchive archive)
        {
            // Check if File Exists
            if (!archive.Contains(file))
            {
                return(null);
            }

            // Extract and Create File
            return(FromRawData(archive.ExtractFile(file)));
        }
Exemple #5
0
        /// <summary>
        /// Loads a tileset from an archive.
        /// </summary>
        /// <param name="file">Tileset to load.</param>
        /// <param name="ignoreCase">Ignore case (noncase-sensitive).</param>
        /// <param name="archive">Data archive to load from.</param>
        /// <returns>Number of tiles loaded.</returns>
        public static Tileset FromArchive(string file, bool ignoreCase, DATArchive archive)
        {
            // Check if File Exists
            if (!archive.Contains(file, ignoreCase))
            {
                return(null);
            }

            // Extract and Create File
            Tileset tileset = LoadTiles(new MemoryStream(archive.ExtractFile(file, ignoreCase)));

            tileset.name     = Path.GetFileNameWithoutExtension(file).ToUpper();
            tileset.filename = file;

            // Return Tileset
            return(tileset);
        }
Exemple #6
0
        public static SPFImage FromArchive(string file, DATArchive archive)
        {
            if (!archive.Contains(file))
            {
                return(null);
            }

            var stream = new MemoryStream(archive.ExtractFile(file));
            var reader = new BinaryReader(stream);

            var spf = new SPFImage();

            int unknown1 = reader.ReadInt32();
            int unknown2 = reader.ReadInt32();

            spf.colorFormat = reader.ReadInt32();

            if (spf.colorFormat == 0)
            {
                var    palette = new Palette256();
                byte[] alpha   = reader.ReadBytes(512);
                byte[] color   = reader.ReadBytes(512);
                for (int i = 0; i < 256; ++i)
                {
                    ushort val = BitConverter.ToUInt16(color, i * 2);
                    int    b   = 8 * ((int)val % 32);
                    int    g   = 8 * ((int)val / 32 % 32);
                    int    r   = 8 * ((int)val / 32 / 32 % 32);
                    palette[i] = Color.FromArgb(r, g, b);
                }
                spf.palette = palette;
            }

            spf.expectedFrames = reader.ReadInt32();
            spf.frames         = new SPFFrame[spf.expectedFrames];

            for (int i = 0; i < spf.expectedFrames; ++i)
            {
                int left         = reader.ReadInt16();
                int top          = reader.ReadInt16();
                int width        = reader.ReadInt16();
                int height       = reader.ReadInt16();
                int unknown3     = reader.ReadInt32();
                int unknown4     = reader.ReadInt32();
                int startAddress = reader.ReadInt32();
                int byteWidth    = reader.ReadInt32();
                int length       = reader.ReadInt32();
                int semiLength   = reader.ReadInt32();

                spf.frames[i] = new SPFFrame(left, top, width, height, startAddress, byteWidth, length, semiLength);
            }

            spf.length = reader.ReadInt32();

            for (int i = 0; i < spf.expectedFrames; ++i)
            {
                int    length = spf.frames[i].Length;
                byte[] data   = reader.ReadBytes(length);
                spf.frames[i].SetData(data);
            }

            reader.Close();

            return(spf);
        }