Example #1
0
        static WZProperty Canvas(WZReader reader, WZProperty self)
        {
            // Define the variables ahead of time that way we can come back to them
            int  width = 0, height = 0, format1 = 0, format2 = 0;
            uint blockLen = 0, position = 0;

            // Define what well be doing once we come back
            WZProperty result = new WZPropertyWeak <Image <Rgba32> >(
                () => {
                using (reader = self.FileContainer.GetContentReader(null, self))
                {
                    reader.BaseStream.Seek(position + 1, SeekOrigin.Begin);
                    ushort header = reader.PeekFor(() => reader.ReadUInt16());
                    return(reader.ParsePNG(
                               width,
                               height,
                               format1 + format2,
                               header != 0x9C78 && header != 0xDA78,
                               blockLen - 1
                               ));
                }
            }, self
                );

            reader.BaseStream.Seek(1, SeekOrigin.Current);
            if (reader.ReadByte() == 1) // Has children
            {
                reader.BaseStream.Seek(2, SeekOrigin.Current);
                result.Children = PropertyList(reader, result).ToArray();
            }
            else
            {
                result.Children = new WZProperty[0];
            }
            width   = reader.ReadWZInt(); // width
            height  = reader.ReadWZInt(); // height
            format1 = reader.ReadWZInt(); // format 1
            format2 = reader.ReadByte();  // format 2
            reader.BaseStream.Seek(4, SeekOrigin.Current);
            blockLen    = (uint)reader.ReadInt32();
            result.Size = (uint)blockLen;
            position    = (uint)reader.BaseStream.Position;

            return(result);
        }
Example #2
0
        public static WZProperty Audio(WZReader reader, WZProperty self)
        {
            byte unk      = reader.ReadByte();
            int  length   = reader.ReadWZInt();
            int  duration = reader.ReadWZInt();

            WZProperty result = new WZPropertyWeak <byte[]>(
                () => {
                Package.Logging($"{self.Path} (Audio) - {unk}");
                using (reader = self.FileContainer.GetContentReader(null, self))
                {
                    reader.BaseStream.Seek(self.Offset + 1, SeekOrigin.Begin);
                    if (length > sbyte.MaxValue || length <= sbyte.MinValue)
                    {
                        reader.BaseStream.Seek(5, SeekOrigin.Current);
                    }
                    else
                    {
                        reader.BaseStream.Seek(1, SeekOrigin.Current);
                    }
                    if (duration > sbyte.MaxValue || duration <= sbyte.MinValue)
                    {
                        reader.BaseStream.Seek(5, SeekOrigin.Current);
                    }
                    else
                    {
                        reader.BaseStream.Seek(1, SeekOrigin.Current);
                    }
                    return(reader.ReadBytes(length));
                }
            }, self
                );

            result.Size = (uint)length;
            result.Meta.Add("duration", duration);
            result.Meta.Add("unk", unk);

            return(result);
        }