mirror of
https://github.com/crskycode/GARbro.git
synced 2026-07-08 01:30:18 +08:00
IBinaryStream migration.
This commit is contained in:
@@ -87,9 +87,9 @@ namespace GameRes.Formats.Tactics
|
||||
var tarc = arc as TacticsArcFile;
|
||||
var tent = (PackedEntry)entry;
|
||||
if (null == tarc || null == tarc.Password && !tent.IsPacked)
|
||||
return arc.File.CreateStream (entry.Offset, entry.Size);
|
||||
return base.OpenEntry (arc, entry);
|
||||
if (null == tarc.Password)
|
||||
return new LzssStream (arc.File.CreateStream (entry.Offset, entry.Size));
|
||||
return new LzssStream (base.OpenEntry (arc, entry));
|
||||
|
||||
var data = arc.File.View.ReadBytes (entry.Offset, entry.Size);
|
||||
int p = 0;
|
||||
@@ -102,9 +102,9 @@ namespace GameRes.Formats.Tactics
|
||||
if (tarc.CustomLzss && tent.IsPacked)
|
||||
{
|
||||
data = UnpackCustomLzss (data);
|
||||
return new MemoryStream (data);
|
||||
return new BinMemoryStream (data, entry.Name);
|
||||
}
|
||||
Stream input = new MemoryStream (data);
|
||||
Stream input = new BinMemoryStream (data, entry.Name);
|
||||
if (tent.IsPacked)
|
||||
input = new LzssStream (input);
|
||||
return input;
|
||||
|
||||
@@ -53,16 +53,13 @@ namespace GameRes.Formats.Tactics
|
||||
throw new NotImplementedException ("TgfFormat.Write not implemented");
|
||||
}
|
||||
|
||||
public override ImageMetaData ReadMetaData (Stream stream)
|
||||
public override ImageMetaData ReadMetaData (IBinaryStream stream)
|
||||
{
|
||||
var header = new byte[8];
|
||||
if (header.Length != stream.Read (header, 0, header.Length))
|
||||
return null;
|
||||
uint length = LittleEndian.ToUInt32 (header, 0);
|
||||
int chunk_size = LittleEndian.ToInt32 (header, 4);
|
||||
uint length = stream.ReadUInt32();
|
||||
int chunk_size = stream.ReadInt32();
|
||||
if (length > 0xffffff || chunk_size <= 0 || length < chunk_size)
|
||||
return null;
|
||||
using (var reader = new Reader (stream, (uint)Math.Max (0x20, chunk_size+2), chunk_size))
|
||||
using (var reader = new Reader (stream.AsStream, (uint)Math.Max (0x20, chunk_size+2), chunk_size))
|
||||
{
|
||||
reader.Unpack();
|
||||
var bmp = reader.Data;
|
||||
@@ -79,14 +76,11 @@ namespace GameRes.Formats.Tactics
|
||||
}
|
||||
}
|
||||
|
||||
public override ImageData Read (Stream stream, ImageMetaData info)
|
||||
public override ImageData Read (IBinaryStream stream, ImageMetaData info)
|
||||
{
|
||||
var meta = info as TgfMetaData;
|
||||
if (null == meta)
|
||||
throw new ArgumentException ("TgfFormat.Read should be supplied with TgfMetaData", "info");
|
||||
|
||||
var meta = (TgfMetaData)info;
|
||||
stream.Position = 8;
|
||||
using (var reader = new Reader (stream, meta.BitmapSize, meta.ChunkSize))
|
||||
using (var reader = new Reader (stream.AsStream, meta.BitmapSize, meta.ChunkSize))
|
||||
{
|
||||
reader.Unpack();
|
||||
using (var bmp = new MemoryStream (reader.Data))
|
||||
|
||||
Reference in New Issue
Block a user