private static void PatchImageImz(Context context, AssetFile assetFile, Stream stream) { var index = 0; var images = Imgz.IsValid(stream) ? Imgz.Read(stream).ToList() : new List <Imgd>(); foreach (var source in assetFile.Source) { if (source.Index > 0) { index = source.Index; } var imd = CreateImageImd(context, source); if (images.Count <= index) { images.Add(imd); } else { images[index] = imd; } index++; } Imgz.Write(stream.SetPosition(0), images); }
public void IsValidTest() { using (var stream = new MemoryStream()) { stream.WriteByte(0x49); stream.WriteByte(0x4d); stream.WriteByte(0x47); stream.WriteByte(0x5a); stream.Position = 0; Assert.True(Imgz.IsValid(stream)); } }