Esempio n. 1
0
        public AIF(Stream input)
        {
            using (var br = new BinaryReaderX(input))
            {
                //Get dataOffset
                dataOffset             = 0;
                br.BaseStream.Position = 4;
                for (int i = 0; i < 4; i++)
                {
                    var size = br.ReadInt32();
                    dataOffset += size;
                    if (i == 0)
                    {
                        br.BaseStream.Position += 0x10;
                        dataOffset             += 0x10;
                    }
                    br.BaseStream.Position += size - 4;
                }

                //Get information
                texInfo = new TexInfo();
                br.BaseStream.Position = 0x30;
                texInfo.format         = br.ReadByte();
                br.BaseStream.Position = 0x38;
                texInfo.width          = br.ReadUInt16();
                texInfo.height         = br.ReadUInt16();
                br.BaseStream.Position = 0x4c;
                uint dataSize = br.ReadUInt32();
                br.BaseStream.Position = 0;
                header = br.ReadBytes(dataOffset);

                //Add Image
                br.BaseStream.Position = dataOffset;
                settings = new ImageSettings
                {
                    Width   = texInfo.width,
                    Height  = texInfo.height,
                    Format  = Support.Format[texInfo.format],
                    Swizzle = new AIFSwizzle(texInfo.width, texInfo.height)
                };
                bmps.Add(Kontract.Image.Common.Load(br.ReadBytes((int)dataSize), settings));
            }
        }
Esempio n. 2
0
        public AIF(Stream input)
        {
            using (var br = new BinaryReaderX(input))
            {
                //Get dataOffset
                dataOffset             = 0;
                br.BaseStream.Position = 4;
                for (int i = 0; i < 4; i++)
                {
                    var size = br.ReadInt32();
                    dataOffset += size;
                    if (i == 0)
                    {
                        br.BaseStream.Position += 0x10;
                        dataOffset             += 0x10;
                    }
                    br.BaseStream.Position += size - 4;
                }

                //Get information
                texInfo = new TexInfo();
                br.BaseStream.Position = 0x30;
                texInfo.format         = (Format)br.ReadByte();
                br.BaseStream.Position = 0x38;
                texInfo.width          = br.ReadUInt16();
                texInfo.height         = br.ReadUInt16();
                br.BaseStream.Position = 0x4c;
                uint dataSize = br.ReadUInt32();
                br.BaseStream.Position = 0;
                header = br.ReadBytes(dataOffset);

                //Add Image
                br.BaseStream.Position = dataOffset;
                var settings = new ImageSettings
                {
                    Width         = texInfo.width,
                    Height        = texInfo.height,
                    Format        = ImageSettings.ConvertFormat(texInfo.format),
                    PadToPowerOf2 = false
                };
                bmps.Add(Common.Load(br.ReadBytes((int)dataSize), settings));
            }
        }