using System; using System.IO; using Hjg.Pngcs.Zlib; namespace Hjg.Pngcs.Chunks { // Token: 0x02000005 RID: 5 public class ChunkRaw { // Token: 0x06000025 RID: 37 RVA: 0x000025C0 File Offset: 0x000007C0 internal ChunkRaw(int length, byte[] idbytes, bool alloc) { this.IdBytes = new byte[4]; this.Data = null; this.crcval = 0; this.Length = length; Array.Copy(idbytes, 0, this.IdBytes, 0, 4); if (alloc) { this.AllocData(); } } // Token: 0x06000026 RID: 38 RVA: 0x0000260C File Offset: 0x0000080C private int ComputeCrc() { CRC32 crc = PngHelperInternal.GetCRC(); crc.Reset(); crc.Update(this.IdBytes, 0, 4); if (this.Length > 0) { crc.Update(this.Data, 0, this.Length); } return (int)crc.GetValue(); } // Token: 0x06000027 RID: 39 RVA: 0x00002658 File Offset: 0x00000858 internal void WriteChunk(Stream os) { if (this.IdBytes.Length != 4) { throw new PngjOutputException("bad chunkid [" + ChunkHelper.ToString(this.IdBytes) + "]"); } this.crcval = this.ComputeCrc(); PngHelperInternal.WriteInt4(os, this.Length); PngHelperInternal.WriteBytes(os, this.IdBytes); if (this.Length > 0) { PngHelperInternal.WriteBytes(os, this.Data, 0, this.Length); } PngHelperInternal.WriteInt4(os, this.crcval); } // Token: 0x06000028 RID: 40 RVA: 0x000026DC File Offset: 0x000008DC internal int ReadChunkData(Stream stream, bool checkCrc) { PngHelperInternal.ReadBytes(stream, this.Data, 0, this.Length); this.crcval = PngHelperInternal.ReadInt4(stream); if (checkCrc) { int num = this.ComputeCrc(); if (num != this.crcval) { throw new PngjBadCrcException(string.Concat(new object[] { "crc invalid for chunk ", this.ToString(), " calc=", num, " read=", this.crcval })); } } return this.Length + 4; } // Token: 0x06000029 RID: 41 RVA: 0x0000276E File Offset: 0x0000096E internal MemoryStream GetAsByteStream() { return new MemoryStream(this.Data); } // Token: 0x0600002A RID: 42 RVA: 0x0000277B File Offset: 0x0000097B private void AllocData() { if (this.Data == null || this.Data.Length < this.Length) { this.Data = new byte[this.Length]; } } // Token: 0x0600002B RID: 43 RVA: 0x000027A8 File Offset: 0x000009A8 public override string ToString() { return string.Concat(new object[] { "chunkid=", ChunkHelper.ToString(this.IdBytes), " len=", this.Length }); } // Token: 0x04000025 RID: 37 public readonly int Length; // Token: 0x04000026 RID: 38 public readonly byte[] IdBytes; // Token: 0x04000027 RID: 39 public byte[] Data; // Token: 0x04000028 RID: 40 private int crcval; } }