From c5e90110be7869bbaa5c586f4854944bb00c80e7 Mon Sep 17 00:00:00 2001 From: morkt Date: Fri, 6 Jul 2018 15:36:50 +0400 Subject: [PATCH] (IAF): alternative RLE compression. --- ArcFormats/Triangle/ImageIAF.cs | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/ArcFormats/Triangle/ImageIAF.cs b/ArcFormats/Triangle/ImageIAF.cs index 1ed187ba..33d75bdc 100644 --- a/ArcFormats/Triangle/ImageIAF.cs +++ b/ArcFormats/Triangle/ImageIAF.cs @@ -161,7 +161,7 @@ namespace GameRes.Formats.Triangle { using (var reader = new RleReader (stream, packed_size, unpacked_size)) { - reader.Unpack(); + reader.UnpackV2(); return reader.Data; } } @@ -274,6 +274,21 @@ namespace GameRes.Formats.Triangle m_size = input_length; } + public void UnpackV2 () + { + int src = 0; + int dst = 0; + while (dst < m_output.Length && src < m_size) + { + byte b = m_input.ReadByte(); + int count = m_input.ReadByte(); + src += 2; + count = Math.Min (count, m_output.Length - dst); + for (int i = 0; i < count; i++) + m_output[dst++] = b; + } + } + public void Unpack () { int src = 0;