Exemple #1
0
        public override SoundInput TryOpen(IBinaryStream file)
        {
            int first = file.ReadByte();

            if ((first ^ 0x21) != 0x78) // doesn't look like zlib stream
            {
                return(null);
            }
            file.Position = 0;
            using (var input = new XoredStream(file.AsStream, 0x21, true))
                using (var zstream = new ZLibStream(input, CompressionMode.Decompress))
                {
                    SoundInput sound = null;
                    var        wav   = new MemoryStream();
                    try
                    {
                        zstream.CopyTo(wav);
                        wav.Position = 0;
                        sound        = new WaveInput(wav);
                    }
                    finally
                    {
                        if (null == sound)
                        {
                            wav.Dispose();
                        }
                        else
                        {
                            file.Dispose();
                        }
                    }
                    return(sound);
                }
        }
Exemple #2
0
 public override ImageData Read(IBinaryStream stream, ImageMetaData info)
 {
     using (var input = new XoredStream(stream.AsStream, 0x21, true))
         using (var zstream = new ZLibStream(input, CompressionMode.Decompress))
             using (var bmp = new BinaryStream(zstream, stream.Name))
                 return(Bmp.Read(bmp, info));
 }
Exemple #3
0
        internal Stream CreatePmxStream(ArcView file)
        {
            Stream input = file.CreateStream();

            input = new XoredStream(input, 0x21);
            input = new ZLibStream(input, CompressionMode.Decompress);
            return(new SeekableStream(input));
        }
Exemple #4
0
        public override ImageMetaData ReadMetaData(Stream stream)
        {
            int first = stream.ReadByte() ^ 0x21;
            if (first != 0x78) // doesn't look like zlib stream
                return null;

            stream.Position = 0;
            using (var input = new XoredStream (stream, 0x21, true))
            using (var zstream = new ZLibStream (input, CompressionMode.Decompress))
                return base.ReadMetaData (zstream);
        }
Exemple #5
0
        public override ImageMetaData ReadMetaData(IBinaryStream stream)
        {
            int first = stream.PeekByte() ^ 0x21;

            if (first != 0x78) // doesn't look like zlib stream
            {
                return(null);
            }

            using (var input = new XoredStream(stream.AsStream, 0x21, true))
                using (var zstream = new ZLibStream(input, CompressionMode.Decompress))
                    using (var bmp = new BinaryStream(zstream, stream.Name))
                        return(Bmp.ReadMetaData(bmp));
        }
Exemple #6
0
        public override ImageMetaData ReadMetaData(Stream stream)
        {
            int first = stream.ReadByte() ^ 0x21;

            if (first != 0x78) // doesn't look like zlib stream
            {
                return(null);
            }

            stream.Position = 0;
            using (var input = new XoredStream(stream, 0x21, true))
                using (var zstream = new ZLibStream(input, CompressionMode.Decompress))
                    return(base.ReadMetaData(zstream));
        }
Exemple #7
0
 public override void Write(SoundInput source, Stream output)
 {
     using (var wav = new XoredStream(output, 0x21, true))
         using (var zstream = new ZLibStream(wav, CompressionMode.Compress, CompressionLevel.Level9))
             base.Write(source, zstream);
 }
Exemple #8
0
 public override void Write(Stream file, ImageData image)
 {
     using (var output = new XoredStream(file, 0x21, true))
         using (var zstream = new ZLibStream(output, CompressionMode.Compress, CompressionLevel.Level9))
             Bmp.Write(zstream, image);
 }
Exemple #9
0
 public override ImageData Read(Stream stream, ImageMetaData info)
 {
     using (var input = new XoredStream(stream, 0x21, true))
         using (var zstream = new ZLibStream(input, CompressionMode.Decompress))
             return(base.Read(zstream, info));
 }
Exemple #10
0
 public override void Write(Stream file, ImageData image)
 {
     using (var output = new XoredStream (file, 0x21, true))
     using (var zstream = new ZLibStream (output, CompressionMode.Compress, CompressionLevel.Level9))
         base.Write (zstream, image);
 }
Exemple #11
0
 public override ImageData Read(Stream stream, ImageMetaData info)
 {
     using (var input = new XoredStream (stream, 0x21, true))
     using (var zstream = new ZLibStream (input, CompressionMode.Decompress))
         return base.Read (zstream, info);
 }