From 3a6f30f3166605123783c413100ceaf1cb7b07c4 Mon Sep 17 00:00:00 2001 From: morkt Date: Mon, 30 Nov 2015 03:50:03 +0400 Subject: [PATCH] use TgaStream.Create where appropriate. --- ArcFormats/AnimeGameSystem/ImageAinos.cs | 8 +------- ArcFormats/CatSystem/ArcHG3.cs | 13 ++----------- ArcFormats/ShiinaRio/ArcS25.cs | 11 +---------- 3 files changed, 4 insertions(+), 28 deletions(-) diff --git a/ArcFormats/AnimeGameSystem/ImageAinos.cs b/ArcFormats/AnimeGameSystem/ImageAinos.cs index 2a18b211..19beb0e3 100644 --- a/ArcFormats/AnimeGameSystem/ImageAinos.cs +++ b/ArcFormats/AnimeGameSystem/ImageAinos.cs @@ -175,13 +175,7 @@ namespace GameRes.Formats.Ags using (var reader = new CgFormat.Reader (input, info, key_frame)) { reader.Unpack(); - var header = new byte[0x12]; - header[2] = 2; - LittleEndian.Pack ((ushort)info.Width, header, 0xc); - LittleEndian.Pack ((ushort)info.Height, header, 0xe); - header[0x10] = 24; - header[0x11] = 0x20; - return new PrefixStream (header, new MemoryStream (reader.Data)); + return TgaStream.Create (info, reader.Data); } } diff --git a/ArcFormats/CatSystem/ArcHG3.cs b/ArcFormats/CatSystem/ArcHG3.cs index d5340882..fa9fa1b6 100644 --- a/ArcFormats/CatSystem/ArcHG3.cs +++ b/ArcFormats/CatSystem/ArcHG3.cs @@ -65,7 +65,7 @@ namespace GameRes.Formats.CatSystem offset += section_size; ++i; } - if (dir.Count < 2) + if (dir.Count < 1) return null; return new ArcFile (file, this, dir); } @@ -89,16 +89,7 @@ namespace GameRes.Formats.CatSystem using (var reader = new Hg3Reader (input, info)) { var pixels = reader.Unpack(); - var header = new byte[0x12]; - header[2] = 2; - LittleEndian.Pack ((short)info.OffsetX, header, 8); - LittleEndian.Pack ((short)info.OffsetY, header, 0xa); - LittleEndian.Pack ((ushort)info.Width, header, 0xc); - LittleEndian.Pack ((ushort)info.Height, header, 0xe); - header[0x10] = (byte)info.BPP; - if (!reader.Flipped) - header[0x11] = 0x20; - return new PrefixStream (header, new MemoryStream (pixels)); + return TgaStream.Create (info, pixels, reader.Flipped); } } } diff --git a/ArcFormats/ShiinaRio/ArcS25.cs b/ArcFormats/ShiinaRio/ArcS25.cs index fc022640..e0f96b73 100644 --- a/ArcFormats/ShiinaRio/ArcS25.cs +++ b/ArcFormats/ShiinaRio/ArcS25.cs @@ -96,16 +96,7 @@ namespace GameRes.Formats.ShiinaRio using (var input = arc.File.CreateStream (0, (uint)arc.File.MaxOffset)) using (var reader = new S25Format.Reader (input, info)) { - var pixels = reader.Unpack(); - var header = new byte[0x12]; - header[2] = 2; - LittleEndian.Pack ((short)info.OffsetX, header, 8); - LittleEndian.Pack ((short)info.OffsetY, header, 0xa); - LittleEndian.Pack ((ushort)info.Width, header, 0xc); - LittleEndian.Pack ((ushort)info.Height, header, 0xe); - header[0x10] = 32; - header[0x11] = 0x20; - return new PrefixStream (header, new MemoryStream (pixels)); + return TgaStream.Create (info, reader.Unpack()); } } }