mirror of
https://github.com/crskycode/GARbro.git
synced 2026-07-08 01:30:18 +08:00
IBinaryStream migration.
This commit is contained in:
@@ -272,7 +272,7 @@ namespace GameRes.Formats.Amaterasu
|
||||
uint WriteAmiEntry (PackedEntry entry, Stream output)
|
||||
{
|
||||
uint packed_size = 0;
|
||||
using (var input = File.OpenRead (entry.Name))
|
||||
using (var input = VFS.OpenBinaryStream (entry))
|
||||
{
|
||||
long file_size = input.Length;
|
||||
if (file_size > uint.MaxValue)
|
||||
@@ -284,7 +284,7 @@ namespace GameRes.Formats.Amaterasu
|
||||
}
|
||||
else
|
||||
{
|
||||
input.CopyTo (output);
|
||||
input.AsStream.CopyTo (output);
|
||||
}
|
||||
}
|
||||
return packed_size;
|
||||
@@ -293,19 +293,19 @@ namespace GameRes.Formats.Amaterasu
|
||||
static Lazy<GrpFormat> s_grp_format = new Lazy<GrpFormat> (() =>
|
||||
FormatCatalog.Instance.ImageFormats.OfType<GrpFormat>().FirstOrDefault());
|
||||
|
||||
uint WriteImageEntry (PackedEntry entry, Stream input, Stream output)
|
||||
uint WriteImageEntry (PackedEntry entry, IBinaryStream input, Stream output)
|
||||
{
|
||||
var grp = s_grp_format.Value;
|
||||
if (null == grp) // probably never happens
|
||||
throw new FileFormatException ("GRP image encoder not available");
|
||||
bool is_grp = grp.Signature == FormatCatalog.ReadSignature (input);
|
||||
bool is_grp = grp.Signature == input.Signature;
|
||||
input.Position = 0;
|
||||
var start = output.Position;
|
||||
using (var zstream = new ZLibStream (output, CompressionMode.Compress, CompressionLevel.Level9, true))
|
||||
{
|
||||
if (is_grp)
|
||||
{
|
||||
input.CopyTo (zstream);
|
||||
input.AsStream.CopyTo (zstream);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@@ -40,23 +40,19 @@ namespace GameRes.Formats.Amaterasu
|
||||
public override uint Signature { get { return 0x00505247; } } // 'GRP'
|
||||
public override bool CanWrite { get { return true; } }
|
||||
|
||||
public override ImageMetaData ReadMetaData (Stream stream)
|
||||
public override ImageMetaData ReadMetaData (IBinaryStream file)
|
||||
{
|
||||
using (var file = new BinaryReader (stream, Encoding.ASCII, true))
|
||||
{
|
||||
if (file.ReadUInt32() != Signature)
|
||||
return null;
|
||||
var meta = new ImageMetaData();
|
||||
meta.OffsetX = file.ReadInt16();
|
||||
meta.OffsetY = file.ReadInt16();
|
||||
meta.Width = file.ReadUInt16();
|
||||
meta.Height = file.ReadUInt16();
|
||||
meta.BPP = 32;
|
||||
return meta;
|
||||
}
|
||||
file.Position = 4;
|
||||
var meta = new ImageMetaData();
|
||||
meta.OffsetX = file.ReadInt16();
|
||||
meta.OffsetY = file.ReadInt16();
|
||||
meta.Width = file.ReadUInt16();
|
||||
meta.Height = file.ReadUInt16();
|
||||
meta.BPP = 32;
|
||||
return meta;
|
||||
}
|
||||
|
||||
public override ImageData Read (Stream file, ImageMetaData info)
|
||||
public override ImageData Read (IBinaryStream file, ImageMetaData info)
|
||||
{
|
||||
int width = (int)info.Width;
|
||||
int height = (int)info.Height;
|
||||
|
||||
Reference in New Issue
Block a user