IBinaryStream migration.

This commit is contained in:
morkt
2016-10-16 09:22:53 +04:00
parent d0c1d5da01
commit bb18303eb4
251 changed files with 3277 additions and 3630 deletions

View File

@@ -37,21 +37,19 @@ namespace GameRes.Formats.Tama
public override string Description { get { return "TamaSoft ADV system audio"; } }
public override uint Signature { get { return 0x20445345; } } // 'ESD '
public override SoundInput TryOpen (Stream file)
public override SoundInput TryOpen (IBinaryStream file)
{
var header = new byte[0x20];
if (header.Length != file.Read (header, 0, header.Length))
return null;
var header = file.ReadHeader (0x20);
var format = new WaveFormat
{
FormatTag = 1,
Channels = LittleEndian.ToUInt16 (header, 0x10),
SamplesPerSecond = LittleEndian.ToUInt32 (header, 8),
BitsPerSample = LittleEndian.ToUInt16 (header, 0xC),
Channels = header.ToUInt16 (0x10),
SamplesPerSecond = header.ToUInt32 (8),
BitsPerSample = header.ToUInt16 (0xC),
};
format.BlockAlign = (ushort)(format.Channels * format.BitsPerSample / 8);
format.AverageBytesPerSecond = format.SamplesPerSecond * format.BlockAlign;
var pcm = new StreamRegion (file, 0x20);
var pcm = new StreamRegion (file.AsStream, 0x20);
return new RawPcmInput (pcm, format);
}
}

View File

@@ -25,7 +25,6 @@
using System.ComponentModel.Composition;
using System.IO;
using GameRes.Utility;
namespace GameRes.Formats.Tama
{
@@ -41,14 +40,13 @@ namespace GameRes.Formats.Tama
public override string Description { get { return "TamaSoft ADV system button image"; } }
public override uint Signature { get { return 0x4E544245; } } // 'EBTN'
public override ImageMetaData ReadMetaData (Stream stream)
public override ImageMetaData ReadMetaData (IBinaryStream stream)
{
var header = new byte[8];
if (header.Length != stream.Read (header, 0, 8))
return null;
int count = LittleEndian.ToInt32 (header, 4);
stream.Position = 4;
int count = stream.ReadInt32();
int offset = 0x30 + count * 4;
using (var input = new StreamRegion (stream, offset, true))
using (var data = new StreamRegion (stream.AsStream, offset, true))
using (var input = new BinaryStream (data, stream.Name))
{
var info = base.ReadMetaData (input);
if (null == info)
@@ -63,10 +61,11 @@ namespace GameRes.Formats.Tama
}
}
public override ImageData Read (Stream stream, ImageMetaData info)
public override ImageData Read (IBinaryStream stream, ImageMetaData info)
{
var meta = (BtnMetaData)info;
using (var input = new StreamRegion (stream, meta.SurOffset, true))
using (var data = new StreamRegion (stream.AsStream, meta.SurOffset, true))
using (var input = new BinaryStream (data, stream.Name))
return base.Read (input, info);
}

View File

@@ -38,24 +38,22 @@ namespace GameRes.Formats.Tama
public override string Description { get { return "TamaSoft ADV system image"; } }
public override uint Signature { get { return 0x52555345; } } // 'ESUR'
public override ImageMetaData ReadMetaData (Stream stream)
public override ImageMetaData ReadMetaData (IBinaryStream stream)
{
var header = new byte[0x10];
if (header.Length != stream.Read (header, 0, header.Length))
return null;
var header = stream.ReadHeader (0x10);
return new ImageMetaData
{
Width = LittleEndian.ToUInt32 (header, 8),
Height = LittleEndian.ToUInt32 (header, 12),
Width = header.ToUInt32 (8),
Height = header.ToUInt32 (12),
BPP = 32,
};
}
public override ImageData Read (Stream stream, ImageMetaData info)
public override ImageData Read (IBinaryStream stream, ImageMetaData info)
{
var pixels = new byte[info.Width * info.Height * 4];
stream.Position = 0x20;
UnpackLzss (stream, pixels);
UnpackLzss (stream.AsStream, pixels);
return ImageData.Create (info, PixelFormats.Bgra32, null, pixels);
}