1 #region Copyright & License Information 2 /* 3 * Copyright 2007-2020 The OpenRA Developers (see AUTHORS) 4 * This file is part of OpenRA, which is free software. It is made 5 * available to you under the terms of the GNU General Public License 6 * as published by the Free Software Foundation, either version 3 of 7 * the License, or (at your option) any later version. For more 8 * information, see COPYING. 9 */ 10 #endregion 11 12 namespace OpenRA.Mods.Common.FileFormats 13 { 14 // Run length encoded sequences of zeros (aka Format2) 15 public static class RLEZerosCompression 16 { DecodeInto(byte[] src, byte[] dest, int destIndex)17 public static void DecodeInto(byte[] src, byte[] dest, int destIndex) 18 { 19 var r = new FastByteReader(src); 20 21 while (!r.Done()) 22 { 23 var cmd = r.ReadByte(); 24 if (cmd == 0) 25 { 26 var count = r.ReadByte(); 27 while (count-- > 0) 28 dest[destIndex++] = 0; 29 } 30 else 31 dest[destIndex++] = cmd; 32 } 33 } 34 } 35 } 36