Exemple #1
0
 public override ImageData Read(Stream stream, ImageMetaData info)
 {
     var meta = (EencMetaData)info;
     meta.Info.FileName = info.FileName;
     Stream input = new StreamRegion (stream, 8, true);
     try
     {
         input = new EencStream (input, meta.Key);
         if (meta.Compressed)
             input = new ZLibStream (input, CompressionMode.Decompress);
         return meta.Format.Read (input, meta.Info);
     }
     finally
     {
         input.Dispose();
     }
 }
Exemple #2
0
        public override ImageMetaData ReadMetaData(IBinaryStream stream)
        {
            var    header     = stream.ReadHeader(8);
            bool   compressed = 'Z' == header[3];
            uint   key        = header.ToUInt32(4) ^ EencKey;
            Stream input      = new StreamRegion(stream.AsStream, 8, true);

            try
            {
                input = new EencStream(input, key);
                if (compressed)
                {
                    input = new ZLibStream(input, CompressionMode.Decompress);
                    input = new SeekableStream(input);
                }
                using (var bin = new BinaryStream(input, stream.Name, true))
                {
                    var format = FindFormat(bin);
                    if (null == format)
                    {
                        return(null);
                    }
                    return(new EencMetaData
                    {
                        Width = format.Item2.Width,
                        Height = format.Item2.Height,
                        BPP = format.Item2.BPP,
                        Key = key,
                        Info = format.Item2,
                        Format = format.Item1,
                        Compressed = compressed,
                    });
                }
            }
            finally
            {
                input.Dispose();
            }
        }
Exemple #3
0
        public override ImageData Read(IBinaryStream stream, ImageMetaData info)
        {
            var meta = (EencMetaData)info;

            meta.Info.FileName = info.FileName;
            Stream input = new StreamRegion(stream.AsStream, 8, true);

            try
            {
                input = new EencStream(input, meta.Key);
                if (meta.Compressed)
                {
                    input = new ZLibStream(input, CompressionMode.Decompress);
                }
                using (var bin = new BinaryStream(input, stream.Name, true))
                    return(meta.Format.Read(bin, meta.Info));
            }
            finally
            {
                input.Dispose();
            }
        }
Exemple #4
0
 public override ImageMetaData ReadMetaData(Stream stream)
 {
     var header = new byte[8];
     if (8 != stream.Read (header, 0, 8))
         return null;
     bool compressed = 'Z' == header[3];
     uint key = LittleEndian.ToUInt32 (header, 4) ^ EencKey;
     Stream input = new StreamRegion (stream, 8, true);
     try
     {
         input = new EencStream (input, key);
         if (compressed)
         {
             input = new ZLibStream (input, CompressionMode.Decompress);
             input = new SeekableStream (input);
         }
         var format = FindFormat (input);
         if (null == format)
             return null;
         return new EencMetaData
         {
             Width = format.Item2.Width,
             Height = format.Item2.Height,
             BPP = format.Item2.BPP,
             Key = key,
             Info = format.Item2,
             Format = format.Item1,
             Compressed = compressed,
         };
     }
     finally
     {
         input.Dispose();
     }
 }