scripts
This commit is contained in:
@@ -0,0 +1,288 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using Hjg.Pngcs.Chunks;
|
||||
using Hjg.Pngcs.Zlib;
|
||||
|
||||
namespace Hjg.Pngcs
|
||||
{
|
||||
// Token: 0x02000035 RID: 53
|
||||
internal class PngIDatChunkInputStream : Stream
|
||||
{
|
||||
// Token: 0x060001DD RID: 477 RVA: 0x00007CE5 File Offset: 0x00005EE5
|
||||
public override void Write(byte[] buffer, int offset, int count)
|
||||
{
|
||||
}
|
||||
|
||||
// Token: 0x060001DE RID: 478 RVA: 0x00007CE7 File Offset: 0x00005EE7
|
||||
public override void SetLength(long value)
|
||||
{
|
||||
}
|
||||
|
||||
// Token: 0x060001DF RID: 479 RVA: 0x00007CE9 File Offset: 0x00005EE9
|
||||
public override long Seek(long offset, SeekOrigin origin)
|
||||
{
|
||||
return -1L;
|
||||
}
|
||||
|
||||
// Token: 0x060001E0 RID: 480 RVA: 0x00007CED File Offset: 0x00005EED
|
||||
public override void Flush()
|
||||
{
|
||||
}
|
||||
|
||||
// Token: 0x1700002A RID: 42
|
||||
// (get) Token: 0x060001E1 RID: 481 RVA: 0x00007CEF File Offset: 0x00005EEF
|
||||
// (set) Token: 0x060001E2 RID: 482 RVA: 0x00007CF7 File Offset: 0x00005EF7
|
||||
public override long Position { get; set; }
|
||||
|
||||
// Token: 0x1700002B RID: 43
|
||||
// (get) Token: 0x060001E3 RID: 483 RVA: 0x00007D00 File Offset: 0x00005F00
|
||||
public override long Length
|
||||
{
|
||||
get
|
||||
{
|
||||
return 0L;
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x1700002C RID: 44
|
||||
// (get) Token: 0x060001E4 RID: 484 RVA: 0x00007D04 File Offset: 0x00005F04
|
||||
public override bool CanWrite
|
||||
{
|
||||
get
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x1700002D RID: 45
|
||||
// (get) Token: 0x060001E5 RID: 485 RVA: 0x00007D07 File Offset: 0x00005F07
|
||||
public override bool CanRead
|
||||
{
|
||||
get
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x1700002E RID: 46
|
||||
// (get) Token: 0x060001E6 RID: 486 RVA: 0x00007D0A File Offset: 0x00005F0A
|
||||
public override bool CanSeek
|
||||
{
|
||||
get
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x060001E7 RID: 487 RVA: 0x00007D10 File Offset: 0x00005F10
|
||||
public PngIDatChunkInputStream(Stream iStream, int lenFirstChunk, long offset_0)
|
||||
{
|
||||
this.idLastChunk = new byte[4];
|
||||
this.toReadThisChunk = 0;
|
||||
this.ended = false;
|
||||
this.foundChunksInfo = new List<PngIDatChunkInputStream.IdatChunkInfo>();
|
||||
this.offset = offset_0;
|
||||
this.checkCrc = true;
|
||||
this.inputStream = iStream;
|
||||
this.crcEngine = new CRC32();
|
||||
this.lenLastChunk = lenFirstChunk;
|
||||
this.toReadThisChunk = lenFirstChunk;
|
||||
Array.Copy(ChunkHelper.b_IDAT, 0, this.idLastChunk, 0, 4);
|
||||
this.crcEngine.Update(this.idLastChunk, 0, 4);
|
||||
this.foundChunksInfo.Add(new PngIDatChunkInputStream.IdatChunkInfo(this.lenLastChunk, offset_0 - 8L));
|
||||
if (this.lenLastChunk == 0)
|
||||
{
|
||||
this.EndChunkGoForNext();
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x060001E8 RID: 488 RVA: 0x00007DC4 File Offset: 0x00005FC4
|
||||
public override void Close()
|
||||
{
|
||||
base.Close();
|
||||
}
|
||||
|
||||
// Token: 0x060001E9 RID: 489 RVA: 0x00007DCC File Offset: 0x00005FCC
|
||||
private void EndChunkGoForNext()
|
||||
{
|
||||
for (;;)
|
||||
{
|
||||
int num = PngHelperInternal.ReadInt4(this.inputStream);
|
||||
this.offset += 4L;
|
||||
if (this.checkCrc)
|
||||
{
|
||||
int value = (int)this.crcEngine.GetValue();
|
||||
if (this.lenLastChunk > 0 && num != value)
|
||||
{
|
||||
break;
|
||||
}
|
||||
this.crcEngine.Reset();
|
||||
}
|
||||
this.lenLastChunk = PngHelperInternal.ReadInt4(this.inputStream);
|
||||
if (this.lenLastChunk < 0)
|
||||
{
|
||||
goto Block_3;
|
||||
}
|
||||
this.toReadThisChunk = this.lenLastChunk;
|
||||
PngHelperInternal.ReadBytes(this.inputStream, this.idLastChunk, 0, 4);
|
||||
this.offset += 8L;
|
||||
this.ended = !PngCsUtils.arraysEqual4(this.idLastChunk, ChunkHelper.b_IDAT);
|
||||
if (!this.ended)
|
||||
{
|
||||
this.foundChunksInfo.Add(new PngIDatChunkInputStream.IdatChunkInfo(this.lenLastChunk, this.offset - 8L));
|
||||
if (this.checkCrc)
|
||||
{
|
||||
this.crcEngine.Update(this.idLastChunk, 0, 4);
|
||||
}
|
||||
}
|
||||
if (this.lenLastChunk != 0 || this.ended)
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
throw new PngjBadCrcException("error reading idat; offset: " + this.offset);
|
||||
Block_3:
|
||||
throw new PngjInputException("invalid len for chunk: " + this.lenLastChunk);
|
||||
}
|
||||
|
||||
// Token: 0x060001EA RID: 490 RVA: 0x00007F0C File Offset: 0x0000610C
|
||||
public void ForceChunkEnd()
|
||||
{
|
||||
if (!this.ended)
|
||||
{
|
||||
byte[] array = new byte[this.toReadThisChunk];
|
||||
PngHelperInternal.ReadBytes(this.inputStream, array, 0, this.toReadThisChunk);
|
||||
if (this.checkCrc)
|
||||
{
|
||||
this.crcEngine.Update(array, 0, this.toReadThisChunk);
|
||||
}
|
||||
this.EndChunkGoForNext();
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x060001EB RID: 491 RVA: 0x00007F64 File Offset: 0x00006164
|
||||
public override int Read(byte[] b, int off, int len_0)
|
||||
{
|
||||
if (this.ended)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
if (this.toReadThisChunk == 0)
|
||||
{
|
||||
throw new Exception("this should not happen");
|
||||
}
|
||||
int num = this.inputStream.Read(b, off, (len_0 >= this.toReadThisChunk) ? this.toReadThisChunk : len_0);
|
||||
if (num == -1)
|
||||
{
|
||||
num = -2;
|
||||
}
|
||||
if (num > 0)
|
||||
{
|
||||
if (this.checkCrc)
|
||||
{
|
||||
this.crcEngine.Update(b, off, num);
|
||||
}
|
||||
this.offset += (long)num;
|
||||
this.toReadThisChunk -= num;
|
||||
}
|
||||
if (num >= 0 && this.toReadThisChunk == 0)
|
||||
{
|
||||
this.EndChunkGoForNext();
|
||||
}
|
||||
return num;
|
||||
}
|
||||
|
||||
// Token: 0x060001EC RID: 492 RVA: 0x00007FFF File Offset: 0x000061FF
|
||||
public int Read(byte[] b)
|
||||
{
|
||||
return this.Read(b, 0, b.Length);
|
||||
}
|
||||
|
||||
// Token: 0x060001ED RID: 493 RVA: 0x0000800C File Offset: 0x0000620C
|
||||
public override int ReadByte()
|
||||
{
|
||||
byte[] array = new byte[1];
|
||||
int num = this.Read(array, 0, 1);
|
||||
if (num >= 0)
|
||||
{
|
||||
return (int)array[0];
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
// Token: 0x060001EE RID: 494 RVA: 0x00008033 File Offset: 0x00006233
|
||||
public int GetLenLastChunk()
|
||||
{
|
||||
return this.lenLastChunk;
|
||||
}
|
||||
|
||||
// Token: 0x060001EF RID: 495 RVA: 0x0000803B File Offset: 0x0000623B
|
||||
public byte[] GetIdLastChunk()
|
||||
{
|
||||
return this.idLastChunk;
|
||||
}
|
||||
|
||||
// Token: 0x060001F0 RID: 496 RVA: 0x00008043 File Offset: 0x00006243
|
||||
public long GetOffset()
|
||||
{
|
||||
return this.offset;
|
||||
}
|
||||
|
||||
// Token: 0x060001F1 RID: 497 RVA: 0x0000804B File Offset: 0x0000624B
|
||||
public bool IsEnded()
|
||||
{
|
||||
return this.ended;
|
||||
}
|
||||
|
||||
// Token: 0x060001F2 RID: 498 RVA: 0x00008053 File Offset: 0x00006253
|
||||
internal void DisableCrcCheck()
|
||||
{
|
||||
this.checkCrc = false;
|
||||
}
|
||||
|
||||
// Token: 0x04000103 RID: 259
|
||||
private readonly Stream inputStream;
|
||||
|
||||
// Token: 0x04000104 RID: 260
|
||||
private readonly CRC32 crcEngine;
|
||||
|
||||
// Token: 0x04000105 RID: 261
|
||||
private bool checkCrc;
|
||||
|
||||
// Token: 0x04000106 RID: 262
|
||||
private int lenLastChunk;
|
||||
|
||||
// Token: 0x04000107 RID: 263
|
||||
private byte[] idLastChunk;
|
||||
|
||||
// Token: 0x04000108 RID: 264
|
||||
private int toReadThisChunk;
|
||||
|
||||
// Token: 0x04000109 RID: 265
|
||||
private bool ended;
|
||||
|
||||
// Token: 0x0400010A RID: 266
|
||||
private long offset;
|
||||
|
||||
// Token: 0x0400010B RID: 267
|
||||
public IList<PngIDatChunkInputStream.IdatChunkInfo> foundChunksInfo;
|
||||
|
||||
// Token: 0x02000036 RID: 54
|
||||
public class IdatChunkInfo
|
||||
{
|
||||
// Token: 0x060001F3 RID: 499 RVA: 0x0000805C File Offset: 0x0000625C
|
||||
public IdatChunkInfo(int len_0, long offset_1)
|
||||
{
|
||||
this.len = len_0;
|
||||
this.offset = offset_1;
|
||||
}
|
||||
|
||||
// Token: 0x0400010D RID: 269
|
||||
public readonly int len;
|
||||
|
||||
// Token: 0x0400010E RID: 270
|
||||
public readonly long offset;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user