Exemplo n.º 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);
                }
        }
Exemplo n.º 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));
 }
Exemplo n.º 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));
        }
Exemplo n.º 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);
        }
Exemplo n.º 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));
        }
Exemplo n.º 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));
        }
Exemplo n.º 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);
 }
Exemplo n.º 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);
 }
Exemplo n.º 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));
 }
Exemplo n.º 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);
 }
Exemplo n.º 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);
 }