Example #1
0
 public override void LoadData(BinaryReader reader, StructInstance instance)
 {
     var format = GetStringAttribute("format");
     ImageDecoder decoder = FindImageDecoder(instance, format);
     var image = decoder.Decode(reader.BaseStream, instance);
     instance.AddCell(new ImageCell(this, image, (int)reader.BaseStream.Position), false);
 }
Example #2
0
        public override void LoadData(BinaryReader reader, StructInstance instance)
        {
            int offset = (int)reader.BaseStream.Position;
            int len;
            try
            {
                len = GetExpressionAttribute("len").EvaluateInt(instance);
            }
            catch (OverflowException)
            {
                throw new LoadDataException("Blob size is larger than Int32");
            }
            if (offset + len > reader.BaseStream.Length)
                throw new LoadDataException("Blob size " + len + " exceeds stream length");
            if (len < 0)
                throw new LoadDataException("Blob size " + len + " is negative");
            var decodedSizeExpr = GetExpressionAttribute("decodedsize");
            int decodedSize = decodedSizeExpr != null ? decodedSizeExpr.EvaluateInt(instance) : -1;
            string encoding = GetStringAttribute("encoding");
            BlobDecoder blobDecoder = FindBlobEncoding(instance, encoding);
            BlobCell cell = new BlobCell(this, reader.BaseStream, offset, len, blobDecoder, decodedSize);
            instance.AddCell(cell, _hidden);
            instance.RegisterCellSize(cell, len);
            reader.BaseStream.Position += len;

            StructDef structDef = GetStructAttribute("struct");
            if (structDef != null)
                instance.AddChildSeed(new BlobChildSeed(structDef, cell));
        }
Example #3
0
        public override void LoadData(BinaryReader reader, StructInstance instance)
        {
            var          format  = GetStringAttribute("format");
            ImageDecoder decoder = FindImageDecoder(instance, format);
            var          image   = decoder.Decode(reader.BaseStream, instance);

            instance.AddCell(new ImageCell(this, image, (int)reader.BaseStream.Position), false);
        }
Example #4
0
        public override void LoadData(BinaryReader reader, StructInstance instance)
        {
            int offset = (int)reader.BaseStream.Position;
            int len;

            try
            {
                len = GetExpressionAttribute("len").EvaluateInt(instance);
            }
            catch (OverflowException)
            {
                throw new LoadDataException("Blob size is larger than Int32");
            }
            if (offset + len > reader.BaseStream.Length)
            {
                throw new LoadDataException("Blob size " + len + " exceeds stream length");
            }
            if (len < 0)
            {
                throw new LoadDataException("Blob size " + len + " is negative");
            }
            var decodedSizeExpr = GetExpressionAttribute("decodedsize");
            int decodedSize     = decodedSizeExpr != null?decodedSizeExpr.EvaluateInt(instance) : -1;

            string      encoding    = GetStringAttribute("encoding");
            BlobDecoder blobDecoder = FindBlobEncoding(instance, encoding);
            BlobCell    cell        = new BlobCell(this, reader.BaseStream, offset, len, blobDecoder, decodedSize);

            instance.AddCell(cell, _hidden);
            instance.RegisterCellSize(cell, len);
            reader.BaseStream.Position += len;

            StructDef structDef = GetStructAttribute("struct");

            if (structDef != null)
            {
                instance.AddChildSeed(new BlobChildSeed(structDef, cell));
            }
        }