This commit is contained in:
niko
2026-06-04 11:42:34 +02:00
parent f39ba70a9f
commit e720b98cd1
7488 changed files with 2493818 additions and 0 deletions
+35
View File
@@ -0,0 +1,35 @@
using System;
namespace Hjg.Pngcs.Chunks
{
// Token: 0x02000007 RID: 7
public class ChunkCopyBehaviour
{
// Token: 0x0400002B RID: 43
public static readonly int COPY_NONE = 0;
// Token: 0x0400002C RID: 44
public static readonly int COPY_PALETTE = 1;
// Token: 0x0400002D RID: 45
public static readonly int COPY_ALL_SAFE = 4;
// Token: 0x0400002E RID: 46
public static readonly int COPY_ALL = 8;
// Token: 0x0400002F RID: 47
public static readonly int COPY_PHYS = 16;
// Token: 0x04000030 RID: 48
public static readonly int COPY_TEXTUAL = 32;
// Token: 0x04000031 RID: 49
public static readonly int COPY_TRANSPARENCY = 64;
// Token: 0x04000032 RID: 50
public static readonly int COPY_UNKNOWN = 128;
// Token: 0x04000033 RID: 51
public static readonly int COPY_ALMOSTALL = 256;
}
}
+294
View File
@@ -0,0 +1,294 @@
using System;
using System.Collections.Generic;
using System.IO;
using Hjg.Pngcs.Zlib;
namespace Hjg.Pngcs.Chunks
{
// Token: 0x02000002 RID: 2
public class ChunkHelper
{
// Token: 0x06000001 RID: 1 RVA: 0x00002050 File Offset: 0x00000250
public static byte[] ToBytes(string x)
{
return PngHelperInternal.charsetLatin1.GetBytes(x);
}
// Token: 0x06000002 RID: 2 RVA: 0x0000205D File Offset: 0x0000025D
public static string ToString(byte[] x)
{
return PngHelperInternal.charsetLatin1.GetString(x);
}
// Token: 0x06000003 RID: 3 RVA: 0x0000206A File Offset: 0x0000026A
public static string ToString(byte[] x, int offset, int len)
{
return PngHelperInternal.charsetLatin1.GetString(x, offset, len);
}
// Token: 0x06000004 RID: 4 RVA: 0x00002079 File Offset: 0x00000279
public static byte[] ToBytesUTF8(string x)
{
return PngHelperInternal.charsetUtf8.GetBytes(x);
}
// Token: 0x06000005 RID: 5 RVA: 0x00002086 File Offset: 0x00000286
public static string ToStringUTF8(byte[] x)
{
return PngHelperInternal.charsetUtf8.GetString(x);
}
// Token: 0x06000006 RID: 6 RVA: 0x00002093 File Offset: 0x00000293
public static string ToStringUTF8(byte[] x, int offset, int len)
{
return PngHelperInternal.charsetUtf8.GetString(x, offset, len);
}
// Token: 0x06000007 RID: 7 RVA: 0x000020A2 File Offset: 0x000002A2
public static void WriteBytesToStream(Stream stream, byte[] bytes)
{
stream.Write(bytes, 0, bytes.Length);
}
// Token: 0x06000008 RID: 8 RVA: 0x000020AF File Offset: 0x000002AF
public static bool IsCritical(string id)
{
return char.IsUpper(id[0]);
}
// Token: 0x06000009 RID: 9 RVA: 0x000020BD File Offset: 0x000002BD
public static bool IsPublic(string id)
{
return char.IsUpper(id[1]);
}
// Token: 0x0600000A RID: 10 RVA: 0x000020CB File Offset: 0x000002CB
public static bool IsSafeToCopy(string id)
{
return !char.IsUpper(id[3]);
}
// Token: 0x0600000B RID: 11 RVA: 0x000020DC File Offset: 0x000002DC
public static bool IsUnknown(PngChunk chunk)
{
return chunk is PngChunkUNKNOWN;
}
// Token: 0x0600000C RID: 12 RVA: 0x000020E8 File Offset: 0x000002E8
public static int PosNullByte(byte[] bytes)
{
for (int i = 0; i < bytes.Length; i++)
{
if (bytes[i] == 0)
{
return i;
}
}
return -1;
}
// Token: 0x0600000D RID: 13 RVA: 0x0000210C File Offset: 0x0000030C
public static bool ShouldLoad(string id, ChunkLoadBehaviour behav)
{
if (ChunkHelper.IsCritical(id))
{
return true;
}
bool flag = PngChunk.isKnown(id);
switch (behav)
{
case ChunkLoadBehaviour.LOAD_CHUNK_NEVER:
return false;
case ChunkLoadBehaviour.LOAD_CHUNK_KNOWN:
return flag;
case ChunkLoadBehaviour.LOAD_CHUNK_IF_SAFE:
return flag || ChunkHelper.IsSafeToCopy(id);
case ChunkLoadBehaviour.LOAD_CHUNK_ALWAYS:
return true;
default:
return false;
}
}
// Token: 0x0600000E RID: 14 RVA: 0x00002157 File Offset: 0x00000357
internal static byte[] compressBytes(byte[] ori, bool compress)
{
return ChunkHelper.compressBytes(ori, 0, ori.Length, compress);
}
// Token: 0x0600000F RID: 15 RVA: 0x00002164 File Offset: 0x00000364
internal static byte[] compressBytes(byte[] ori, int offset, int len, bool compress)
{
byte[] array2;
try
{
MemoryStream memoryStream = new MemoryStream(ori, offset, len);
Stream stream = memoryStream;
if (!compress)
{
stream = ZlibStreamFactory.createZlibInputStream(memoryStream);
}
MemoryStream memoryStream2 = new MemoryStream();
Stream stream2 = memoryStream2;
if (compress)
{
stream2 = ZlibStreamFactory.createZlibOutputStream(memoryStream2);
}
ChunkHelper.shovelInToOut(stream, stream2);
stream.Close();
stream2.Close();
byte[] array = memoryStream2.ToArray();
array2 = array;
}
catch (Exception ex)
{
throw new PngjException(ex);
}
return array2;
}
// Token: 0x06000010 RID: 16 RVA: 0x000021D8 File Offset: 0x000003D8
private static void shovelInToOut(Stream inx, Stream outx)
{
byte[] array = new byte[1024];
int num;
while ((num = inx.Read(array, 0, 1024)) > 0)
{
outx.Write(array, 0, num);
}
}
// Token: 0x06000011 RID: 17 RVA: 0x0000220D File Offset: 0x0000040D
internal static bool maskMatch(int v, int mask)
{
return (v & mask) != 0;
}
// Token: 0x06000012 RID: 18 RVA: 0x00002218 File Offset: 0x00000418
public static List<PngChunk> FilterList(List<PngChunk> list, ChunkPredicate predicateKeep)
{
List<PngChunk> list2 = new List<PngChunk>();
foreach (PngChunk pngChunk in list)
{
if (predicateKeep.Matches(pngChunk))
{
list2.Add(pngChunk);
}
}
return list2;
}
// Token: 0x06000013 RID: 19 RVA: 0x00002278 File Offset: 0x00000478
public static int TrimList(List<PngChunk> list, ChunkPredicate predicateRemove)
{
int num = 0;
for (int i = list.Count - 1; i >= 0; i--)
{
if (predicateRemove.Matches(list[i]))
{
list.RemoveAt(i);
num++;
}
}
return num;
}
// Token: 0x06000014 RID: 20 RVA: 0x000022B8 File Offset: 0x000004B8
public static bool Equivalent(PngChunk c1, PngChunk c2)
{
if (c1 == c2)
{
return true;
}
if (c1 == null || c2 == null || !c1.Id.Equals(c2.Id))
{
return false;
}
if (c1.GetType() != c2.GetType())
{
return false;
}
if (!c2.AllowsMultiple())
{
return true;
}
if (c1 is PngChunkTextVar)
{
return ((PngChunkTextVar)c1).GetKey().Equals(((PngChunkTextVar)c2).GetKey());
}
return c1 is PngChunkSPLT && ((PngChunkSPLT)c1).PalName.Equals(((PngChunkSPLT)c2).PalName);
}
// Token: 0x06000015 RID: 21 RVA: 0x00002349 File Offset: 0x00000549
public static bool IsText(PngChunk c)
{
return c is PngChunkTextVar;
}
// Token: 0x04000001 RID: 1
internal const string IHDR = "IHDR";
// Token: 0x04000002 RID: 2
internal const string PLTE = "PLTE";
// Token: 0x04000003 RID: 3
internal const string IDAT = "IDAT";
// Token: 0x04000004 RID: 4
internal const string IEND = "IEND";
// Token: 0x04000005 RID: 5
internal const string cHRM = "cHRM";
// Token: 0x04000006 RID: 6
internal const string gAMA = "gAMA";
// Token: 0x04000007 RID: 7
internal const string iCCP = "iCCP";
// Token: 0x04000008 RID: 8
internal const string sBIT = "sBIT";
// Token: 0x04000009 RID: 9
internal const string sRGB = "sRGB";
// Token: 0x0400000A RID: 10
internal const string bKGD = "bKGD";
// Token: 0x0400000B RID: 11
internal const string hIST = "hIST";
// Token: 0x0400000C RID: 12
internal const string tRNS = "tRNS";
// Token: 0x0400000D RID: 13
internal const string pHYs = "pHYs";
// Token: 0x0400000E RID: 14
internal const string sPLT = "sPLT";
// Token: 0x0400000F RID: 15
internal const string tIME = "tIME";
// Token: 0x04000010 RID: 16
internal const string iTXt = "iTXt";
// Token: 0x04000011 RID: 17
internal const string tEXt = "tEXt";
// Token: 0x04000012 RID: 18
internal const string zTXt = "zTXt";
// Token: 0x04000013 RID: 19
internal static readonly byte[] b_IHDR = ChunkHelper.ToBytes("IHDR");
// Token: 0x04000014 RID: 20
internal static readonly byte[] b_PLTE = ChunkHelper.ToBytes("PLTE");
// Token: 0x04000015 RID: 21
internal static readonly byte[] b_IDAT = ChunkHelper.ToBytes("IDAT");
// Token: 0x04000016 RID: 22
internal static readonly byte[] b_IEND = ChunkHelper.ToBytes("IEND");
}
}
+17
View File
@@ -0,0 +1,17 @@
using System;
namespace Hjg.Pngcs.Chunks
{
// Token: 0x02000004 RID: 4
public enum ChunkLoadBehaviour
{
// Token: 0x04000021 RID: 33
LOAD_CHUNK_NEVER,
// Token: 0x04000022 RID: 34
LOAD_CHUNK_KNOWN,
// Token: 0x04000023 RID: 35
LOAD_CHUNK_IF_SAFE,
// Token: 0x04000024 RID: 36
LOAD_CHUNK_ALWAYS
}
}
+11
View File
@@ -0,0 +1,11 @@
using System;
namespace Hjg.Pngcs.Chunks
{
// Token: 0x02000008 RID: 8
public interface ChunkPredicate
{
// Token: 0x06000039 RID: 57
bool Matches(PngChunk chunk);
}
}
+23
View File
@@ -0,0 +1,23 @@
using System;
namespace Hjg.Pngcs.Chunks
{
// Token: 0x0200000B RID: 11
internal class ChunkPredicateEquiv : ChunkPredicate
{
// Token: 0x0600003E RID: 62 RVA: 0x00002B73 File Offset: 0x00000D73
public ChunkPredicateEquiv(PngChunk chunk)
{
this.chunk = chunk;
}
// Token: 0x0600003F RID: 63 RVA: 0x00002B82 File Offset: 0x00000D82
public bool Matches(PngChunk c)
{
return ChunkHelper.Equivalent(c, this.chunk);
}
// Token: 0x04000037 RID: 55
private readonly PngChunk chunk;
}
}
+23
View File
@@ -0,0 +1,23 @@
using System;
namespace Hjg.Pngcs.Chunks
{
// Token: 0x02000009 RID: 9
internal class ChunkPredicateId : ChunkPredicate
{
// Token: 0x0600003A RID: 58 RVA: 0x00002AD2 File Offset: 0x00000CD2
public ChunkPredicateId(string id)
{
this.id = id;
}
// Token: 0x0600003B RID: 59 RVA: 0x00002AE1 File Offset: 0x00000CE1
public bool Matches(PngChunk c)
{
return c.Id.Equals(this.id);
}
// Token: 0x04000034 RID: 52
private readonly string id;
}
}
+27
View File
@@ -0,0 +1,27 @@
using System;
namespace Hjg.Pngcs.Chunks
{
// Token: 0x0200000A RID: 10
internal class ChunkPredicateId2 : ChunkPredicate
{
// Token: 0x0600003C RID: 60 RVA: 0x00002AF4 File Offset: 0x00000CF4
public ChunkPredicateId2(string id, string inner)
{
this.id = id;
this.innerid = inner;
}
// Token: 0x0600003D RID: 61 RVA: 0x00002B0C File Offset: 0x00000D0C
public bool Matches(PngChunk c)
{
return c.Id.Equals(this.id) && (!(c is PngChunkTextVar) || ((PngChunkTextVar)c).GetKey().Equals(this.innerid)) && (!(c is PngChunkSPLT) || ((PngChunkSPLT)c).PalName.Equals(this.innerid));
}
// Token: 0x04000035 RID: 53
private readonly string id;
// Token: 0x04000036 RID: 54
private readonly string innerid;
}
}
+117
View File
@@ -0,0 +1,117 @@
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;
}
}
+141
View File
@@ -0,0 +1,141 @@
using System;
using System.Collections.Generic;
using System.Text;
namespace Hjg.Pngcs.Chunks
{
// Token: 0x02000003 RID: 3
public class ChunksList
{
// Token: 0x06000018 RID: 24 RVA: 0x0000239A File Offset: 0x0000059A
internal ChunksList(ImageInfo imfinfo)
{
this.chunks = new List<PngChunk>();
this.imageInfo = imfinfo;
}
// Token: 0x06000019 RID: 25 RVA: 0x000023B4 File Offset: 0x000005B4
public Dictionary<string, int> GetChunksKeys()
{
Dictionary<string, int> dictionary = new Dictionary<string, int>();
foreach (PngChunk pngChunk in this.chunks)
{
dictionary[pngChunk.Id] = (dictionary.ContainsKey(pngChunk.Id) ? (dictionary[pngChunk.Id] + 1) : 1);
}
return dictionary;
}
// Token: 0x0600001A RID: 26 RVA: 0x00002434 File Offset: 0x00000634
public List<PngChunk> GetChunks()
{
return new List<PngChunk>(this.chunks);
}
// Token: 0x0600001B RID: 27 RVA: 0x00002441 File Offset: 0x00000641
internal static List<PngChunk> GetXById(List<PngChunk> list, string id, string innerid)
{
if (innerid == null)
{
return ChunkHelper.FilterList(list, new ChunkPredicateId(id));
}
return ChunkHelper.FilterList(list, new ChunkPredicateId2(id, innerid));
}
// Token: 0x0600001C RID: 28 RVA: 0x00002460 File Offset: 0x00000660
public void AppendReadChunk(PngChunk chunk, int chunkGroup)
{
chunk.ChunkGroup = chunkGroup;
this.chunks.Add(chunk);
}
// Token: 0x0600001D RID: 29 RVA: 0x00002475 File Offset: 0x00000675
public List<PngChunk> GetById(string id)
{
return this.GetById(id, null);
}
// Token: 0x0600001E RID: 30 RVA: 0x0000247F File Offset: 0x0000067F
public List<PngChunk> GetById(string id, string innerid)
{
return ChunksList.GetXById(this.chunks, id, innerid);
}
// Token: 0x0600001F RID: 31 RVA: 0x0000248E File Offset: 0x0000068E
public PngChunk GetById1(string id)
{
return this.GetById1(id, false);
}
// Token: 0x06000020 RID: 32 RVA: 0x00002498 File Offset: 0x00000698
public PngChunk GetById1(string id, bool failIfMultiple)
{
return this.GetById1(id, null, failIfMultiple);
}
// Token: 0x06000021 RID: 33 RVA: 0x000024A4 File Offset: 0x000006A4
public PngChunk GetById1(string id, string innerid, bool failIfMultiple)
{
List<PngChunk> byId = this.GetById(id, innerid);
if (byId.Count == 0)
{
return null;
}
if (byId.Count > 1 && (failIfMultiple || !byId[0].AllowsMultiple()))
{
throw new PngjException("unexpected multiple chunks id=" + id);
}
return byId[byId.Count - 1];
}
// Token: 0x06000022 RID: 34 RVA: 0x000024FD File Offset: 0x000006FD
public List<PngChunk> GetEquivalent(PngChunk chunk)
{
return ChunkHelper.FilterList(this.chunks, new ChunkPredicateEquiv(chunk));
}
// Token: 0x06000023 RID: 35 RVA: 0x00002510 File Offset: 0x00000710
public override string ToString()
{
return "ChunkList: read: " + this.chunks.Count;
}
// Token: 0x06000024 RID: 36 RVA: 0x0000252C File Offset: 0x0000072C
public string ToStringFull()
{
StringBuilder stringBuilder = new StringBuilder(this.ToString());
stringBuilder.Append("\n Read:\n");
foreach (PngChunk pngChunk in this.chunks)
{
stringBuilder.Append(pngChunk).Append(" G=" + pngChunk.ChunkGroup + "\n");
}
return stringBuilder.ToString();
}
// Token: 0x04000017 RID: 23
internal const int CHUNK_GROUP_0_IDHR = 0;
// Token: 0x04000018 RID: 24
internal const int CHUNK_GROUP_1_AFTERIDHR = 1;
// Token: 0x04000019 RID: 25
internal const int CHUNK_GROUP_2_PLTE = 2;
// Token: 0x0400001A RID: 26
internal const int CHUNK_GROUP_3_AFTERPLTE = 3;
// Token: 0x0400001B RID: 27
internal const int CHUNK_GROUP_4_IDAT = 4;
// Token: 0x0400001C RID: 28
internal const int CHUNK_GROUP_5_AFTERIDAT = 5;
// Token: 0x0400001D RID: 29
internal const int CHUNK_GROUP_6_END = 6;
// Token: 0x0400001E RID: 30
protected List<PngChunk> chunks;
// Token: 0x0400001F RID: 31
internal readonly ImageInfo imageInfo;
}
}
+152
View File
@@ -0,0 +1,152 @@
using System;
using System.Collections.Generic;
using System.IO;
namespace Hjg.Pngcs.Chunks
{
// Token: 0x02000006 RID: 6
public class ChunksListForWrite : ChunksList
{
// Token: 0x0600002C RID: 44 RVA: 0x000027EE File Offset: 0x000009EE
internal ChunksListForWrite(ImageInfo info)
: base(info)
{
this.queuedChunks = new List<PngChunk>();
this.alreadyWrittenKeys = new Dictionary<string, int>();
}
// Token: 0x0600002D RID: 45 RVA: 0x0000280D File Offset: 0x00000A0D
public List<PngChunk> GetQueuedById(string id)
{
return this.GetQueuedById(id, null);
}
// Token: 0x0600002E RID: 46 RVA: 0x00002817 File Offset: 0x00000A17
public List<PngChunk> GetQueuedById(string id, string innerid)
{
return ChunksList.GetXById(this.queuedChunks, id, innerid);
}
// Token: 0x0600002F RID: 47 RVA: 0x00002828 File Offset: 0x00000A28
public PngChunk GetQueuedById1(string id, string innerid, bool failIfMultiple)
{
List<PngChunk> queuedById = this.GetQueuedById(id, innerid);
if (queuedById.Count == 0)
{
return null;
}
if (queuedById.Count > 1 && (failIfMultiple || !queuedById[0].AllowsMultiple()))
{
throw new PngjException("unexpected multiple chunks id=" + id);
}
return queuedById[queuedById.Count - 1];
}
// Token: 0x06000030 RID: 48 RVA: 0x00002881 File Offset: 0x00000A81
public PngChunk GetQueuedById1(string id, bool failIfMultiple)
{
return this.GetQueuedById1(id, null, failIfMultiple);
}
// Token: 0x06000031 RID: 49 RVA: 0x0000288C File Offset: 0x00000A8C
public PngChunk GetQueuedById1(string id)
{
return this.GetQueuedById1(id, false);
}
// Token: 0x06000032 RID: 50 RVA: 0x00002896 File Offset: 0x00000A96
public bool RemoveChunk(PngChunk c)
{
return this.queuedChunks.Remove(c);
}
// Token: 0x06000033 RID: 51 RVA: 0x000028A4 File Offset: 0x00000AA4
public bool Queue(PngChunk chunk)
{
this.queuedChunks.Add(chunk);
return true;
}
// Token: 0x06000034 RID: 52 RVA: 0x000028B4 File Offset: 0x00000AB4
private static bool shouldWrite(PngChunk c, int currentGroup)
{
if (currentGroup == 2)
{
return c.Id.Equals("PLTE");
}
if (currentGroup % 2 == 0)
{
throw new PngjOutputException("bad chunk group?");
}
int num2;
int num;
if (c.mustGoBeforePLTE())
{
num = (num2 = 1);
}
else if (c.mustGoBeforeIDAT())
{
num = 3;
num2 = (c.mustGoAfterPLTE() ? 3 : 1);
}
else
{
num = 5;
num2 = 1;
}
int num3 = num;
if (c.Priority)
{
num3 = num2;
}
if (ChunkHelper.IsUnknown(c) && c.ChunkGroup > 0)
{
num3 = c.ChunkGroup;
}
return currentGroup == num3 || (currentGroup > num3 && currentGroup <= num);
}
// Token: 0x06000035 RID: 53 RVA: 0x00002948 File Offset: 0x00000B48
internal int writeChunks(Stream os, int currentGroup)
{
List<int> list = new List<int>();
for (int i = 0; i < this.queuedChunks.Count; i++)
{
PngChunk pngChunk = this.queuedChunks[i];
if (ChunksListForWrite.shouldWrite(pngChunk, currentGroup))
{
if (ChunkHelper.IsCritical(pngChunk.Id) && !pngChunk.Id.Equals("PLTE"))
{
throw new PngjOutputException("bad chunk queued: " + pngChunk);
}
if (this.alreadyWrittenKeys.ContainsKey(pngChunk.Id) && !pngChunk.AllowsMultiple())
{
throw new PngjOutputException("duplicated chunk does not allow multiple: " + pngChunk);
}
pngChunk.write(os);
this.chunks.Add(pngChunk);
this.alreadyWrittenKeys[pngChunk.Id] = (this.alreadyWrittenKeys.ContainsKey(pngChunk.Id) ? (this.alreadyWrittenKeys[pngChunk.Id] + 1) : 1);
list.Add(i);
pngChunk.ChunkGroup = currentGroup;
}
}
for (int j = list.Count - 1; j >= 0; j--)
{
this.queuedChunks.RemoveAt(list[j]);
}
return list.Count;
}
// Token: 0x06000036 RID: 54 RVA: 0x00002A72 File Offset: 0x00000C72
internal List<PngChunk> GetQueuedChunks()
{
return this.queuedChunks;
}
// Token: 0x04000029 RID: 41
private List<PngChunk> queuedChunks;
// Token: 0x0400002A RID: 42
private Dictionary<string, int> alreadyWrittenKeys;
}
}
+298
View File
@@ -0,0 +1,298 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Reflection;
namespace Hjg.Pngcs.Chunks
{
// Token: 0x0200000C RID: 12
public abstract class PngChunk
{
// Token: 0x17000001 RID: 1
// (get) Token: 0x06000040 RID: 64 RVA: 0x00002B90 File Offset: 0x00000D90
// (set) Token: 0x06000041 RID: 65 RVA: 0x00002B98 File Offset: 0x00000D98
public bool Priority { get; set; }
// Token: 0x17000002 RID: 2
// (get) Token: 0x06000042 RID: 66 RVA: 0x00002BA1 File Offset: 0x00000DA1
// (set) Token: 0x06000043 RID: 67 RVA: 0x00002BA9 File Offset: 0x00000DA9
public int ChunkGroup { get; set; }
// Token: 0x17000003 RID: 3
// (get) Token: 0x06000044 RID: 68 RVA: 0x00002BB2 File Offset: 0x00000DB2
// (set) Token: 0x06000045 RID: 69 RVA: 0x00002BBA File Offset: 0x00000DBA
public int Length { get; set; }
// Token: 0x17000004 RID: 4
// (get) Token: 0x06000046 RID: 70 RVA: 0x00002BC3 File Offset: 0x00000DC3
// (set) Token: 0x06000047 RID: 71 RVA: 0x00002BCB File Offset: 0x00000DCB
public long Offset { get; set; }
// Token: 0x06000048 RID: 72 RVA: 0x00002BD4 File Offset: 0x00000DD4
protected PngChunk(string id, ImageInfo imgInfo)
{
this.Id = id;
this.ImgInfo = imgInfo;
this.Crit = ChunkHelper.IsCritical(id);
this.Pub = ChunkHelper.IsPublic(id);
this.Safe = ChunkHelper.IsSafeToCopy(id);
this.Priority = false;
this.ChunkGroup = -1;
this.Length = -1;
this.Offset = 0L;
}
// Token: 0x06000049 RID: 73 RVA: 0x00002C38 File Offset: 0x00000E38
private static Dictionary<string, Type> initFactory()
{
return new Dictionary<string, Type>
{
{
"IDAT",
typeof(PngChunkIDAT)
},
{
"IHDR",
typeof(PngChunkIHDR)
},
{
"PLTE",
typeof(PngChunkPLTE)
},
{
"IEND",
typeof(PngChunkIEND)
},
{
"tEXt",
typeof(PngChunkTEXT)
},
{
"iTXt",
typeof(PngChunkITXT)
},
{
"zTXt",
typeof(PngChunkZTXT)
},
{
"bKGD",
typeof(PngChunkBKGD)
},
{
"gAMA",
typeof(PngChunkGAMA)
},
{
"pHYs",
typeof(PngChunkPHYS)
},
{
"iCCP",
typeof(PngChunkICCP)
},
{
"tIME",
typeof(PngChunkTIME)
},
{
"tRNS",
typeof(PngChunkTRNS)
},
{
"cHRM",
typeof(PngChunkCHRM)
},
{
"sBIT",
typeof(PngChunkSBIT)
},
{
"sRGB",
typeof(PngChunkSRGB)
},
{
"hIST",
typeof(PngChunkHIST)
},
{
"sPLT",
typeof(PngChunkSPLT)
},
{
"oFFs",
typeof(PngChunkOFFS)
},
{
"sTER",
typeof(PngChunkSTER)
}
};
}
// Token: 0x0600004A RID: 74 RVA: 0x00002DF0 File Offset: 0x00000FF0
public static void FactoryRegister(string chunkId, Type type)
{
PngChunk.factoryMap.Add(chunkId, type);
}
// Token: 0x0600004B RID: 75 RVA: 0x00002DFE File Offset: 0x00000FFE
internal static bool isKnown(string id)
{
return PngChunk.factoryMap.ContainsKey(id);
}
// Token: 0x0600004C RID: 76 RVA: 0x00002E0B File Offset: 0x0000100B
internal bool mustGoBeforePLTE()
{
return this.GetOrderingConstraint() == PngChunk.ChunkOrderingConstraint.BEFORE_PLTE_AND_IDAT;
}
// Token: 0x0600004D RID: 77 RVA: 0x00002E18 File Offset: 0x00001018
internal bool mustGoBeforeIDAT()
{
PngChunk.ChunkOrderingConstraint orderingConstraint = this.GetOrderingConstraint();
return orderingConstraint == PngChunk.ChunkOrderingConstraint.BEFORE_IDAT || orderingConstraint == PngChunk.ChunkOrderingConstraint.BEFORE_PLTE_AND_IDAT || orderingConstraint == PngChunk.ChunkOrderingConstraint.AFTER_PLTE_BEFORE_IDAT;
}
// Token: 0x0600004E RID: 78 RVA: 0x00002E3A File Offset: 0x0000103A
internal bool mustGoAfterPLTE()
{
return this.GetOrderingConstraint() == PngChunk.ChunkOrderingConstraint.AFTER_PLTE_BEFORE_IDAT;
}
// Token: 0x0600004F RID: 79 RVA: 0x00002E48 File Offset: 0x00001048
internal static PngChunk Factory(ChunkRaw chunk, ImageInfo info)
{
PngChunk pngChunk = PngChunk.FactoryFromId(ChunkHelper.ToString(chunk.IdBytes), info);
pngChunk.Length = chunk.Length;
pngChunk.ParseFromRaw(chunk);
return pngChunk;
}
// Token: 0x06000050 RID: 80 RVA: 0x00002E7C File Offset: 0x0000107C
internal static PngChunk FactoryFromId(string cid, ImageInfo info)
{
PngChunk pngChunk = null;
if (PngChunk.factoryMap == null)
{
PngChunk.initFactory();
}
if (PngChunk.isKnown(cid))
{
Type type = PngChunk.factoryMap[cid];
if (type == null)
{
Console.Error.WriteLine("What?? " + cid);
}
ConstructorInfo constructor = type.GetConstructor(new Type[] { typeof(ImageInfo) });
object obj = constructor.Invoke(new object[] { info });
pngChunk = (PngChunk)obj;
}
if (pngChunk == null)
{
pngChunk = new PngChunkUNKNOWN(cid, info);
}
return pngChunk;
}
// Token: 0x06000051 RID: 81 RVA: 0x00002F0C File Offset: 0x0000110C
public ChunkRaw createEmptyChunk(int len, bool alloc)
{
return new ChunkRaw(len, ChunkHelper.ToBytes(this.Id), alloc);
}
// Token: 0x06000052 RID: 82 RVA: 0x00002F30 File Offset: 0x00001130
public static T CloneChunk<T>(T chunk, ImageInfo info) where T : PngChunk
{
PngChunk pngChunk = PngChunk.FactoryFromId(chunk.Id, info);
if (pngChunk.GetType() != chunk.GetType())
{
throw new PngjException(string.Concat(new object[]
{
"bad class cloning chunk: ",
pngChunk.GetType(),
" ",
chunk.GetType()
}));
}
pngChunk.CloneDataFromRead(chunk);
return (T)((object)pngChunk);
}
// Token: 0x06000053 RID: 83 RVA: 0x00002FB4 File Offset: 0x000011B4
internal void write(Stream os)
{
ChunkRaw chunkRaw = this.CreateRawChunk();
if (chunkRaw == null)
{
throw new PngjException("null chunk ! creation failed for " + this);
}
chunkRaw.WriteChunk(os);
}
// Token: 0x06000054 RID: 84 RVA: 0x00002FE4 File Offset: 0x000011E4
public override string ToString()
{
return string.Concat(new object[]
{
"chunk id= ",
this.Id,
" (len=",
this.Length,
" off=",
this.Offset,
") c=",
base.GetType().Name
});
}
// Token: 0x06000055 RID: 85
public abstract ChunkRaw CreateRawChunk();
// Token: 0x06000056 RID: 86
public abstract void ParseFromRaw(ChunkRaw c);
// Token: 0x06000057 RID: 87
public abstract void CloneDataFromRead(PngChunk other);
// Token: 0x06000058 RID: 88
public abstract bool AllowsMultiple();
// Token: 0x06000059 RID: 89
public abstract PngChunk.ChunkOrderingConstraint GetOrderingConstraint();
// Token: 0x04000038 RID: 56
public readonly string Id;
// Token: 0x04000039 RID: 57
public readonly bool Crit;
// Token: 0x0400003A RID: 58
public readonly bool Pub;
// Token: 0x0400003B RID: 59
public readonly bool Safe;
// Token: 0x0400003C RID: 60
protected readonly ImageInfo ImgInfo;
// Token: 0x0400003D RID: 61
private static Dictionary<string, Type> factoryMap = PngChunk.initFactory();
// Token: 0x0200000D RID: 13
public enum ChunkOrderingConstraint
{
// Token: 0x04000043 RID: 67
NONE,
// Token: 0x04000044 RID: 68
BEFORE_PLTE_AND_IDAT,
// Token: 0x04000045 RID: 69
AFTER_PLTE_BEFORE_IDAT,
// Token: 0x04000046 RID: 70
BEFORE_IDAT,
// Token: 0x04000047 RID: 71
NA
}
}
}
+153
View File
@@ -0,0 +1,153 @@
using System;
namespace Hjg.Pngcs.Chunks
{
// Token: 0x02000023 RID: 35
public class PngChunkBKGD : PngChunkSingle
{
// Token: 0x0600013B RID: 315 RVA: 0x00005F9F File Offset: 0x0000419F
public PngChunkBKGD(ImageInfo info)
: base("bKGD", info)
{
}
// Token: 0x0600013C RID: 316 RVA: 0x00005FAD File Offset: 0x000041AD
public override PngChunk.ChunkOrderingConstraint GetOrderingConstraint()
{
return PngChunk.ChunkOrderingConstraint.AFTER_PLTE_BEFORE_IDAT;
}
// Token: 0x0600013D RID: 317 RVA: 0x00005FB0 File Offset: 0x000041B0
public override ChunkRaw CreateRawChunk()
{
ChunkRaw chunkRaw;
if (this.ImgInfo.Greyscale)
{
chunkRaw = base.createEmptyChunk(2, true);
PngHelperInternal.WriteInt2tobytes(this.gray, chunkRaw.Data, 0);
}
else if (this.ImgInfo.Indexed)
{
chunkRaw = base.createEmptyChunk(1, true);
chunkRaw.Data[0] = (byte)this.paletteIndex;
}
else
{
chunkRaw = base.createEmptyChunk(6, true);
PngHelperInternal.WriteInt2tobytes(this.red, chunkRaw.Data, 0);
PngHelperInternal.WriteInt2tobytes(this.green, chunkRaw.Data, 0);
PngHelperInternal.WriteInt2tobytes(this.blue, chunkRaw.Data, 0);
}
return chunkRaw;
}
// Token: 0x0600013E RID: 318 RVA: 0x00006050 File Offset: 0x00004250
public override void ParseFromRaw(ChunkRaw c)
{
if (this.ImgInfo.Greyscale)
{
this.gray = PngHelperInternal.ReadInt2fromBytes(c.Data, 0);
return;
}
if (this.ImgInfo.Indexed)
{
this.paletteIndex = (int)(c.Data[0] & byte.MaxValue);
return;
}
this.red = PngHelperInternal.ReadInt2fromBytes(c.Data, 0);
this.green = PngHelperInternal.ReadInt2fromBytes(c.Data, 2);
this.blue = PngHelperInternal.ReadInt2fromBytes(c.Data, 4);
}
// Token: 0x0600013F RID: 319 RVA: 0x000060D8 File Offset: 0x000042D8
public override void CloneDataFromRead(PngChunk other)
{
PngChunkBKGD pngChunkBKGD = (PngChunkBKGD)other;
this.gray = pngChunkBKGD.gray;
this.red = pngChunkBKGD.red;
this.green = pngChunkBKGD.red;
this.blue = pngChunkBKGD.red;
this.paletteIndex = pngChunkBKGD.paletteIndex;
}
// Token: 0x06000140 RID: 320 RVA: 0x00006128 File Offset: 0x00004328
public void SetGray(int gray)
{
if (!this.ImgInfo.Greyscale)
{
throw new PngjException("only gray images support this");
}
this.gray = gray;
}
// Token: 0x06000141 RID: 321 RVA: 0x00006149 File Offset: 0x00004349
public int GetGray()
{
if (!this.ImgInfo.Greyscale)
{
throw new PngjException("only gray images support this");
}
return this.gray;
}
// Token: 0x06000142 RID: 322 RVA: 0x00006169 File Offset: 0x00004369
public void SetPaletteIndex(int index)
{
if (!this.ImgInfo.Indexed)
{
throw new PngjException("only indexed (pallete) images support this");
}
this.paletteIndex = index;
}
// Token: 0x06000143 RID: 323 RVA: 0x0000618A File Offset: 0x0000438A
public int GetPaletteIndex()
{
if (!this.ImgInfo.Indexed)
{
throw new PngjException("only indexed (pallete) images support this");
}
return this.paletteIndex;
}
// Token: 0x06000144 RID: 324 RVA: 0x000061AA File Offset: 0x000043AA
public void SetRGB(int r, int g, int b)
{
if (this.ImgInfo.Greyscale || this.ImgInfo.Indexed)
{
throw new PngjException("only rgb or rgba images support this");
}
this.red = r;
this.green = g;
this.blue = b;
}
// Token: 0x06000145 RID: 325 RVA: 0x000061E8 File Offset: 0x000043E8
public int[] GetRGB()
{
if (this.ImgInfo.Greyscale || this.ImgInfo.Indexed)
{
throw new PngjException("only rgb or rgba images support this");
}
return new int[] { this.red, this.green, this.blue };
}
// Token: 0x040000AE RID: 174
public const string ID = "bKGD";
// Token: 0x040000AF RID: 175
private int gray;
// Token: 0x040000B0 RID: 176
private int red;
// Token: 0x040000B1 RID: 177
private int green;
// Token: 0x040000B2 RID: 178
private int blue;
// Token: 0x040000B3 RID: 179
private int paletteIndex;
}
}
+112
View File
@@ -0,0 +1,112 @@
using System;
namespace Hjg.Pngcs.Chunks
{
// Token: 0x02000016 RID: 22
public class PngChunkCHRM : PngChunkSingle
{
// Token: 0x060000A1 RID: 161 RVA: 0x00003BC7 File Offset: 0x00001DC7
public PngChunkCHRM(ImageInfo info)
: base("cHRM", info)
{
}
// Token: 0x060000A2 RID: 162 RVA: 0x00003BD5 File Offset: 0x00001DD5
public override PngChunk.ChunkOrderingConstraint GetOrderingConstraint()
{
return PngChunk.ChunkOrderingConstraint.AFTER_PLTE_BEFORE_IDAT;
}
// Token: 0x060000A3 RID: 163 RVA: 0x00003BD8 File Offset: 0x00001DD8
public override ChunkRaw CreateRawChunk()
{
ChunkRaw chunkRaw = base.createEmptyChunk(32, true);
PngHelperInternal.WriteInt4tobytes(PngHelperInternal.DoubleToInt100000(this.whitex), chunkRaw.Data, 0);
PngHelperInternal.WriteInt4tobytes(PngHelperInternal.DoubleToInt100000(this.whitey), chunkRaw.Data, 4);
PngHelperInternal.WriteInt4tobytes(PngHelperInternal.DoubleToInt100000(this.redx), chunkRaw.Data, 8);
PngHelperInternal.WriteInt4tobytes(PngHelperInternal.DoubleToInt100000(this.redy), chunkRaw.Data, 12);
PngHelperInternal.WriteInt4tobytes(PngHelperInternal.DoubleToInt100000(this.greenx), chunkRaw.Data, 16);
PngHelperInternal.WriteInt4tobytes(PngHelperInternal.DoubleToInt100000(this.greeny), chunkRaw.Data, 20);
PngHelperInternal.WriteInt4tobytes(PngHelperInternal.DoubleToInt100000(this.bluex), chunkRaw.Data, 24);
PngHelperInternal.WriteInt4tobytes(PngHelperInternal.DoubleToInt100000(this.bluey), chunkRaw.Data, 28);
return chunkRaw;
}
// Token: 0x060000A4 RID: 164 RVA: 0x00003CB0 File Offset: 0x00001EB0
public override void ParseFromRaw(ChunkRaw c)
{
if (c.Length != 32)
{
throw new PngjException("bad chunk " + c);
}
this.whitex = PngHelperInternal.IntToDouble100000(PngHelperInternal.ReadInt4fromBytes(c.Data, 0));
this.whitey = PngHelperInternal.IntToDouble100000(PngHelperInternal.ReadInt4fromBytes(c.Data, 4));
this.redx = PngHelperInternal.IntToDouble100000(PngHelperInternal.ReadInt4fromBytes(c.Data, 8));
this.redy = PngHelperInternal.IntToDouble100000(PngHelperInternal.ReadInt4fromBytes(c.Data, 12));
this.greenx = PngHelperInternal.IntToDouble100000(PngHelperInternal.ReadInt4fromBytes(c.Data, 16));
this.greeny = PngHelperInternal.IntToDouble100000(PngHelperInternal.ReadInt4fromBytes(c.Data, 20));
this.bluex = PngHelperInternal.IntToDouble100000(PngHelperInternal.ReadInt4fromBytes(c.Data, 24));
this.bluey = PngHelperInternal.IntToDouble100000(PngHelperInternal.ReadInt4fromBytes(c.Data, 28));
}
// Token: 0x060000A5 RID: 165 RVA: 0x00003D98 File Offset: 0x00001F98
public override void CloneDataFromRead(PngChunk other)
{
PngChunkCHRM pngChunkCHRM = (PngChunkCHRM)other;
this.whitex = pngChunkCHRM.whitex;
this.whitey = pngChunkCHRM.whitex;
this.redx = pngChunkCHRM.redx;
this.redy = pngChunkCHRM.redy;
this.greenx = pngChunkCHRM.greenx;
this.greeny = pngChunkCHRM.greeny;
this.bluex = pngChunkCHRM.bluex;
this.bluey = pngChunkCHRM.bluey;
}
// Token: 0x060000A6 RID: 166 RVA: 0x00003E0C File Offset: 0x0000200C
public void SetChromaticities(double whitex, double whitey, double redx, double redy, double greenx, double greeny, double bluex, double bluey)
{
this.whitex = whitex;
this.redx = redx;
this.greenx = greenx;
this.bluex = bluex;
this.whitey = whitey;
this.redy = redy;
this.greeny = greeny;
this.bluey = bluey;
}
// Token: 0x060000A7 RID: 167 RVA: 0x00003E4C File Offset: 0x0000204C
public double[] GetChromaticities()
{
return new double[] { this.whitex, this.whitey, this.redx, this.redy, this.greenx, this.greeny, this.bluex, this.bluey };
}
// Token: 0x04000056 RID: 86
public const string ID = "cHRM";
// Token: 0x04000057 RID: 87
private double whitex;
// Token: 0x04000058 RID: 88
private double whitey;
// Token: 0x04000059 RID: 89
private double redx;
// Token: 0x0400005A RID: 90
private double redy;
// Token: 0x0400005B RID: 91
private double greenx;
// Token: 0x0400005C RID: 92
private double greeny;
// Token: 0x0400005D RID: 93
private double bluex;
// Token: 0x0400005E RID: 94
private double bluey;
}
}
+64
View File
@@ -0,0 +1,64 @@
using System;
namespace Hjg.Pngcs.Chunks
{
// Token: 0x02000024 RID: 36
public class PngChunkGAMA : PngChunkSingle
{
// Token: 0x06000146 RID: 326 RVA: 0x0000623D File Offset: 0x0000443D
public PngChunkGAMA(ImageInfo info)
: base("gAMA", info)
{
}
// Token: 0x06000147 RID: 327 RVA: 0x0000624B File Offset: 0x0000444B
public override PngChunk.ChunkOrderingConstraint GetOrderingConstraint()
{
return PngChunk.ChunkOrderingConstraint.BEFORE_PLTE_AND_IDAT;
}
// Token: 0x06000148 RID: 328 RVA: 0x00006250 File Offset: 0x00004450
public override ChunkRaw CreateRawChunk()
{
ChunkRaw chunkRaw = base.createEmptyChunk(4, true);
int num = (int)(this.gamma * 100000.0 + 0.5);
PngHelperInternal.WriteInt4tobytes(num, chunkRaw.Data, 0);
return chunkRaw;
}
// Token: 0x06000149 RID: 329 RVA: 0x00006290 File Offset: 0x00004490
public override void ParseFromRaw(ChunkRaw chunk)
{
if (chunk.Length != 4)
{
throw new PngjException("bad chunk " + chunk);
}
int num = PngHelperInternal.ReadInt4fromBytes(chunk.Data, 0);
this.gamma = (double)num / 100000.0;
}
// Token: 0x0600014A RID: 330 RVA: 0x000062D6 File Offset: 0x000044D6
public override void CloneDataFromRead(PngChunk other)
{
this.gamma = ((PngChunkGAMA)other).gamma;
}
// Token: 0x0600014B RID: 331 RVA: 0x000062E9 File Offset: 0x000044E9
public double GetGamma()
{
return this.gamma;
}
// Token: 0x0600014C RID: 332 RVA: 0x000062F1 File Offset: 0x000044F1
public void SetGamma(double gamma)
{
this.gamma = gamma;
}
// Token: 0x040000B4 RID: 180
public const string ID = "gAMA";
// Token: 0x040000B5 RID: 181
private double gamma;
}
}
+76
View File
@@ -0,0 +1,76 @@
using System;
namespace Hjg.Pngcs.Chunks
{
// Token: 0x02000015 RID: 21
public class PngChunkHIST : PngChunkSingle
{
// Token: 0x06000099 RID: 153 RVA: 0x00003A7E File Offset: 0x00001C7E
public PngChunkHIST(ImageInfo info)
: base(PngChunkHIST.ID, info)
{
}
// Token: 0x0600009A RID: 154 RVA: 0x00003A98 File Offset: 0x00001C98
public override PngChunk.ChunkOrderingConstraint GetOrderingConstraint()
{
return PngChunk.ChunkOrderingConstraint.AFTER_PLTE_BEFORE_IDAT;
}
// Token: 0x0600009B RID: 155 RVA: 0x00003A9C File Offset: 0x00001C9C
public override ChunkRaw CreateRawChunk()
{
if (!this.ImgInfo.Indexed)
{
throw new PngjException("only indexed images accept a HIST chunk");
}
ChunkRaw chunkRaw = base.createEmptyChunk(this.hist.Length * 2, true);
for (int i = 0; i < this.hist.Length; i++)
{
PngHelperInternal.WriteInt2tobytes(this.hist[i], chunkRaw.Data, i * 2);
}
return chunkRaw;
}
// Token: 0x0600009C RID: 156 RVA: 0x00003B00 File Offset: 0x00001D00
public override void ParseFromRaw(ChunkRaw c)
{
if (!this.ImgInfo.Indexed)
{
throw new PngjException("only indexed images accept a HIST chunk");
}
int num = c.Data.Length / 2;
this.hist = new int[num];
for (int i = 0; i < this.hist.Length; i++)
{
this.hist[i] = PngHelperInternal.ReadInt2fromBytes(c.Data, i * 2);
}
}
// Token: 0x0600009D RID: 157 RVA: 0x00003B68 File Offset: 0x00001D68
public override void CloneDataFromRead(PngChunk other)
{
PngChunkHIST pngChunkHIST = (PngChunkHIST)other;
this.hist = new int[pngChunkHIST.hist.Length];
Array.Copy(pngChunkHIST.hist, 0, this.hist, 0, pngChunkHIST.hist.Length);
}
// Token: 0x0600009E RID: 158 RVA: 0x00003BAA File Offset: 0x00001DAA
public int[] GetHist()
{
return this.hist;
}
// Token: 0x0600009F RID: 159 RVA: 0x00003BB2 File Offset: 0x00001DB2
public void SetHist(int[] hist)
{
this.hist = hist;
}
// Token: 0x04000054 RID: 84
public static readonly string ID = "hIST";
// Token: 0x04000055 RID: 85
private int[] hist = new int[0];
}
}
+95
View File
@@ -0,0 +1,95 @@
using System;
namespace Hjg.Pngcs.Chunks
{
// Token: 0x02000025 RID: 37
public class PngChunkICCP : PngChunkSingle
{
// Token: 0x0600014D RID: 333 RVA: 0x000062FA File Offset: 0x000044FA
public PngChunkICCP(ImageInfo info)
: base("iCCP", info)
{
}
// Token: 0x0600014E RID: 334 RVA: 0x00006308 File Offset: 0x00004508
public override PngChunk.ChunkOrderingConstraint GetOrderingConstraint()
{
return PngChunk.ChunkOrderingConstraint.BEFORE_PLTE_AND_IDAT;
}
// Token: 0x0600014F RID: 335 RVA: 0x0000630C File Offset: 0x0000450C
public override ChunkRaw CreateRawChunk()
{
ChunkRaw chunkRaw = base.createEmptyChunk(this.profileName.Length + this.compressedProfile.Length + 2, true);
Array.Copy(ChunkHelper.ToBytes(this.profileName), 0, chunkRaw.Data, 0, this.profileName.Length);
chunkRaw.Data[this.profileName.Length] = 0;
chunkRaw.Data[this.profileName.Length + 1] = 0;
Array.Copy(this.compressedProfile, 0, chunkRaw.Data, this.profileName.Length + 2, this.compressedProfile.Length);
return chunkRaw;
}
// Token: 0x06000150 RID: 336 RVA: 0x000063AC File Offset: 0x000045AC
public override void ParseFromRaw(ChunkRaw chunk)
{
int num = ChunkHelper.PosNullByte(chunk.Data);
this.profileName = PngHelperInternal.charsetLatin1.GetString(chunk.Data, 0, num);
int num2 = (int)(chunk.Data[num + 1] & byte.MaxValue);
if (num2 != 0)
{
throw new Exception("bad compression for ChunkTypeICCP");
}
int num3 = chunk.Data.Length - (num + 2);
this.compressedProfile = new byte[num3];
Array.Copy(chunk.Data, num + 2, this.compressedProfile, 0, num3);
}
// Token: 0x06000151 RID: 337 RVA: 0x0000642C File Offset: 0x0000462C
public override void CloneDataFromRead(PngChunk other)
{
PngChunkICCP pngChunkICCP = (PngChunkICCP)other;
this.profileName = pngChunkICCP.profileName;
this.compressedProfile = new byte[pngChunkICCP.compressedProfile.Length];
Array.Copy(pngChunkICCP.compressedProfile, this.compressedProfile, this.compressedProfile.Length);
}
// Token: 0x06000152 RID: 338 RVA: 0x00006478 File Offset: 0x00004678
public void SetProfileNameAndContent(string name, string profile)
{
this.SetProfileNameAndContent(name, ChunkHelper.ToBytes(this.profileName));
}
// Token: 0x06000153 RID: 339 RVA: 0x0000648C File Offset: 0x0000468C
public void SetProfileNameAndContent(string name, byte[] profile)
{
this.profileName = name;
this.compressedProfile = ChunkHelper.compressBytes(profile, true);
}
// Token: 0x06000154 RID: 340 RVA: 0x000064A2 File Offset: 0x000046A2
public string GetProfileName()
{
return this.profileName;
}
// Token: 0x06000155 RID: 341 RVA: 0x000064AA File Offset: 0x000046AA
public byte[] GetProfile()
{
return ChunkHelper.compressBytes(this.compressedProfile, false);
}
// Token: 0x06000156 RID: 342 RVA: 0x000064B8 File Offset: 0x000046B8
public string GetProfileAsString()
{
return ChunkHelper.ToString(this.GetProfile());
}
// Token: 0x040000B6 RID: 182
public const string ID = "iCCP";
// Token: 0x040000B7 RID: 183
private string profileName;
// Token: 0x040000B8 RID: 184
private byte[] compressedProfile;
}
}
+41
View File
@@ -0,0 +1,41 @@
using System;
namespace Hjg.Pngcs.Chunks
{
// Token: 0x02000026 RID: 38
public class PngChunkIDAT : PngChunkMultiple
{
// Token: 0x06000157 RID: 343 RVA: 0x000064C5 File Offset: 0x000046C5
public PngChunkIDAT(ImageInfo i, int len, long offset)
: base("IDAT", i)
{
base.Length = len;
base.Offset = offset;
}
// Token: 0x06000158 RID: 344 RVA: 0x000064E1 File Offset: 0x000046E1
public override PngChunk.ChunkOrderingConstraint GetOrderingConstraint()
{
return PngChunk.ChunkOrderingConstraint.NA;
}
// Token: 0x06000159 RID: 345 RVA: 0x000064E4 File Offset: 0x000046E4
public override ChunkRaw CreateRawChunk()
{
return null;
}
// Token: 0x0600015A RID: 346 RVA: 0x000064E7 File Offset: 0x000046E7
public override void ParseFromRaw(ChunkRaw c)
{
}
// Token: 0x0600015B RID: 347 RVA: 0x000064E9 File Offset: 0x000046E9
public override void CloneDataFromRead(PngChunk other)
{
}
// Token: 0x040000B9 RID: 185
public const string ID = "IDAT";
}
}
+39
View File
@@ -0,0 +1,39 @@
using System;
namespace Hjg.Pngcs.Chunks
{
// Token: 0x02000027 RID: 39
public class PngChunkIEND : PngChunkSingle
{
// Token: 0x0600015C RID: 348 RVA: 0x000064EB File Offset: 0x000046EB
public PngChunkIEND(ImageInfo info)
: base("IEND", info)
{
}
// Token: 0x0600015D RID: 349 RVA: 0x000064F9 File Offset: 0x000046F9
public override PngChunk.ChunkOrderingConstraint GetOrderingConstraint()
{
return PngChunk.ChunkOrderingConstraint.NA;
}
// Token: 0x0600015E RID: 350 RVA: 0x000064FC File Offset: 0x000046FC
public override ChunkRaw CreateRawChunk()
{
return new ChunkRaw(0, ChunkHelper.b_IEND, false);
}
// Token: 0x0600015F RID: 351 RVA: 0x00006517 File Offset: 0x00004717
public override void ParseFromRaw(ChunkRaw c)
{
}
// Token: 0x06000160 RID: 352 RVA: 0x00006519 File Offset: 0x00004719
public override void CloneDataFromRead(PngChunk other)
{
}
// Token: 0x040000BA RID: 186
public const string ID = "IEND";
}
}
+106
View File
@@ -0,0 +1,106 @@
using System;
using System.IO;
namespace Hjg.Pngcs.Chunks
{
// Token: 0x02000028 RID: 40
public class PngChunkIHDR : PngChunkSingle
{
// Token: 0x17000020 RID: 32
// (get) Token: 0x06000161 RID: 353 RVA: 0x0000651B File Offset: 0x0000471B
// (set) Token: 0x06000162 RID: 354 RVA: 0x00006523 File Offset: 0x00004723
public int Cols { get; set; }
// Token: 0x17000021 RID: 33
// (get) Token: 0x06000163 RID: 355 RVA: 0x0000652C File Offset: 0x0000472C
// (set) Token: 0x06000164 RID: 356 RVA: 0x00006534 File Offset: 0x00004734
public int Rows { get; set; }
// Token: 0x17000022 RID: 34
// (get) Token: 0x06000165 RID: 357 RVA: 0x0000653D File Offset: 0x0000473D
// (set) Token: 0x06000166 RID: 358 RVA: 0x00006545 File Offset: 0x00004745
public int Bitspc { get; set; }
// Token: 0x17000023 RID: 35
// (get) Token: 0x06000167 RID: 359 RVA: 0x0000654E File Offset: 0x0000474E
// (set) Token: 0x06000168 RID: 360 RVA: 0x00006556 File Offset: 0x00004756
public int Colormodel { get; set; }
// Token: 0x17000024 RID: 36
// (get) Token: 0x06000169 RID: 361 RVA: 0x0000655F File Offset: 0x0000475F
// (set) Token: 0x0600016A RID: 362 RVA: 0x00006567 File Offset: 0x00004767
public int Compmeth { get; set; }
// Token: 0x17000025 RID: 37
// (get) Token: 0x0600016B RID: 363 RVA: 0x00006570 File Offset: 0x00004770
// (set) Token: 0x0600016C RID: 364 RVA: 0x00006578 File Offset: 0x00004778
public int Filmeth { get; set; }
// Token: 0x17000026 RID: 38
// (get) Token: 0x0600016D RID: 365 RVA: 0x00006581 File Offset: 0x00004781
// (set) Token: 0x0600016E RID: 366 RVA: 0x00006589 File Offset: 0x00004789
public int Interlaced { get; set; }
// Token: 0x0600016F RID: 367 RVA: 0x00006592 File Offset: 0x00004792
public PngChunkIHDR(ImageInfo info)
: base("IHDR", info)
{
}
// Token: 0x06000170 RID: 368 RVA: 0x000065A0 File Offset: 0x000047A0
public override PngChunk.ChunkOrderingConstraint GetOrderingConstraint()
{
return PngChunk.ChunkOrderingConstraint.NA;
}
// Token: 0x06000171 RID: 369 RVA: 0x000065A4 File Offset: 0x000047A4
public override ChunkRaw CreateRawChunk()
{
ChunkRaw chunkRaw = new ChunkRaw(13, ChunkHelper.b_IHDR, true);
int num = 0;
PngHelperInternal.WriteInt4tobytes(this.Cols, chunkRaw.Data, num);
num += 4;
PngHelperInternal.WriteInt4tobytes(this.Rows, chunkRaw.Data, num);
num += 4;
chunkRaw.Data[num++] = (byte)this.Bitspc;
chunkRaw.Data[num++] = (byte)this.Colormodel;
chunkRaw.Data[num++] = (byte)this.Compmeth;
chunkRaw.Data[num++] = (byte)this.Filmeth;
chunkRaw.Data[num++] = (byte)this.Interlaced;
return chunkRaw;
}
// Token: 0x06000172 RID: 370 RVA: 0x00006650 File Offset: 0x00004850
public override void ParseFromRaw(ChunkRaw c)
{
if (c.Length != 13)
{
throw new PngjException("Bad IDHR len " + c.Length);
}
MemoryStream asByteStream = c.GetAsByteStream();
this.Cols = PngHelperInternal.ReadInt4(asByteStream);
this.Rows = PngHelperInternal.ReadInt4(asByteStream);
this.Bitspc = PngHelperInternal.ReadByte(asByteStream);
this.Colormodel = PngHelperInternal.ReadByte(asByteStream);
this.Compmeth = PngHelperInternal.ReadByte(asByteStream);
this.Filmeth = PngHelperInternal.ReadByte(asByteStream);
this.Interlaced = PngHelperInternal.ReadByte(asByteStream);
}
// Token: 0x06000173 RID: 371 RVA: 0x000066E0 File Offset: 0x000048E0
public override void CloneDataFromRead(PngChunk other)
{
PngChunkIHDR pngChunkIHDR = (PngChunkIHDR)other;
this.Cols = pngChunkIHDR.Cols;
this.Rows = pngChunkIHDR.Rows;
this.Bitspc = pngChunkIHDR.Bitspc;
this.Colormodel = pngChunkIHDR.Colormodel;
this.Compmeth = pngChunkIHDR.Compmeth;
this.Filmeth = pngChunkIHDR.Filmeth;
this.Interlaced = pngChunkIHDR.Interlaced;
}
// Token: 0x040000BB RID: 187
public const string ID = "IHDR";
}
}
+147
View File
@@ -0,0 +1,147 @@
using System;
using System.IO;
namespace Hjg.Pngcs.Chunks
{
// Token: 0x0200002B RID: 43
public class PngChunkITXT : PngChunkTextVar
{
// Token: 0x0600017A RID: 378 RVA: 0x0000677D File Offset: 0x0000497D
public PngChunkITXT(ImageInfo info)
: base("iTXt", info)
{
}
// Token: 0x0600017B RID: 379 RVA: 0x000067A4 File Offset: 0x000049A4
public override ChunkRaw CreateRawChunk()
{
if (this.key.Length == 0)
{
throw new PngjException("Text chunk key must be non empty");
}
MemoryStream memoryStream = new MemoryStream();
ChunkHelper.WriteBytesToStream(memoryStream, ChunkHelper.ToBytes(this.key));
memoryStream.WriteByte(0);
memoryStream.WriteByte(this.compressed ? 1 : 0);
memoryStream.WriteByte(0);
ChunkHelper.WriteBytesToStream(memoryStream, ChunkHelper.ToBytes(this.langTag));
memoryStream.WriteByte(0);
ChunkHelper.WriteBytesToStream(memoryStream, ChunkHelper.ToBytesUTF8(this.translatedTag));
memoryStream.WriteByte(0);
byte[] array = ChunkHelper.ToBytesUTF8(this.val);
if (this.compressed)
{
array = ChunkHelper.compressBytes(array, true);
}
ChunkHelper.WriteBytesToStream(memoryStream, array);
byte[] array2 = memoryStream.ToArray();
ChunkRaw chunkRaw = base.createEmptyChunk(array2.Length, false);
chunkRaw.Data = array2;
return chunkRaw;
}
// Token: 0x0600017C RID: 380 RVA: 0x00006870 File Offset: 0x00004A70
public override void ParseFromRaw(ChunkRaw c)
{
int num = 0;
int[] array = new int[3];
for (int i = 0; i < c.Data.Length; i++)
{
if (c.Data[i] == 0)
{
array[num] = i;
num++;
if (num == 1)
{
i += 2;
}
if (num == 3)
{
break;
}
}
}
if (num != 3)
{
throw new PngjException("Bad formed PngChunkITXT chunk");
}
this.key = ChunkHelper.ToString(c.Data, 0, array[0]);
int num2 = array[0] + 1;
this.compressed = c.Data[num2] != 0;
num2++;
if (this.compressed && c.Data[num2] != 0)
{
throw new PngjException("Bad formed PngChunkITXT chunk - bad compression method ");
}
this.langTag = ChunkHelper.ToString(c.Data, num2, array[1] - num2);
this.translatedTag = ChunkHelper.ToStringUTF8(c.Data, array[1] + 1, array[2] - array[1] - 1);
num2 = array[2] + 1;
if (this.compressed)
{
byte[] array2 = ChunkHelper.compressBytes(c.Data, num2, c.Data.Length - num2, false);
this.val = ChunkHelper.ToStringUTF8(array2);
return;
}
this.val = ChunkHelper.ToStringUTF8(c.Data, num2, c.Data.Length - num2);
}
// Token: 0x0600017D RID: 381 RVA: 0x000069A0 File Offset: 0x00004BA0
public override void CloneDataFromRead(PngChunk other)
{
PngChunkITXT pngChunkITXT = (PngChunkITXT)other;
this.key = pngChunkITXT.key;
this.val = pngChunkITXT.val;
this.compressed = pngChunkITXT.compressed;
this.langTag = pngChunkITXT.langTag;
this.translatedTag = pngChunkITXT.translatedTag;
}
// Token: 0x0600017E RID: 382 RVA: 0x000069F0 File Offset: 0x00004BF0
public bool IsCompressed()
{
return this.compressed;
}
// Token: 0x0600017F RID: 383 RVA: 0x000069F8 File Offset: 0x00004BF8
public void SetCompressed(bool compressed)
{
this.compressed = compressed;
}
// Token: 0x06000180 RID: 384 RVA: 0x00006A01 File Offset: 0x00004C01
public string GetLangtag()
{
return this.langTag;
}
// Token: 0x06000181 RID: 385 RVA: 0x00006A09 File Offset: 0x00004C09
public void SetLangtag(string langtag)
{
this.langTag = langtag;
}
// Token: 0x06000182 RID: 386 RVA: 0x00006A12 File Offset: 0x00004C12
public string GetTranslatedTag()
{
return this.translatedTag;
}
// Token: 0x06000183 RID: 387 RVA: 0x00006A1A File Offset: 0x00004C1A
public void SetTranslatedTag(string translatedTag)
{
this.translatedTag = translatedTag;
}
// Token: 0x040000D8 RID: 216
public const string ID = "iTXt";
// Token: 0x040000D9 RID: 217
private bool compressed;
// Token: 0x040000DA RID: 218
private string langTag = "";
// Token: 0x040000DB RID: 219
private string translatedTag = "";
}
}
+20
View File
@@ -0,0 +1,20 @@
using System;
namespace Hjg.Pngcs.Chunks
{
// Token: 0x0200000E RID: 14
public abstract class PngChunkMultiple : PngChunk
{
// Token: 0x0600005B RID: 91 RVA: 0x0000305D File Offset: 0x0000125D
internal PngChunkMultiple(string id, ImageInfo imgInfo)
: base(id, imgInfo)
{
}
// Token: 0x0600005C RID: 92 RVA: 0x00003067 File Offset: 0x00001267
public sealed override bool AllowsMultiple()
{
return true;
}
}
}
+107
View File
@@ -0,0 +1,107 @@
using System;
namespace Hjg.Pngcs.Chunks
{
// Token: 0x02000013 RID: 19
public class PngChunkOFFS : PngChunkSingle
{
// Token: 0x06000082 RID: 130 RVA: 0x000035E8 File Offset: 0x000017E8
public PngChunkOFFS(ImageInfo info)
: base("oFFs", info)
{
}
// Token: 0x06000083 RID: 131 RVA: 0x000035F6 File Offset: 0x000017F6
public override PngChunk.ChunkOrderingConstraint GetOrderingConstraint()
{
return PngChunk.ChunkOrderingConstraint.BEFORE_IDAT;
}
// Token: 0x06000084 RID: 132 RVA: 0x000035FC File Offset: 0x000017FC
public override ChunkRaw CreateRawChunk()
{
ChunkRaw chunkRaw = base.createEmptyChunk(9, true);
PngHelperInternal.WriteInt4tobytes((int)this.posX, chunkRaw.Data, 0);
PngHelperInternal.WriteInt4tobytes((int)this.posY, chunkRaw.Data, 4);
chunkRaw.Data[8] = (byte)this.units;
return chunkRaw;
}
// Token: 0x06000085 RID: 133 RVA: 0x0000364C File Offset: 0x0000184C
public override void ParseFromRaw(ChunkRaw chunk)
{
if (chunk.Length != 9)
{
throw new PngjException("bad chunk length " + chunk);
}
this.posX = (long)PngHelperInternal.ReadInt4fromBytes(chunk.Data, 0);
if (this.posX < 0L)
{
this.posX += 4294967296L;
}
this.posY = (long)PngHelperInternal.ReadInt4fromBytes(chunk.Data, 4);
if (this.posY < 0L)
{
this.posY += 4294967296L;
}
this.units = PngHelperInternal.ReadInt1fromByte(chunk.Data, 8);
}
// Token: 0x06000086 RID: 134 RVA: 0x000036EC File Offset: 0x000018EC
public override void CloneDataFromRead(PngChunk other)
{
PngChunkOFFS pngChunkOFFS = (PngChunkOFFS)other;
this.posX = pngChunkOFFS.posX;
this.posY = pngChunkOFFS.posY;
this.units = pngChunkOFFS.units;
}
// Token: 0x06000087 RID: 135 RVA: 0x00003724 File Offset: 0x00001924
public int GetUnits()
{
return this.units;
}
// Token: 0x06000088 RID: 136 RVA: 0x0000372C File Offset: 0x0000192C
public void SetUnits(int units)
{
this.units = units;
}
// Token: 0x06000089 RID: 137 RVA: 0x00003735 File Offset: 0x00001935
public long GetPosX()
{
return this.posX;
}
// Token: 0x0600008A RID: 138 RVA: 0x0000373D File Offset: 0x0000193D
public void SetPosX(long posX)
{
this.posX = posX;
}
// Token: 0x0600008B RID: 139 RVA: 0x00003746 File Offset: 0x00001946
public long GetPosY()
{
return this.posY;
}
// Token: 0x0600008C RID: 140 RVA: 0x0000374E File Offset: 0x0000194E
public void SetPosY(long posY)
{
this.posY = posY;
}
// Token: 0x0400004C RID: 76
public const string ID = "oFFs";
// Token: 0x0400004D RID: 77
private long posX;
// Token: 0x0400004E RID: 78
private long posY;
// Token: 0x0400004F RID: 79
private int units;
}
}
+117
View File
@@ -0,0 +1,117 @@
using System;
namespace Hjg.Pngcs.Chunks
{
// Token: 0x0200002D RID: 45
public class PngChunkPHYS : PngChunkSingle
{
// Token: 0x17000027 RID: 39
// (get) Token: 0x0600018C RID: 396 RVA: 0x00006AC8 File Offset: 0x00004CC8
// (set) Token: 0x0600018D RID: 397 RVA: 0x00006AD0 File Offset: 0x00004CD0
public long PixelsxUnitX { get; set; }
// Token: 0x17000028 RID: 40
// (get) Token: 0x0600018E RID: 398 RVA: 0x00006AD9 File Offset: 0x00004CD9
// (set) Token: 0x0600018F RID: 399 RVA: 0x00006AE1 File Offset: 0x00004CE1
public long PixelsxUnitY { get; set; }
// Token: 0x17000029 RID: 41
// (get) Token: 0x06000190 RID: 400 RVA: 0x00006AEA File Offset: 0x00004CEA
// (set) Token: 0x06000191 RID: 401 RVA: 0x00006AF2 File Offset: 0x00004CF2
public int Units { get; set; }
// Token: 0x06000192 RID: 402 RVA: 0x00006AFB File Offset: 0x00004CFB
public PngChunkPHYS(ImageInfo info)
: base("pHYs", info)
{
}
// Token: 0x06000193 RID: 403 RVA: 0x00006B09 File Offset: 0x00004D09
public override PngChunk.ChunkOrderingConstraint GetOrderingConstraint()
{
return PngChunk.ChunkOrderingConstraint.BEFORE_IDAT;
}
// Token: 0x06000194 RID: 404 RVA: 0x00006B0C File Offset: 0x00004D0C
public override ChunkRaw CreateRawChunk()
{
ChunkRaw chunkRaw = base.createEmptyChunk(9, true);
PngHelperInternal.WriteInt4tobytes((int)this.PixelsxUnitX, chunkRaw.Data, 0);
PngHelperInternal.WriteInt4tobytes((int)this.PixelsxUnitY, chunkRaw.Data, 4);
chunkRaw.Data[8] = (byte)this.Units;
return chunkRaw;
}
// Token: 0x06000195 RID: 405 RVA: 0x00006B5C File Offset: 0x00004D5C
public override void CloneDataFromRead(PngChunk other)
{
PngChunkPHYS pngChunkPHYS = (PngChunkPHYS)other;
this.PixelsxUnitX = pngChunkPHYS.PixelsxUnitX;
this.PixelsxUnitY = pngChunkPHYS.PixelsxUnitY;
this.Units = pngChunkPHYS.Units;
}
// Token: 0x06000196 RID: 406 RVA: 0x00006B94 File Offset: 0x00004D94
public override void ParseFromRaw(ChunkRaw chunk)
{
if (chunk.Length != 9)
{
throw new PngjException("bad chunk length " + chunk);
}
this.PixelsxUnitX = (long)PngHelperInternal.ReadInt4fromBytes(chunk.Data, 0);
if (this.PixelsxUnitX < 0L)
{
this.PixelsxUnitX += 4294967296L;
}
this.PixelsxUnitY = (long)PngHelperInternal.ReadInt4fromBytes(chunk.Data, 4);
if (this.PixelsxUnitY < 0L)
{
this.PixelsxUnitY += 4294967296L;
}
this.Units = PngHelperInternal.ReadInt1fromByte(chunk.Data, 8);
}
// Token: 0x06000197 RID: 407 RVA: 0x00006C34 File Offset: 0x00004E34
public double GetAsDpi()
{
if (this.Units != 1 || this.PixelsxUnitX != this.PixelsxUnitY)
{
return -1.0;
}
return (double)this.PixelsxUnitX * 0.0254;
}
// Token: 0x06000198 RID: 408 RVA: 0x00006C68 File Offset: 0x00004E68
public double[] GetAsDpi2()
{
if (this.Units != 1)
{
return new double[] { -1.0, -1.0 };
}
return new double[]
{
(double)this.PixelsxUnitX * 0.0254,
(double)this.PixelsxUnitY * 0.0254
};
}
// Token: 0x06000199 RID: 409 RVA: 0x00006CCF File Offset: 0x00004ECF
public void SetAsDpi(double dpi)
{
this.Units = 1;
this.PixelsxUnitX = (long)(dpi / 0.0254 + 0.5);
this.PixelsxUnitY = this.PixelsxUnitX;
}
// Token: 0x0600019A RID: 410 RVA: 0x00006D00 File Offset: 0x00004F00
public void SetAsDpi2(double dpix, double dpiy)
{
this.Units = 1;
this.PixelsxUnitX = (long)(dpix / 0.0254 + 0.5);
this.PixelsxUnitY = (long)(dpiy / 0.0254 + 0.5);
}
// Token: 0x040000DD RID: 221
public const string ID = "pHYs";
}
}
+135
View File
@@ -0,0 +1,135 @@
using System;
namespace Hjg.Pngcs.Chunks
{
// Token: 0x0200002E RID: 46
public class PngChunkPLTE : PngChunkSingle
{
// Token: 0x0600019B RID: 411 RVA: 0x00006D4C File Offset: 0x00004F4C
public PngChunkPLTE(ImageInfo info)
: base("PLTE", info)
{
this.nentries = 0;
}
// Token: 0x0600019C RID: 412 RVA: 0x00006D61 File Offset: 0x00004F61
public override PngChunk.ChunkOrderingConstraint GetOrderingConstraint()
{
return PngChunk.ChunkOrderingConstraint.NA;
}
// Token: 0x0600019D RID: 413 RVA: 0x00006D64 File Offset: 0x00004F64
public override ChunkRaw CreateRawChunk()
{
int num = 3 * this.nentries;
int[] array = new int[3];
ChunkRaw chunkRaw = base.createEmptyChunk(num, true);
int i = 0;
int num2 = 0;
while (i < this.nentries)
{
this.GetEntryRgb(i, array);
chunkRaw.Data[num2++] = (byte)array[0];
chunkRaw.Data[num2++] = (byte)array[1];
chunkRaw.Data[num2++] = (byte)array[2];
i++;
}
return chunkRaw;
}
// Token: 0x0600019E RID: 414 RVA: 0x00006DE0 File Offset: 0x00004FE0
public override void ParseFromRaw(ChunkRaw chunk)
{
this.SetNentries(chunk.Length / 3);
int i = 0;
int num = 0;
while (i < this.nentries)
{
this.SetEntry(i, (int)(chunk.Data[num++] & byte.MaxValue), (int)(chunk.Data[num++] & byte.MaxValue), (int)(chunk.Data[num++] & byte.MaxValue));
i++;
}
}
// Token: 0x0600019F RID: 415 RVA: 0x00006E4C File Offset: 0x0000504C
public override void CloneDataFromRead(PngChunk other)
{
PngChunkPLTE pngChunkPLTE = (PngChunkPLTE)other;
this.SetNentries(pngChunkPLTE.GetNentries());
Array.Copy(pngChunkPLTE.entries, 0, this.entries, 0, this.nentries);
}
// Token: 0x060001A0 RID: 416 RVA: 0x00006E88 File Offset: 0x00005088
public void SetNentries(int nentries)
{
this.nentries = nentries;
if (nentries < 1 || nentries > 256)
{
throw new PngjException("invalid pallette - nentries=" + nentries);
}
if (this.entries == null || this.entries.Length != nentries)
{
this.entries = new int[nentries];
}
}
// Token: 0x060001A1 RID: 417 RVA: 0x00006EDD File Offset: 0x000050DD
public int GetNentries()
{
return this.nentries;
}
// Token: 0x060001A2 RID: 418 RVA: 0x00006EE5 File Offset: 0x000050E5
public void SetEntry(int n, int r, int g, int b)
{
this.entries[n] = (r << 16) | (g << 8) | b;
}
// Token: 0x060001A3 RID: 419 RVA: 0x00006EFA File Offset: 0x000050FA
public int GetEntry(int n)
{
return this.entries[n];
}
// Token: 0x060001A4 RID: 420 RVA: 0x00006F04 File Offset: 0x00005104
public void GetEntryRgb(int index, int[] rgb, int offset)
{
int num = this.entries[index];
rgb[offset] = (num & 16711680) >> 16;
rgb[offset + 1] = (num & 65280) >> 8;
rgb[offset + 2] = num & 255;
}
// Token: 0x060001A5 RID: 421 RVA: 0x00006F41 File Offset: 0x00005141
public void GetEntryRgb(int n, int[] rgb)
{
this.GetEntryRgb(n, rgb, 0);
}
// Token: 0x060001A6 RID: 422 RVA: 0x00006F4C File Offset: 0x0000514C
public int MinBitDepth()
{
if (this.nentries <= 2)
{
return 1;
}
if (this.nentries <= 4)
{
return 2;
}
if (this.nentries <= 16)
{
return 4;
}
return 8;
}
// Token: 0x040000E1 RID: 225
public const string ID = "PLTE";
// Token: 0x040000E2 RID: 226
private int nentries;
// Token: 0x040000E3 RID: 227
private int[] entries;
}
}
+123
View File
@@ -0,0 +1,123 @@
using System;
namespace Hjg.Pngcs.Chunks
{
// Token: 0x02000017 RID: 23
public class PngChunkSBIT : PngChunkSingle
{
// Token: 0x17000009 RID: 9
// (get) Token: 0x060000A8 RID: 168 RVA: 0x00003EA9 File Offset: 0x000020A9
// (set) Token: 0x060000A9 RID: 169 RVA: 0x00003EB1 File Offset: 0x000020B1
public int Graysb { get; set; }
// Token: 0x1700000A RID: 10
// (get) Token: 0x060000AA RID: 170 RVA: 0x00003EBA File Offset: 0x000020BA
// (set) Token: 0x060000AB RID: 171 RVA: 0x00003EC2 File Offset: 0x000020C2
public int Alphasb { get; set; }
// Token: 0x1700000B RID: 11
// (get) Token: 0x060000AC RID: 172 RVA: 0x00003ECB File Offset: 0x000020CB
// (set) Token: 0x060000AD RID: 173 RVA: 0x00003ED3 File Offset: 0x000020D3
public int Redsb { get; set; }
// Token: 0x1700000C RID: 12
// (get) Token: 0x060000AE RID: 174 RVA: 0x00003EDC File Offset: 0x000020DC
// (set) Token: 0x060000AF RID: 175 RVA: 0x00003EE4 File Offset: 0x000020E4
public int Greensb { get; set; }
// Token: 0x1700000D RID: 13
// (get) Token: 0x060000B0 RID: 176 RVA: 0x00003EED File Offset: 0x000020ED
// (set) Token: 0x060000B1 RID: 177 RVA: 0x00003EF5 File Offset: 0x000020F5
public int Bluesb { get; set; }
// Token: 0x060000B2 RID: 178 RVA: 0x00003EFE File Offset: 0x000020FE
public PngChunkSBIT(ImageInfo info)
: base("sBIT", info)
{
}
// Token: 0x060000B3 RID: 179 RVA: 0x00003F0C File Offset: 0x0000210C
public override PngChunk.ChunkOrderingConstraint GetOrderingConstraint()
{
return PngChunk.ChunkOrderingConstraint.BEFORE_PLTE_AND_IDAT;
}
// Token: 0x060000B4 RID: 180 RVA: 0x00003F10 File Offset: 0x00002110
public override void ParseFromRaw(ChunkRaw c)
{
if (c.Length != this.GetLen())
{
throw new PngjException("bad chunk length " + c);
}
if (this.ImgInfo.Greyscale)
{
this.Graysb = PngHelperInternal.ReadInt1fromByte(c.Data, 0);
if (this.ImgInfo.Alpha)
{
this.Alphasb = PngHelperInternal.ReadInt1fromByte(c.Data, 1);
return;
}
}
else
{
this.Redsb = PngHelperInternal.ReadInt1fromByte(c.Data, 0);
this.Greensb = PngHelperInternal.ReadInt1fromByte(c.Data, 1);
this.Bluesb = PngHelperInternal.ReadInt1fromByte(c.Data, 2);
if (this.ImgInfo.Alpha)
{
this.Alphasb = PngHelperInternal.ReadInt1fromByte(c.Data, 3);
}
}
}
// Token: 0x060000B5 RID: 181 RVA: 0x00003FD0 File Offset: 0x000021D0
public override ChunkRaw CreateRawChunk()
{
ChunkRaw chunkRaw = base.createEmptyChunk(this.GetLen(), true);
if (this.ImgInfo.Greyscale)
{
chunkRaw.Data[0] = (byte)this.Graysb;
if (this.ImgInfo.Alpha)
{
chunkRaw.Data[1] = (byte)this.Alphasb;
}
}
else
{
chunkRaw.Data[0] = (byte)this.Redsb;
chunkRaw.Data[1] = (byte)this.Greensb;
chunkRaw.Data[2] = (byte)this.Bluesb;
if (this.ImgInfo.Alpha)
{
chunkRaw.Data[3] = (byte)this.Alphasb;
}
}
return chunkRaw;
}
// Token: 0x060000B6 RID: 182 RVA: 0x00004074 File Offset: 0x00002274
public override void CloneDataFromRead(PngChunk other)
{
PngChunkSBIT pngChunkSBIT = (PngChunkSBIT)other;
this.Graysb = pngChunkSBIT.Graysb;
this.Redsb = pngChunkSBIT.Redsb;
this.Greensb = pngChunkSBIT.Greensb;
this.Bluesb = pngChunkSBIT.Bluesb;
this.Alphasb = pngChunkSBIT.Alphasb;
}
// Token: 0x060000B7 RID: 183 RVA: 0x000040C4 File Offset: 0x000022C4
private int GetLen()
{
int num = (this.ImgInfo.Greyscale ? 1 : 3);
if (this.ImgInfo.Alpha)
{
num++;
}
return num;
}
// Token: 0x0400005F RID: 95
public const string ID = "sBIT";
}
}
+141
View File
@@ -0,0 +1,141 @@
using System;
using System.IO;
namespace Hjg.Pngcs.Chunks
{
// Token: 0x02000014 RID: 20
public class PngChunkSPLT : PngChunkMultiple
{
// Token: 0x17000006 RID: 6
// (get) Token: 0x0600008D RID: 141 RVA: 0x00003757 File Offset: 0x00001957
// (set) Token: 0x0600008E RID: 142 RVA: 0x0000375F File Offset: 0x0000195F
public string PalName { get; set; }
// Token: 0x17000007 RID: 7
// (get) Token: 0x0600008F RID: 143 RVA: 0x00003768 File Offset: 0x00001968
// (set) Token: 0x06000090 RID: 144 RVA: 0x00003770 File Offset: 0x00001970
public int SampleDepth { get; set; }
// Token: 0x17000008 RID: 8
// (get) Token: 0x06000091 RID: 145 RVA: 0x00003779 File Offset: 0x00001979
// (set) Token: 0x06000092 RID: 146 RVA: 0x00003781 File Offset: 0x00001981
public int[] Palette { get; set; }
// Token: 0x06000093 RID: 147 RVA: 0x0000378A File Offset: 0x0000198A
public PngChunkSPLT(ImageInfo info)
: base("sPLT", info)
{
this.PalName = "";
}
// Token: 0x06000094 RID: 148 RVA: 0x000037A3 File Offset: 0x000019A3
public override PngChunk.ChunkOrderingConstraint GetOrderingConstraint()
{
return PngChunk.ChunkOrderingConstraint.BEFORE_IDAT;
}
// Token: 0x06000095 RID: 149 RVA: 0x000037A8 File Offset: 0x000019A8
public override ChunkRaw CreateRawChunk()
{
MemoryStream memoryStream = new MemoryStream();
ChunkHelper.WriteBytesToStream(memoryStream, ChunkHelper.ToBytes(this.PalName));
memoryStream.WriteByte(0);
memoryStream.WriteByte((byte)this.SampleDepth);
int nentries = this.GetNentries();
for (int i = 0; i < nentries; i++)
{
for (int j = 0; j < 4; j++)
{
if (this.SampleDepth == 8)
{
PngHelperInternal.WriteByte(memoryStream, (byte)this.Palette[i * 5 + j]);
}
else
{
PngHelperInternal.WriteInt2(memoryStream, this.Palette[i * 5 + j]);
}
}
PngHelperInternal.WriteInt2(memoryStream, this.Palette[i * 5 + 4]);
}
byte[] array = memoryStream.ToArray();
ChunkRaw chunkRaw = base.createEmptyChunk(array.Length, false);
chunkRaw.Data = array;
return chunkRaw;
}
// Token: 0x06000096 RID: 150 RVA: 0x00003864 File Offset: 0x00001A64
public override void ParseFromRaw(ChunkRaw c)
{
int num = -1;
for (int i = 0; i < c.Data.Length; i++)
{
if (c.Data[i] == 0)
{
num = i;
break;
}
}
if (num <= 0 || num > c.Data.Length - 2)
{
throw new PngjException("bad sPLT chunk: no separator found");
}
this.PalName = ChunkHelper.ToString(c.Data, 0, num);
this.SampleDepth = PngHelperInternal.ReadInt1fromByte(c.Data, num + 1);
num += 2;
int num2 = (c.Data.Length - num) / ((this.SampleDepth == 8) ? 6 : 10);
this.Palette = new int[num2 * 5];
int num3 = 0;
for (int j = 0; j < num2; j++)
{
int num4;
int num5;
int num6;
int num7;
if (this.SampleDepth == 8)
{
num4 = PngHelperInternal.ReadInt1fromByte(c.Data, num++);
num5 = PngHelperInternal.ReadInt1fromByte(c.Data, num++);
num6 = PngHelperInternal.ReadInt1fromByte(c.Data, num++);
num7 = PngHelperInternal.ReadInt1fromByte(c.Data, num++);
}
else
{
num4 = PngHelperInternal.ReadInt2fromBytes(c.Data, num);
num += 2;
num5 = PngHelperInternal.ReadInt2fromBytes(c.Data, num);
num += 2;
num6 = PngHelperInternal.ReadInt2fromBytes(c.Data, num);
num += 2;
num7 = PngHelperInternal.ReadInt2fromBytes(c.Data, num);
num += 2;
}
int num8 = PngHelperInternal.ReadInt2fromBytes(c.Data, num);
num += 2;
this.Palette[num3++] = num4;
this.Palette[num3++] = num5;
this.Palette[num3++] = num6;
this.Palette[num3++] = num7;
this.Palette[num3++] = num8;
}
}
// Token: 0x06000097 RID: 151 RVA: 0x00003A18 File Offset: 0x00001C18
public override void CloneDataFromRead(PngChunk other)
{
PngChunkSPLT pngChunkSPLT = (PngChunkSPLT)other;
this.PalName = pngChunkSPLT.PalName;
this.SampleDepth = pngChunkSPLT.SampleDepth;
this.Palette = new int[pngChunkSPLT.Palette.Length];
Array.Copy(pngChunkSPLT.Palette, 0, this.Palette, 0, this.Palette.Length);
}
// Token: 0x06000098 RID: 152 RVA: 0x00003A72 File Offset: 0x00001C72
public int GetNentries()
{
return this.Palette.Length / 5;
}
// Token: 0x04000050 RID: 80
public const string ID = "sPLT";
}
}
+65
View File
@@ -0,0 +1,65 @@
using System;
namespace Hjg.Pngcs.Chunks
{
// Token: 0x02000018 RID: 24
public class PngChunkSRGB : PngChunkSingle
{
// Token: 0x1700000E RID: 14
// (get) Token: 0x060000B8 RID: 184 RVA: 0x000040F5 File Offset: 0x000022F5
// (set) Token: 0x060000B9 RID: 185 RVA: 0x000040FD File Offset: 0x000022FD
public int Intent { get; set; }
// Token: 0x060000BA RID: 186 RVA: 0x00004106 File Offset: 0x00002306
public PngChunkSRGB(ImageInfo info)
: base("sRGB", info)
{
}
// Token: 0x060000BB RID: 187 RVA: 0x00004114 File Offset: 0x00002314
public override PngChunk.ChunkOrderingConstraint GetOrderingConstraint()
{
return PngChunk.ChunkOrderingConstraint.BEFORE_PLTE_AND_IDAT;
}
// Token: 0x060000BC RID: 188 RVA: 0x00004118 File Offset: 0x00002318
public override ChunkRaw CreateRawChunk()
{
ChunkRaw chunkRaw = base.createEmptyChunk(1, true);
chunkRaw.Data[0] = (byte)this.Intent;
return chunkRaw;
}
// Token: 0x060000BD RID: 189 RVA: 0x00004140 File Offset: 0x00002340
public override void ParseFromRaw(ChunkRaw c)
{
if (c.Length != 1)
{
throw new PngjException("bad chunk length " + c);
}
this.Intent = PngHelperInternal.ReadInt1fromByte(c.Data, 0);
}
// Token: 0x060000BE RID: 190 RVA: 0x00004170 File Offset: 0x00002370
public override void CloneDataFromRead(PngChunk other)
{
PngChunkSRGB pngChunkSRGB = (PngChunkSRGB)other;
this.Intent = pngChunkSRGB.Intent;
}
// Token: 0x04000065 RID: 101
public const string ID = "sRGB";
// Token: 0x04000066 RID: 102
public const int RENDER_INTENT_Perceptual = 0;
// Token: 0x04000067 RID: 103
public const int RENDER_INTENT_Relative_colorimetric = 1;
// Token: 0x04000068 RID: 104
public const int RENDER_INTENT_Saturation = 2;
// Token: 0x04000069 RID: 105
public const int RENDER_INTENT_Absolute_colorimetric = 3;
}
}
+53
View File
@@ -0,0 +1,53 @@
using System;
namespace Hjg.Pngcs.Chunks
{
// Token: 0x02000012 RID: 18
public class PngChunkSTER : PngChunkSingle
{
// Token: 0x17000005 RID: 5
// (get) Token: 0x0600007B RID: 123 RVA: 0x00003556 File Offset: 0x00001756
// (set) Token: 0x0600007C RID: 124 RVA: 0x0000355E File Offset: 0x0000175E
public byte Mode { get; set; }
// Token: 0x0600007D RID: 125 RVA: 0x00003567 File Offset: 0x00001767
public PngChunkSTER(ImageInfo info)
: base("sTER", info)
{
}
// Token: 0x0600007E RID: 126 RVA: 0x00003575 File Offset: 0x00001775
public override PngChunk.ChunkOrderingConstraint GetOrderingConstraint()
{
return PngChunk.ChunkOrderingConstraint.BEFORE_IDAT;
}
// Token: 0x0600007F RID: 127 RVA: 0x00003578 File Offset: 0x00001778
public override ChunkRaw CreateRawChunk()
{
ChunkRaw chunkRaw = base.createEmptyChunk(1, true);
chunkRaw.Data[0] = this.Mode;
return chunkRaw;
}
// Token: 0x06000080 RID: 128 RVA: 0x0000359D File Offset: 0x0000179D
public override void ParseFromRaw(ChunkRaw chunk)
{
if (chunk.Length != 1)
{
throw new PngjException("bad chunk length " + chunk);
}
this.Mode = chunk.Data[0];
}
// Token: 0x06000081 RID: 129 RVA: 0x000035C8 File Offset: 0x000017C8
public override void CloneDataFromRead(PngChunk other)
{
PngChunkSTER pngChunkSTER = (PngChunkSTER)other;
this.Mode = pngChunkSTER.Mode;
}
// Token: 0x0400004A RID: 74
public const string ID = "sTER";
}
}
+34
View File
@@ -0,0 +1,34 @@
using System;
namespace Hjg.Pngcs.Chunks
{
// Token: 0x0200000F RID: 15
public abstract class PngChunkSingle : PngChunk
{
// Token: 0x0600005D RID: 93 RVA: 0x0000306A File Offset: 0x0000126A
public PngChunkSingle(string id, ImageInfo imgInfo)
: base(id, imgInfo)
{
}
// Token: 0x0600005E RID: 94 RVA: 0x00003074 File Offset: 0x00001274
public sealed override bool AllowsMultiple()
{
return false;
}
// Token: 0x0600005F RID: 95 RVA: 0x00003078 File Offset: 0x00001278
public override int GetHashCode()
{
int num = 31;
int num2 = 1;
return num * num2 + ((this.Id == null) ? 0 : this.Id.GetHashCode());
}
// Token: 0x06000060 RID: 96 RVA: 0x000030A6 File Offset: 0x000012A6
public override bool Equals(object obj)
{
return obj is PngChunkSingle && this.Id != null && this.Id.Equals(((PngChunkSingle)obj).Id);
}
}
}
+45
View File
@@ -0,0 +1,45 @@
using System;
namespace Hjg.Pngcs.Chunks
{
// Token: 0x02000010 RID: 16
internal class PngChunkSkipped : PngChunk
{
// Token: 0x06000061 RID: 97 RVA: 0x000030D0 File Offset: 0x000012D0
internal PngChunkSkipped(string id, ImageInfo imgInfo, int clen)
: base(id, imgInfo)
{
base.Length = clen;
}
// Token: 0x06000062 RID: 98 RVA: 0x000030E1 File Offset: 0x000012E1
public sealed override bool AllowsMultiple()
{
return true;
}
// Token: 0x06000063 RID: 99 RVA: 0x000030E4 File Offset: 0x000012E4
public sealed override ChunkRaw CreateRawChunk()
{
throw new PngjException("Non supported for a skipped chunk");
}
// Token: 0x06000064 RID: 100 RVA: 0x000030F0 File Offset: 0x000012F0
public sealed override void ParseFromRaw(ChunkRaw c)
{
throw new PngjException("Non supported for a skipped chunk");
}
// Token: 0x06000065 RID: 101 RVA: 0x000030FC File Offset: 0x000012FC
public sealed override void CloneDataFromRead(PngChunk other)
{
throw new PngjException("Non supported for a skipped chunk");
}
// Token: 0x06000066 RID: 102 RVA: 0x00003108 File Offset: 0x00001308
public override PngChunk.ChunkOrderingConstraint GetOrderingConstraint()
{
return PngChunk.ChunkOrderingConstraint.NONE;
}
}
}
+54
View File
@@ -0,0 +1,54 @@
using System;
namespace Hjg.Pngcs.Chunks
{
// Token: 0x0200002F RID: 47
public class PngChunkTEXT : PngChunkTextVar
{
// Token: 0x060001A7 RID: 423 RVA: 0x00006F71 File Offset: 0x00005171
public PngChunkTEXT(ImageInfo info)
: base("tEXt", info)
{
}
// Token: 0x060001A8 RID: 424 RVA: 0x00006F80 File Offset: 0x00005180
public override ChunkRaw CreateRawChunk()
{
if (this.key.Length == 0)
{
throw new PngjException("Text chunk key must be non empty");
}
byte[] bytes = PngHelperInternal.charsetLatin1.GetBytes(this.key);
byte[] bytes2 = PngHelperInternal.charsetLatin1.GetBytes(this.val);
ChunkRaw chunkRaw = base.createEmptyChunk(bytes.Length + bytes2.Length + 1, true);
Array.Copy(bytes, 0, chunkRaw.Data, 0, bytes.Length);
chunkRaw.Data[bytes.Length] = 0;
Array.Copy(bytes2, 0, chunkRaw.Data, bytes.Length + 1, bytes2.Length);
return chunkRaw;
}
// Token: 0x060001A9 RID: 425 RVA: 0x0000700C File Offset: 0x0000520C
public override void ParseFromRaw(ChunkRaw c)
{
int num = 0;
while (num < c.Data.Length && c.Data[num] != 0)
{
num++;
}
this.key = PngHelperInternal.charsetLatin1.GetString(c.Data, 0, num);
num++;
this.val = ((num < c.Data.Length) ? PngHelperInternal.charsetLatin1.GetString(c.Data, num, c.Data.Length - num) : "");
}
// Token: 0x060001AA RID: 426 RVA: 0x00007088 File Offset: 0x00005288
public override void CloneDataFromRead(PngChunk other)
{
PngChunkTEXT pngChunkTEXT = (PngChunkTEXT)other;
this.key = pngChunkTEXT.key;
this.val = pngChunkTEXT.val;
}
// Token: 0x040000E4 RID: 228
public const string ID = "tEXt";
}
}
+116
View File
@@ -0,0 +1,116 @@
using System;
namespace Hjg.Pngcs.Chunks
{
// Token: 0x02000030 RID: 48
public class PngChunkTIME : PngChunkSingle
{
// Token: 0x060001AB RID: 427 RVA: 0x000070B4 File Offset: 0x000052B4
public PngChunkTIME(ImageInfo info)
: base("tIME", info)
{
}
// Token: 0x060001AC RID: 428 RVA: 0x000070C2 File Offset: 0x000052C2
public override PngChunk.ChunkOrderingConstraint GetOrderingConstraint()
{
return PngChunk.ChunkOrderingConstraint.NONE;
}
// Token: 0x060001AD RID: 429 RVA: 0x000070C8 File Offset: 0x000052C8
public override ChunkRaw CreateRawChunk()
{
ChunkRaw chunkRaw = base.createEmptyChunk(7, true);
PngHelperInternal.WriteInt2tobytes(this.year, chunkRaw.Data, 0);
chunkRaw.Data[2] = (byte)this.mon;
chunkRaw.Data[3] = (byte)this.day;
chunkRaw.Data[4] = (byte)this.hour;
chunkRaw.Data[5] = (byte)this.min;
chunkRaw.Data[6] = (byte)this.sec;
return chunkRaw;
}
// Token: 0x060001AE RID: 430 RVA: 0x0000713C File Offset: 0x0000533C
public override void ParseFromRaw(ChunkRaw chunk)
{
if (chunk.Length != 7)
{
throw new PngjException("bad chunk " + chunk);
}
this.year = PngHelperInternal.ReadInt2fromBytes(chunk.Data, 0);
this.mon = PngHelperInternal.ReadInt1fromByte(chunk.Data, 2);
this.day = PngHelperInternal.ReadInt1fromByte(chunk.Data, 3);
this.hour = PngHelperInternal.ReadInt1fromByte(chunk.Data, 4);
this.min = PngHelperInternal.ReadInt1fromByte(chunk.Data, 5);
this.sec = PngHelperInternal.ReadInt1fromByte(chunk.Data, 6);
}
// Token: 0x060001AF RID: 431 RVA: 0x000071D0 File Offset: 0x000053D0
public override void CloneDataFromRead(PngChunk other)
{
PngChunkTIME pngChunkTIME = (PngChunkTIME)other;
this.year = pngChunkTIME.year;
this.mon = pngChunkTIME.mon;
this.day = pngChunkTIME.day;
this.hour = pngChunkTIME.hour;
this.min = pngChunkTIME.min;
this.sec = pngChunkTIME.sec;
}
// Token: 0x060001B0 RID: 432 RVA: 0x0000722C File Offset: 0x0000542C
public void SetNow(int secsAgo)
{
DateTime now = DateTime.Now;
this.year = now.Year;
this.mon = now.Month;
this.day = now.Day;
this.hour = now.Hour;
this.min = now.Minute;
this.sec = now.Second;
}
// Token: 0x060001B1 RID: 433 RVA: 0x0000728D File Offset: 0x0000548D
internal void SetYMDHMS(int yearx, int monx, int dayx, int hourx, int minx, int secx)
{
this.year = yearx;
this.mon = monx;
this.day = dayx;
this.hour = hourx;
this.min = minx;
this.sec = secx;
}
// Token: 0x060001B2 RID: 434 RVA: 0x000072BC File Offset: 0x000054BC
public int[] GetYMDHMS()
{
return new int[] { this.year, this.mon, this.day, this.hour, this.min, this.sec };
}
// Token: 0x060001B3 RID: 435 RVA: 0x00007308 File Offset: 0x00005508
public string GetAsString()
{
return string.Format("%04d/%02d/%02d %02d:%02d:%02d", new object[] { this.year, this.mon, this.day, this.hour, this.min, this.sec });
}
// Token: 0x040000E5 RID: 229
public const string ID = "tIME";
// Token: 0x040000E6 RID: 230
private int year;
// Token: 0x040000E7 RID: 231
private int mon;
// Token: 0x040000E8 RID: 232
private int day;
// Token: 0x040000E9 RID: 233
private int hour;
// Token: 0x040000EA RID: 234
private int min;
// Token: 0x040000EB RID: 235
private int sec;
}
}
+180
View File
@@ -0,0 +1,180 @@
using System;
namespace Hjg.Pngcs.Chunks
{
// Token: 0x02000031 RID: 49
public class PngChunkTRNS : PngChunkSingle
{
// Token: 0x060001B4 RID: 436 RVA: 0x0000737B File Offset: 0x0000557B
public PngChunkTRNS(ImageInfo info)
: base("tRNS", info)
{
}
// Token: 0x060001B5 RID: 437 RVA: 0x00007389 File Offset: 0x00005589
public override PngChunk.ChunkOrderingConstraint GetOrderingConstraint()
{
return PngChunk.ChunkOrderingConstraint.AFTER_PLTE_BEFORE_IDAT;
}
// Token: 0x060001B6 RID: 438 RVA: 0x0000738C File Offset: 0x0000558C
public override ChunkRaw CreateRawChunk()
{
ChunkRaw chunkRaw;
if (this.ImgInfo.Greyscale)
{
chunkRaw = base.createEmptyChunk(2, true);
PngHelperInternal.WriteInt2tobytes(this.gray, chunkRaw.Data, 0);
}
else if (this.ImgInfo.Indexed)
{
chunkRaw = base.createEmptyChunk(this.paletteAlpha.Length, true);
for (int i = 0; i < chunkRaw.Length; i++)
{
chunkRaw.Data[i] = (byte)this.paletteAlpha[i];
}
}
else
{
chunkRaw = base.createEmptyChunk(6, true);
PngHelperInternal.WriteInt2tobytes(this.red, chunkRaw.Data, 0);
PngHelperInternal.WriteInt2tobytes(this.green, chunkRaw.Data, 0);
PngHelperInternal.WriteInt2tobytes(this.blue, chunkRaw.Data, 0);
}
return chunkRaw;
}
// Token: 0x060001B7 RID: 439 RVA: 0x0000744C File Offset: 0x0000564C
public override void ParseFromRaw(ChunkRaw c)
{
if (this.ImgInfo.Greyscale)
{
this.gray = PngHelperInternal.ReadInt2fromBytes(c.Data, 0);
return;
}
if (this.ImgInfo.Indexed)
{
int num = c.Data.Length;
this.paletteAlpha = new int[num];
for (int i = 0; i < num; i++)
{
this.paletteAlpha[i] = (int)(c.Data[i] & byte.MaxValue);
}
return;
}
this.red = PngHelperInternal.ReadInt2fromBytes(c.Data, 0);
this.green = PngHelperInternal.ReadInt2fromBytes(c.Data, 2);
this.blue = PngHelperInternal.ReadInt2fromBytes(c.Data, 4);
}
// Token: 0x060001B8 RID: 440 RVA: 0x000074F4 File Offset: 0x000056F4
public override void CloneDataFromRead(PngChunk other)
{
PngChunkTRNS pngChunkTRNS = (PngChunkTRNS)other;
this.gray = pngChunkTRNS.gray;
this.red = pngChunkTRNS.red;
this.green = pngChunkTRNS.red;
this.blue = pngChunkTRNS.red;
if (pngChunkTRNS.paletteAlpha != null)
{
this.paletteAlpha = new int[pngChunkTRNS.paletteAlpha.Length];
Array.Copy(pngChunkTRNS.paletteAlpha, 0, this.paletteAlpha, 0, this.paletteAlpha.Length);
}
}
// Token: 0x060001B9 RID: 441 RVA: 0x0000756E File Offset: 0x0000576E
public void SetRGB(int r, int g, int b)
{
if (this.ImgInfo.Greyscale || this.ImgInfo.Indexed)
{
throw new PngjException("only rgb or rgba images support this");
}
this.red = r;
this.green = g;
this.blue = b;
}
// Token: 0x060001BA RID: 442 RVA: 0x000075AC File Offset: 0x000057AC
public int[] GetRGB()
{
if (this.ImgInfo.Greyscale || this.ImgInfo.Indexed)
{
throw new PngjException("only rgb or rgba images support this");
}
return new int[] { this.red, this.green, this.blue };
}
// Token: 0x060001BB RID: 443 RVA: 0x00007601 File Offset: 0x00005801
public void SetGray(int g)
{
if (!this.ImgInfo.Greyscale)
{
throw new PngjException("only grayscale images support this");
}
this.gray = g;
}
// Token: 0x060001BC RID: 444 RVA: 0x00007622 File Offset: 0x00005822
public int GetGray()
{
if (!this.ImgInfo.Greyscale)
{
throw new PngjException("only grayscale images support this");
}
return this.gray;
}
// Token: 0x060001BD RID: 445 RVA: 0x00007642 File Offset: 0x00005842
public void SetPalletteAlpha(int[] palAlpha)
{
if (!this.ImgInfo.Indexed)
{
throw new PngjException("only indexed images support this");
}
this.paletteAlpha = palAlpha;
}
// Token: 0x060001BE RID: 446 RVA: 0x00007664 File Offset: 0x00005864
public void setIndexEntryAsTransparent(int palAlphaIndex)
{
if (!this.ImgInfo.Indexed)
{
throw new PngjException("only indexed images support this");
}
this.paletteAlpha = new int[] { palAlphaIndex + 1 };
for (int i = 0; i < palAlphaIndex; i++)
{
this.paletteAlpha[i] = 255;
}
this.paletteAlpha[palAlphaIndex] = 0;
}
// Token: 0x060001BF RID: 447 RVA: 0x000076BF File Offset: 0x000058BF
public int[] GetPalletteAlpha()
{
if (!this.ImgInfo.Indexed)
{
throw new PngjException("only indexed images support this");
}
return this.paletteAlpha;
}
// Token: 0x040000EC RID: 236
public const string ID = "tRNS";
// Token: 0x040000ED RID: 237
private int gray;
// Token: 0x040000EE RID: 238
private int red;
// Token: 0x040000EF RID: 239
private int green;
// Token: 0x040000F0 RID: 240
private int blue;
// Token: 0x040000F1 RID: 241
private int[] paletteAlpha;
}
}
+106
View File
@@ -0,0 +1,106 @@
using System;
namespace Hjg.Pngcs.Chunks
{
// Token: 0x02000029 RID: 41
public abstract class PngChunkTextVar : PngChunkMultiple
{
// Token: 0x06000174 RID: 372 RVA: 0x00006748 File Offset: 0x00004948
protected internal PngChunkTextVar(string id, ImageInfo info)
: base(id, info)
{
}
// Token: 0x06000175 RID: 373 RVA: 0x00006752 File Offset: 0x00004952
public override PngChunk.ChunkOrderingConstraint GetOrderingConstraint()
{
return PngChunk.ChunkOrderingConstraint.NONE;
}
// Token: 0x06000176 RID: 374 RVA: 0x00006755 File Offset: 0x00004955
public string GetKey()
{
return this.key;
}
// Token: 0x06000177 RID: 375 RVA: 0x0000675D File Offset: 0x0000495D
public string GetVal()
{
return this.val;
}
// Token: 0x06000178 RID: 376 RVA: 0x00006765 File Offset: 0x00004965
public void SetKeyVal(string key, string val)
{
this.key = key;
this.val = val;
}
// Token: 0x040000C3 RID: 195
public const string KEY_Title = "Title";
// Token: 0x040000C4 RID: 196
public const string KEY_Author = "Author";
// Token: 0x040000C5 RID: 197
public const string KEY_Description = "Description";
// Token: 0x040000C6 RID: 198
public const string KEY_Copyright = "Copyright";
// Token: 0x040000C7 RID: 199
public const string KEY_Creation_Time = "Creation Time";
// Token: 0x040000C8 RID: 200
public const string KEY_Software = "Software";
// Token: 0x040000C9 RID: 201
public const string KEY_Disclaimer = "Disclaimer";
// Token: 0x040000CA RID: 202
public const string KEY_Warning = "Warning";
// Token: 0x040000CB RID: 203
public const string KEY_Source = "Source";
// Token: 0x040000CC RID: 204
public const string KEY_Comment = "Comment";
// Token: 0x040000CD RID: 205
protected internal string key;
// Token: 0x040000CE RID: 206
protected internal string val;
// Token: 0x0200002A RID: 42
public class PngTxtInfo
{
// Token: 0x040000CF RID: 207
public string title;
// Token: 0x040000D0 RID: 208
public string author;
// Token: 0x040000D1 RID: 209
public string description;
// Token: 0x040000D2 RID: 210
public string creation_time;
// Token: 0x040000D3 RID: 211
public string software;
// Token: 0x040000D4 RID: 212
public string disclaimer;
// Token: 0x040000D5 RID: 213
public string warning;
// Token: 0x040000D6 RID: 214
public string source;
// Token: 0x040000D7 RID: 215
public string comment;
}
}
}
+63
View File
@@ -0,0 +1,63 @@
using System;
namespace Hjg.Pngcs.Chunks
{
// Token: 0x0200002C RID: 44
public class PngChunkUNKNOWN : PngChunkMultiple
{
// Token: 0x06000184 RID: 388 RVA: 0x00006A23 File Offset: 0x00004C23
public PngChunkUNKNOWN(string id, ImageInfo info)
: base(id, info)
{
}
// Token: 0x06000185 RID: 389 RVA: 0x00006A2D File Offset: 0x00004C2D
private PngChunkUNKNOWN(PngChunkUNKNOWN c, ImageInfo info)
: base(c.Id, info)
{
Array.Copy(c.data, 0, this.data, 0, c.data.Length);
}
// Token: 0x06000186 RID: 390 RVA: 0x00006A57 File Offset: 0x00004C57
public override PngChunk.ChunkOrderingConstraint GetOrderingConstraint()
{
return PngChunk.ChunkOrderingConstraint.NONE;
}
// Token: 0x06000187 RID: 391 RVA: 0x00006A5C File Offset: 0x00004C5C
public override ChunkRaw CreateRawChunk()
{
ChunkRaw chunkRaw = base.createEmptyChunk(this.data.Length, false);
chunkRaw.Data = this.data;
return chunkRaw;
}
// Token: 0x06000188 RID: 392 RVA: 0x00006A86 File Offset: 0x00004C86
public override void ParseFromRaw(ChunkRaw c)
{
this.data = c.Data;
}
// Token: 0x06000189 RID: 393 RVA: 0x00006A94 File Offset: 0x00004C94
public byte[] GetData()
{
return this.data;
}
// Token: 0x0600018A RID: 394 RVA: 0x00006A9C File Offset: 0x00004C9C
public void SetData(byte[] data_0)
{
this.data = data_0;
}
// Token: 0x0600018B RID: 395 RVA: 0x00006AA8 File Offset: 0x00004CA8
public override void CloneDataFromRead(PngChunk other)
{
PngChunkUNKNOWN pngChunkUNKNOWN = (PngChunkUNKNOWN)other;
this.data = pngChunkUNKNOWN.data;
}
// Token: 0x040000DC RID: 220
private byte[] data;
}
}
+71
View File
@@ -0,0 +1,71 @@
using System;
using System.IO;
namespace Hjg.Pngcs.Chunks
{
// Token: 0x02000032 RID: 50
public class PngChunkZTXT : PngChunkTextVar
{
// Token: 0x060001C0 RID: 448 RVA: 0x000076DF File Offset: 0x000058DF
public PngChunkZTXT(ImageInfo info)
: base("zTXt", info)
{
}
// Token: 0x060001C1 RID: 449 RVA: 0x000076F0 File Offset: 0x000058F0
public override ChunkRaw CreateRawChunk()
{
if (this.key.Length == 0)
{
throw new PngjException("Text chunk key must be non empty");
}
MemoryStream memoryStream = new MemoryStream();
ChunkHelper.WriteBytesToStream(memoryStream, ChunkHelper.ToBytes(this.key));
memoryStream.WriteByte(0);
memoryStream.WriteByte(0);
byte[] array = ChunkHelper.compressBytes(ChunkHelper.ToBytes(this.val), true);
ChunkHelper.WriteBytesToStream(memoryStream, array);
byte[] array2 = memoryStream.ToArray();
ChunkRaw chunkRaw = base.createEmptyChunk(array2.Length, false);
chunkRaw.Data = array2;
return chunkRaw;
}
// Token: 0x060001C2 RID: 450 RVA: 0x00007770 File Offset: 0x00005970
public override void ParseFromRaw(ChunkRaw c)
{
int num = -1;
for (int i = 0; i < c.Data.Length; i++)
{
if (c.Data[i] == 0)
{
num = i;
break;
}
}
if (num < 0 || num > c.Data.Length - 2)
{
throw new PngjException("bad zTXt chunk: no separator found");
}
this.key = ChunkHelper.ToString(c.Data, 0, num);
int num2 = (int)c.Data[num + 1];
if (num2 != 0)
{
throw new PngjException("bad zTXt chunk: unknown compression method");
}
byte[] array = ChunkHelper.compressBytes(c.Data, num + 2, c.Data.Length - num - 2, false);
this.val = ChunkHelper.ToString(array);
}
// Token: 0x060001C3 RID: 451 RVA: 0x00007810 File Offset: 0x00005A10
public override void CloneDataFromRead(PngChunk other)
{
PngChunkZTXT pngChunkZTXT = (PngChunkZTXT)other;
this.key = pngChunkZTXT.key;
this.val = pngChunkZTXT.val;
}
// Token: 0x040000F2 RID: 242
public const string ID = "zTXt";
}
}
+218
View File
@@ -0,0 +1,218 @@
using System;
using System.Collections.Generic;
namespace Hjg.Pngcs.Chunks
{
// Token: 0x02000011 RID: 17
public class PngMetadata
{
// Token: 0x06000067 RID: 103 RVA: 0x0000310B File Offset: 0x0000130B
internal PngMetadata(ChunksList chunks)
{
this.chunkList = chunks;
if (chunks is ChunksListForWrite)
{
this.ReadOnly = false;
return;
}
this.ReadOnly = true;
}
// Token: 0x06000068 RID: 104 RVA: 0x00003134 File Offset: 0x00001334
public void QueueChunk(PngChunk chunk, bool lazyOverwrite)
{
ChunksListForWrite chunkListW = this.getChunkListW();
if (this.ReadOnly)
{
throw new PngjException("cannot set chunk : readonly metadata");
}
if (lazyOverwrite)
{
ChunkHelper.TrimList(chunkListW.GetQueuedChunks(), new ChunkPredicateEquiv(chunk));
}
chunkListW.Queue(chunk);
}
// Token: 0x06000069 RID: 105 RVA: 0x00003178 File Offset: 0x00001378
public void QueueChunk(PngChunk chunk)
{
this.QueueChunk(chunk, true);
}
// Token: 0x0600006A RID: 106 RVA: 0x00003182 File Offset: 0x00001382
private ChunksListForWrite getChunkListW()
{
return (ChunksListForWrite)this.chunkList;
}
// Token: 0x0600006B RID: 107 RVA: 0x00003190 File Offset: 0x00001390
public double[] GetDpi()
{
PngChunk byId = this.chunkList.GetById1("pHYs", true);
if (byId == null)
{
return new double[] { -1.0, -1.0 };
}
return ((PngChunkPHYS)byId).GetAsDpi2();
}
// Token: 0x0600006C RID: 108 RVA: 0x000031E0 File Offset: 0x000013E0
public void SetDpi(double dpix, double dpiy)
{
PngChunkPHYS pngChunkPHYS = new PngChunkPHYS(this.chunkList.imageInfo);
pngChunkPHYS.SetAsDpi2(dpix, dpiy);
this.QueueChunk(pngChunkPHYS);
}
// Token: 0x0600006D RID: 109 RVA: 0x0000320D File Offset: 0x0000140D
public void SetDpi(double dpi)
{
this.SetDpi(dpi, dpi);
}
// Token: 0x0600006E RID: 110 RVA: 0x00003218 File Offset: 0x00001418
public PngChunkTIME SetTimeNow(int nsecs)
{
PngChunkTIME pngChunkTIME = new PngChunkTIME(this.chunkList.imageInfo);
pngChunkTIME.SetNow(nsecs);
this.QueueChunk(pngChunkTIME);
return pngChunkTIME;
}
// Token: 0x0600006F RID: 111 RVA: 0x00003245 File Offset: 0x00001445
public PngChunkTIME SetTimeNow()
{
return this.SetTimeNow(0);
}
// Token: 0x06000070 RID: 112 RVA: 0x00003250 File Offset: 0x00001450
public PngChunkTIME SetTimeYMDHMS(int year, int mon, int day, int hour, int min, int sec)
{
PngChunkTIME pngChunkTIME = new PngChunkTIME(this.chunkList.imageInfo);
pngChunkTIME.SetYMDHMS(year, mon, day, hour, min, sec);
this.QueueChunk(pngChunkTIME, true);
return pngChunkTIME;
}
// Token: 0x06000071 RID: 113 RVA: 0x00003286 File Offset: 0x00001486
public PngChunkTIME GetTime()
{
return (PngChunkTIME)this.chunkList.GetById1("tIME");
}
// Token: 0x06000072 RID: 114 RVA: 0x000032A0 File Offset: 0x000014A0
public string GetTimeAsString()
{
PngChunkTIME time = this.GetTime();
if (time != null)
{
return time.GetAsString();
}
return "";
}
// Token: 0x06000073 RID: 115 RVA: 0x000032C4 File Offset: 0x000014C4
public PngChunkTextVar SetText(string key, string val, bool useLatin1, bool compress)
{
if (compress && !useLatin1)
{
throw new PngjException("cannot compress non latin text");
}
PngChunkTextVar pngChunkTextVar;
if (useLatin1)
{
if (compress)
{
pngChunkTextVar = new PngChunkZTXT(this.chunkList.imageInfo);
}
else
{
pngChunkTextVar = new PngChunkTEXT(this.chunkList.imageInfo);
}
}
else
{
pngChunkTextVar = new PngChunkITXT(this.chunkList.imageInfo);
((PngChunkITXT)pngChunkTextVar).SetLangtag(key);
}
pngChunkTextVar.SetKeyVal(key, val);
this.QueueChunk(pngChunkTextVar, true);
return pngChunkTextVar;
}
// Token: 0x06000074 RID: 116 RVA: 0x0000333E File Offset: 0x0000153E
public PngChunkTextVar SetText(string key, string val)
{
return this.SetText(key, val, false, false);
}
// Token: 0x06000075 RID: 117 RVA: 0x0000334C File Offset: 0x0000154C
public List<PngChunkTextVar> GetTxtsForKey(string key)
{
List<PngChunkTextVar> list = new List<PngChunkTextVar>();
foreach (PngChunk pngChunk in this.chunkList.GetById("tEXt", key))
{
list.Add((PngChunkTextVar)pngChunk);
}
foreach (PngChunk pngChunk2 in this.chunkList.GetById("zTXt", key))
{
list.Add((PngChunkTextVar)pngChunk2);
}
foreach (PngChunk pngChunk3 in this.chunkList.GetById("iTXt", key))
{
list.Add((PngChunkTextVar)pngChunk3);
}
return list;
}
// Token: 0x06000076 RID: 118 RVA: 0x00003460 File Offset: 0x00001660
public string GetTxtForKey(string key)
{
string text = "";
List<PngChunkTextVar> txtsForKey = this.GetTxtsForKey(key);
if (txtsForKey.Count == 0)
{
return text;
}
foreach (PngChunkTextVar pngChunkTextVar in txtsForKey)
{
text = text + pngChunkTextVar.GetVal() + "\n";
}
return text.Trim();
}
// Token: 0x06000077 RID: 119 RVA: 0x000034D8 File Offset: 0x000016D8
public PngChunkPLTE GetPLTE()
{
return (PngChunkPLTE)this.chunkList.GetById1("PLTE");
}
// Token: 0x06000078 RID: 120 RVA: 0x000034F0 File Offset: 0x000016F0
public PngChunkPLTE CreatePLTEChunk()
{
PngChunkPLTE pngChunkPLTE = new PngChunkPLTE(this.chunkList.imageInfo);
this.QueueChunk(pngChunkPLTE);
return pngChunkPLTE;
}
// Token: 0x06000079 RID: 121 RVA: 0x00003516 File Offset: 0x00001716
public PngChunkTRNS GetTRNS()
{
return (PngChunkTRNS)this.chunkList.GetById1("tRNS");
}
// Token: 0x0600007A RID: 122 RVA: 0x00003530 File Offset: 0x00001730
public PngChunkTRNS CreateTRNSChunk()
{
PngChunkTRNS pngChunkTRNS = new PngChunkTRNS(this.chunkList.imageInfo);
this.QueueChunk(pngChunkTRNS);
return pngChunkTRNS;
}
// Token: 0x04000048 RID: 72
private readonly ChunksList chunkList;
// Token: 0x04000049 RID: 73
private readonly bool ReadOnly;
}
}
+41
View File
@@ -0,0 +1,41 @@
using System;
using System.IO;
namespace Hjg.Pngcs
{
// Token: 0x0200001D RID: 29
public class FileHelper
{
// Token: 0x060000F1 RID: 241 RVA: 0x00004DA0 File Offset: 0x00002FA0
public static Stream OpenFileForReading(string file)
{
if (file == null || !File.Exists(file))
{
throw new PngjInputException("Cannot open file for reading (" + file + ")");
}
return new FileStream(file, FileMode.Open);
}
// Token: 0x060000F2 RID: 242 RVA: 0x00004DDC File Offset: 0x00002FDC
public static Stream OpenFileForWriting(string file, bool allowOverwrite)
{
if (File.Exists(file) && !allowOverwrite)
{
throw new PngjOutputException("File already exists (" + file + ") and overwrite=false");
}
return new FileStream(file, FileMode.Create);
}
// Token: 0x060000F3 RID: 243 RVA: 0x00004E15 File Offset: 0x00003015
public static PngWriter CreatePngWriter(string fileName, ImageInfo imgInfo, bool allowOverwrite)
{
return new PngWriter(FileHelper.OpenFileForWriting(fileName, allowOverwrite), imgInfo, fileName);
}
// Token: 0x060000F4 RID: 244 RVA: 0x00004E25 File Offset: 0x00003025
public static PngReader CreatePngReader(string fileName)
{
return new PngReader(FileHelper.OpenFileForReading(fileName), fileName);
}
}
}
+29
View File
@@ -0,0 +1,29 @@
using System;
namespace Hjg.Pngcs
{
// Token: 0x02000033 RID: 51
public enum FilterType
{
// Token: 0x040000F4 RID: 244
FILTER_NONE,
// Token: 0x040000F5 RID: 245
FILTER_SUB,
// Token: 0x040000F6 RID: 246
FILTER_UP,
// Token: 0x040000F7 RID: 247
FILTER_AVERAGE,
// Token: 0x040000F8 RID: 248
FILTER_PAETH,
// Token: 0x040000F9 RID: 249
FILTER_DEFAULT = -1,
// Token: 0x040000FA RID: 250
FILTER_AGGRESSIVE = -2,
// Token: 0x040000FB RID: 251
FILTER_VERYAGGRESSIVE = -3,
// Token: 0x040000FC RID: 252
FILTER_CYCLIC = -50,
// Token: 0x040000FD RID: 253
FILTER_UNKNOWN = -100
}
}
+149
View File
@@ -0,0 +1,149 @@
using System;
namespace Hjg.Pngcs
{
// Token: 0x0200001C RID: 28
internal class FilterWriteStrategy
{
// Token: 0x060000EA RID: 234 RVA: 0x00004B18 File Offset: 0x00002D18
internal FilterWriteStrategy(ImageInfo imgInfo, FilterType configuredType)
{
this.imgInfo = imgInfo;
this.configuredType = configuredType;
if (configuredType < FilterType.FILTER_NONE)
{
if ((imgInfo.Rows < 8 && imgInfo.Cols < 8) || imgInfo.Indexed || imgInfo.BitDepth < 8)
{
this.currentType = FilterType.FILTER_NONE;
}
else
{
this.currentType = FilterType.FILTER_PAETH;
}
}
else
{
this.currentType = configuredType;
}
if (configuredType == FilterType.FILTER_AGGRESSIVE)
{
this.discoverEachLines = FilterWriteStrategy.COMPUTE_STATS_EVERY_N_LINES;
}
if (configuredType == FilterType.FILTER_VERYAGGRESSIVE)
{
this.discoverEachLines = 1;
}
}
// Token: 0x060000EB RID: 235 RVA: 0x00004BE6 File Offset: 0x00002DE6
internal bool shouldTestAll(int rown)
{
if (this.discoverEachLines > 0 && this.lastRowTested + this.discoverEachLines <= rown)
{
this.currentType = FilterType.FILTER_UNKNOWN;
return true;
}
return false;
}
// Token: 0x060000EC RID: 236 RVA: 0x00004C0C File Offset: 0x00002E0C
internal void setPreference(double none, double sub, double up, double ave, double paeth)
{
this.preference = new double[] { none, sub, up, ave, paeth };
}
// Token: 0x060000ED RID: 237 RVA: 0x00004C3D File Offset: 0x00002E3D
internal bool computesStatistics()
{
return this.discoverEachLines > 0;
}
// Token: 0x060000EE RID: 238 RVA: 0x00004C48 File Offset: 0x00002E48
internal void fillResultsForFilter(int rown, FilterType type, double sum, int[] histo, bool tentative)
{
this.lastRowTested = rown;
this.lastSums[(int)type] = sum;
if (histo != null)
{
double num = ((rown == 0) ? 0.0 : 0.3);
double num2 = 1.0 - num;
double num3 = 0.0;
for (int i = 0; i < 256; i++)
{
double num4 = (double)histo[i] / (double)this.imgInfo.Cols;
num4 = this.histogram1[i] * num + num4 * num2;
if (tentative)
{
num3 += ((num4 > 1E-08) ? (num4 * Math.Log(num4)) : 0.0);
}
else
{
this.histogram1[i] = num4;
}
}
this.lastEntropies[(int)type] = -num3;
}
}
// Token: 0x060000EF RID: 239 RVA: 0x00004D10 File Offset: 0x00002F10
internal FilterType gimmeFilterType(int rown, bool useEntropy)
{
if (this.currentType == FilterType.FILTER_UNKNOWN)
{
if (rown == 0)
{
this.currentType = FilterType.FILTER_SUB;
}
else
{
double num = double.MaxValue;
for (int i = 0; i < 5; i++)
{
double num2 = (useEntropy ? this.lastEntropies[i] : this.lastSums[i]);
num2 /= this.preference[i];
if (num2 <= num)
{
num = num2;
this.currentType = (FilterType)i;
}
}
}
}
if (this.configuredType == FilterType.FILTER_CYCLIC)
{
this.currentType = (this.currentType + 1) % (FilterType)5;
}
return this.currentType;
}
// Token: 0x04000088 RID: 136
private static readonly int COMPUTE_STATS_EVERY_N_LINES = 8;
// Token: 0x04000089 RID: 137
private readonly ImageInfo imgInfo;
// Token: 0x0400008A RID: 138
private readonly FilterType configuredType;
// Token: 0x0400008B RID: 139
private FilterType currentType;
// Token: 0x0400008C RID: 140
private int lastRowTested = -1000000;
// Token: 0x0400008D RID: 141
private double[] lastSums = new double[5];
// Token: 0x0400008E RID: 142
private double[] lastEntropies = new double[5];
// Token: 0x0400008F RID: 143
private double[] preference = new double[] { 1.1, 1.1, 1.1, 1.1, 1.2 };
// Token: 0x04000090 RID: 144
private int discoverEachLines = -1;
// Token: 0x04000091 RID: 145
private double[] histogram1 = new double[256];
}
}
+160
View File
@@ -0,0 +1,160 @@
using System;
namespace Hjg.Pngcs
{
// Token: 0x0200001F RID: 31
public class ImageInfo
{
// Token: 0x060000F9 RID: 249 RVA: 0x00004E98 File Offset: 0x00003098
public ImageInfo(int cols, int rows, int bitdepth, bool alpha)
: this(cols, rows, bitdepth, alpha, false, false)
{
}
// Token: 0x060000FA RID: 250 RVA: 0x00004EA8 File Offset: 0x000030A8
public ImageInfo(int cols, int rows, int bitdepth, bool alpha, bool grayscale, bool palette)
{
this.Cols = cols;
this.Rows = rows;
this.Alpha = alpha;
this.Indexed = palette;
this.Greyscale = grayscale;
if (this.Greyscale && palette)
{
throw new PngjException("palette and greyscale are exclusive");
}
this.Channels = ((grayscale || palette) ? (alpha ? 2 : 1) : (alpha ? 4 : 3));
this.BitDepth = bitdepth;
this.Packed = bitdepth < 8;
this.BitspPixel = this.Channels * this.BitDepth;
this.BytesPixel = (this.BitspPixel + 7) / 8;
this.BytesPerRow = (this.BitspPixel * cols + 7) / 8;
this.SamplesPerRow = this.Channels * this.Cols;
this.SamplesPerRowPacked = (this.Packed ? this.BytesPerRow : this.SamplesPerRow);
int bitDepth = this.BitDepth;
switch (bitDepth)
{
case 1:
case 2:
case 4:
if (!this.Indexed && !this.Greyscale)
{
throw new PngjException("only indexed or grayscale can have bitdepth=" + this.BitDepth);
}
goto IL_16B;
case 3:
break;
default:
if (bitDepth == 8)
{
goto IL_16B;
}
if (bitDepth == 16)
{
if (this.Indexed)
{
throw new PngjException("indexed can't have bitdepth=" + this.BitDepth);
}
goto IL_16B;
}
break;
}
throw new PngjException("invalid bitdepth=" + this.BitDepth);
IL_16B:
if (cols < 1 || cols > 400000)
{
throw new PngjException("invalid cols=" + cols + " ???");
}
if (rows < 1 || rows > 400000)
{
throw new PngjException("invalid rows=" + rows + " ???");
}
}
// Token: 0x060000FB RID: 251 RVA: 0x00005070 File Offset: 0x00003270
public override string ToString()
{
return string.Concat(new object[]
{
"ImageInfo [cols=", this.Cols, ", rows=", this.Rows, ", bitDepth=", this.BitDepth, ", channels=", this.Channels, ", bitspPixel=", this.BitspPixel,
", bytesPixel=", this.BytesPixel, ", bytesPerRow=", this.BytesPerRow, ", samplesPerRow=", this.SamplesPerRow, ", samplesPerRowP=", this.SamplesPerRowPacked, ", alpha=", this.Alpha,
", greyscale=", this.Greyscale, ", indexed=", this.Indexed, ", packed=", this.Packed, "]"
});
}
// Token: 0x060000FC RID: 252 RVA: 0x000051C4 File Offset: 0x000033C4
public override int GetHashCode()
{
int num = 31;
int num2 = 1;
num2 = num * num2 + (this.Alpha ? 1231 : 1237);
num2 = num * num2 + this.BitDepth;
num2 = num * num2 + this.Channels;
num2 = num * num2 + this.Cols;
num2 = num * num2 + (this.Greyscale ? 1231 : 1237);
num2 = num * num2 + (this.Indexed ? 1231 : 1237);
return num * num2 + this.Rows;
}
// Token: 0x060000FD RID: 253 RVA: 0x00005250 File Offset: 0x00003450
public override bool Equals(object obj)
{
if (this == obj)
{
return true;
}
if (obj == null)
{
return false;
}
if (base.GetType() != obj.GetType())
{
return false;
}
ImageInfo imageInfo = (ImageInfo)obj;
return this.Alpha == imageInfo.Alpha && this.BitDepth == imageInfo.BitDepth && this.Channels == imageInfo.Channels && this.Cols == imageInfo.Cols && this.Greyscale == imageInfo.Greyscale && this.Indexed == imageInfo.Indexed && this.Rows == imageInfo.Rows;
}
// Token: 0x04000092 RID: 146
private const int MAX_COLS_ROWS_VAL = 400000;
// Token: 0x04000093 RID: 147
public readonly int Cols;
// Token: 0x04000094 RID: 148
public readonly int Rows;
// Token: 0x04000095 RID: 149
public readonly int BitDepth;
// Token: 0x04000096 RID: 150
public readonly int Channels;
// Token: 0x04000097 RID: 151
public readonly int BitspPixel;
// Token: 0x04000098 RID: 152
public readonly int BytesPixel;
// Token: 0x04000099 RID: 153
public readonly int BytesPerRow;
// Token: 0x0400009A RID: 154
public readonly int SamplesPerRow;
// Token: 0x0400009B RID: 155
public readonly int SamplesPerRowPacked;
// Token: 0x0400009C RID: 156
public readonly bool Alpha;
// Token: 0x0400009D RID: 157
public readonly bool Greyscale;
// Token: 0x0400009E RID: 158
public readonly bool Indexed;
// Token: 0x0400009F RID: 159
public readonly bool Packed;
}
}
+408
View File
@@ -0,0 +1,408 @@
using System;
namespace Hjg.Pngcs
{
// Token: 0x02000020 RID: 32
public class ImageLine
{
// Token: 0x17000017 RID: 23
// (get) Token: 0x060000FE RID: 254 RVA: 0x000052F0 File Offset: 0x000034F0
// (set) Token: 0x060000FF RID: 255 RVA: 0x000052F8 File Offset: 0x000034F8
public ImageInfo ImgInfo { get; private set; }
// Token: 0x17000018 RID: 24
// (get) Token: 0x06000100 RID: 256 RVA: 0x00005301 File Offset: 0x00003501
// (set) Token: 0x06000101 RID: 257 RVA: 0x00005309 File Offset: 0x00003509
public int[] Scanline { get; private set; }
// Token: 0x17000019 RID: 25
// (get) Token: 0x06000102 RID: 258 RVA: 0x00005312 File Offset: 0x00003512
// (set) Token: 0x06000103 RID: 259 RVA: 0x0000531A File Offset: 0x0000351A
public byte[] ScanlineB { get; private set; }
// Token: 0x1700001A RID: 26
// (get) Token: 0x06000104 RID: 260 RVA: 0x00005323 File Offset: 0x00003523
// (set) Token: 0x06000105 RID: 261 RVA: 0x0000532B File Offset: 0x0000352B
public int Rown { get; set; }
// Token: 0x1700001B RID: 27
// (get) Token: 0x06000106 RID: 262 RVA: 0x00005334 File Offset: 0x00003534
// (set) Token: 0x06000107 RID: 263 RVA: 0x0000533C File Offset: 0x0000353C
public int ElementsPerRow { get; private set; }
// Token: 0x1700001C RID: 28
// (get) Token: 0x06000108 RID: 264 RVA: 0x00005345 File Offset: 0x00003545
// (set) Token: 0x06000109 RID: 265 RVA: 0x0000534D File Offset: 0x0000354D
public int maxSampleVal { get; private set; }
// Token: 0x1700001D RID: 29
// (get) Token: 0x0600010A RID: 266 RVA: 0x00005356 File Offset: 0x00003556
// (set) Token: 0x0600010B RID: 267 RVA: 0x0000535E File Offset: 0x0000355E
public ImageLine.ESampleType SampleType { get; private set; }
// Token: 0x1700001E RID: 30
// (get) Token: 0x0600010C RID: 268 RVA: 0x00005367 File Offset: 0x00003567
// (set) Token: 0x0600010D RID: 269 RVA: 0x0000536F File Offset: 0x0000356F
public bool SamplesUnpacked { get; private set; }
// Token: 0x1700001F RID: 31
// (get) Token: 0x0600010E RID: 270 RVA: 0x00005378 File Offset: 0x00003578
// (set) Token: 0x0600010F RID: 271 RVA: 0x00005380 File Offset: 0x00003580
public FilterType FilterUsed { get; set; }
// Token: 0x06000110 RID: 272 RVA: 0x00005389 File Offset: 0x00003589
public ImageLine(ImageInfo imgInfo)
: this(imgInfo, ImageLine.ESampleType.INT, false)
{
}
// Token: 0x06000111 RID: 273 RVA: 0x00005394 File Offset: 0x00003594
public ImageLine(ImageInfo imgInfo, ImageLine.ESampleType stype)
: this(imgInfo, stype, false)
{
}
// Token: 0x06000112 RID: 274 RVA: 0x0000539F File Offset: 0x0000359F
public ImageLine(ImageInfo imgInfo, ImageLine.ESampleType stype, bool unpackedMode)
: this(imgInfo, stype, unpackedMode, null, null)
{
}
// Token: 0x06000113 RID: 275 RVA: 0x000053AC File Offset: 0x000035AC
internal ImageLine(ImageInfo imgInfo, ImageLine.ESampleType stype, bool unpackedMode, int[] sci, byte[] scb)
{
this.ImgInfo = imgInfo;
this.channels = imgInfo.Channels;
this.bitDepth = imgInfo.BitDepth;
this.FilterUsed = FilterType.FILTER_UNKNOWN;
this.SampleType = stype;
this.SamplesUnpacked = unpackedMode || !imgInfo.Packed;
this.ElementsPerRow = (this.SamplesUnpacked ? imgInfo.SamplesPerRow : imgInfo.SamplesPerRowPacked);
if (stype == ImageLine.ESampleType.INT)
{
this.Scanline = ((sci != null) ? sci : new int[this.ElementsPerRow]);
this.ScanlineB = null;
this.maxSampleVal = ((this.bitDepth == 16) ? 65535 : ImageLine.GetMaskForPackedFormatsLs(this.bitDepth));
}
else
{
if (stype != ImageLine.ESampleType.BYTE)
{
throw new PngjExceptionInternal("bad ImageLine initialization");
}
this.ScanlineB = ((scb != null) ? scb : new byte[this.ElementsPerRow]);
this.Scanline = null;
this.maxSampleVal = ((this.bitDepth == 16) ? 255 : ImageLine.GetMaskForPackedFormatsLs(this.bitDepth));
}
this.Rown = -1;
}
// Token: 0x06000114 RID: 276 RVA: 0x000054C0 File Offset: 0x000036C0
internal static void unpackInplaceInt(ImageInfo iminfo, int[] src, int[] dst, bool Scale)
{
int num = iminfo.BitDepth;
if (num >= 8)
{
return;
}
int maskForPackedFormatsLs = ImageLine.GetMaskForPackedFormatsLs(num);
int num2 = 8 - num;
int num3 = 8 * iminfo.SamplesPerRowPacked - num * iminfo.SamplesPerRow;
int num4;
int num5;
if (num3 != 8)
{
num4 = maskForPackedFormatsLs << num3;
num5 = num3;
}
else
{
num4 = maskForPackedFormatsLs;
num5 = 0;
}
int i = iminfo.SamplesPerRow - 1;
int num6 = iminfo.SamplesPerRowPacked - 1;
while (i >= 0)
{
int num7 = (src[num6] & num4) >> num5;
if (Scale)
{
num7 <<= num2;
}
dst[i] = num7;
num4 <<= num;
num5 += num;
if (num5 == 8)
{
num4 = maskForPackedFormatsLs;
num5 = 0;
num6--;
}
i--;
}
}
// Token: 0x06000115 RID: 277 RVA: 0x00005570 File Offset: 0x00003770
internal static void packInplaceInt(ImageInfo iminfo, int[] src, int[] dst, bool scaled)
{
int num = iminfo.BitDepth;
if (num >= 8)
{
return;
}
int maskForPackedFormatsLs = ImageLine.GetMaskForPackedFormatsLs(num);
int num2 = 8 - num;
int num3 = 8 - num;
int num4 = 8 - num;
int num5 = src[0];
dst[0] = 0;
if (scaled)
{
num5 >>= num2;
}
num5 = (num5 & maskForPackedFormatsLs) << num4;
int num6 = 0;
for (int i = 0; i < iminfo.SamplesPerRow; i++)
{
int num7 = src[i];
if (scaled)
{
num7 >>= num2;
}
dst[num6] |= (num7 & maskForPackedFormatsLs) << num4;
num4 -= num;
if (num4 < 0)
{
num4 = num3;
num6++;
dst[num6] = 0;
}
}
dst[0] |= num5;
}
// Token: 0x06000116 RID: 278 RVA: 0x00005634 File Offset: 0x00003834
internal static void unpackInplaceByte(ImageInfo iminfo, byte[] src, byte[] dst, bool scale)
{
int num = iminfo.BitDepth;
if (num >= 8)
{
return;
}
int maskForPackedFormatsLs = ImageLine.GetMaskForPackedFormatsLs(num);
int num2 = 8 - num;
int num3 = 8 * iminfo.SamplesPerRowPacked - num * iminfo.SamplesPerRow;
int num4;
int num5;
if (num3 != 8)
{
num4 = maskForPackedFormatsLs << num3;
num5 = num3;
}
else
{
num4 = maskForPackedFormatsLs;
num5 = 0;
}
int i = iminfo.SamplesPerRow - 1;
int num6 = iminfo.SamplesPerRowPacked - 1;
while (i >= 0)
{
int num7 = ((int)src[num6] & num4) >> num5;
if (scale)
{
num7 <<= num2;
}
dst[i] = (byte)num7;
num4 <<= num;
num5 += num;
if (num5 == 8)
{
num4 = maskForPackedFormatsLs;
num5 = 0;
num6--;
}
i--;
}
}
// Token: 0x06000117 RID: 279 RVA: 0x000056E4 File Offset: 0x000038E4
internal static void packInplaceByte(ImageInfo iminfo, byte[] src, byte[] dst, bool scaled)
{
int num = iminfo.BitDepth;
if (num >= 8)
{
return;
}
byte b = (byte)ImageLine.GetMaskForPackedFormatsLs(num);
byte b2 = (byte)(8 - num);
byte b3 = (byte)(8 - num);
int num2 = 8 - num;
byte b4 = src[0];
dst[0] = 0;
if (scaled)
{
b4 = (byte)(b4 >> (int)b2);
}
b4 = (byte)((b4 & b) << num2);
int num3 = 0;
for (int i = 0; i < iminfo.SamplesPerRow; i++)
{
byte b5 = src[i];
if (scaled)
{
b5 = (byte)(b5 >> (int)b2);
}
int num4 = num3;
dst[num4] |= (byte)((b5 & b) << num2);
num2 -= num;
if (num2 < 0)
{
num2 = (int)b3;
num3++;
dst[num3] = 0;
}
}
int num5 = 0;
dst[num5] |= b4;
}
// Token: 0x06000118 RID: 280 RVA: 0x000057B1 File Offset: 0x000039B1
internal void SetScanLine(int[] b)
{
Array.Copy(b, 0, this.Scanline, 0, this.Scanline.Length);
}
// Token: 0x06000119 RID: 281 RVA: 0x000057C9 File Offset: 0x000039C9
internal int[] GetScanLineCopy(int[] b)
{
if (b == null || b.Length < this.Scanline.Length)
{
b = new int[this.Scanline.Length];
}
Array.Copy(this.Scanline, 0, b, 0, this.Scanline.Length);
return b;
}
// Token: 0x0600011A RID: 282 RVA: 0x00005804 File Offset: 0x00003A04
public ImageLine unpackToNewImageLine()
{
ImageLine imageLine = new ImageLine(this.ImgInfo, this.SampleType, true);
if (this.SampleType == ImageLine.ESampleType.INT)
{
ImageLine.unpackInplaceInt(this.ImgInfo, this.Scanline, imageLine.Scanline, false);
}
else
{
ImageLine.unpackInplaceByte(this.ImgInfo, this.ScanlineB, imageLine.ScanlineB, false);
}
return imageLine;
}
// Token: 0x0600011B RID: 283 RVA: 0x00005860 File Offset: 0x00003A60
public ImageLine packToNewImageLine()
{
ImageLine imageLine = new ImageLine(this.ImgInfo, this.SampleType, false);
if (this.SampleType == ImageLine.ESampleType.INT)
{
ImageLine.packInplaceInt(this.ImgInfo, this.Scanline, imageLine.Scanline, false);
}
else
{
ImageLine.packInplaceByte(this.ImgInfo, this.ScanlineB, imageLine.ScanlineB, false);
}
return imageLine;
}
// Token: 0x0600011C RID: 284 RVA: 0x000058BB File Offset: 0x00003ABB
public int[] GetScanlineInt()
{
return this.Scanline;
}
// Token: 0x0600011D RID: 285 RVA: 0x000058C3 File Offset: 0x00003AC3
public byte[] GetScanlineByte()
{
return this.ScanlineB;
}
// Token: 0x0600011E RID: 286 RVA: 0x000058CB File Offset: 0x00003ACB
public bool IsInt()
{
return this.SampleType == ImageLine.ESampleType.INT;
}
// Token: 0x0600011F RID: 287 RVA: 0x000058D6 File Offset: 0x00003AD6
public bool IsByte()
{
return this.SampleType == ImageLine.ESampleType.BYTE;
}
// Token: 0x06000120 RID: 288 RVA: 0x000058E4 File Offset: 0x00003AE4
public override string ToString()
{
return string.Concat(new object[]
{
"row=",
this.Rown,
" cols=",
this.ImgInfo.Cols,
" bpc=",
this.ImgInfo.BitDepth,
" size=",
this.Scanline.Length
});
}
// Token: 0x06000121 RID: 289 RVA: 0x00005962 File Offset: 0x00003B62
internal static int GetMaskForPackedFormats(int bitDepth)
{
if (bitDepth == 4)
{
return 240;
}
if (bitDepth == 2)
{
return 192;
}
if (bitDepth == 1)
{
return 128;
}
return 255;
}
// Token: 0x06000122 RID: 290 RVA: 0x00005987 File Offset: 0x00003B87
internal static int GetMaskForPackedFormatsLs(int bitDepth)
{
if (bitDepth == 4)
{
return 15;
}
if (bitDepth == 2)
{
return 3;
}
if (bitDepth == 1)
{
return 1;
}
return 255;
}
// Token: 0x040000A0 RID: 160
internal readonly int channels;
// Token: 0x040000A1 RID: 161
internal readonly int bitDepth;
// Token: 0x02000021 RID: 33
public enum ESampleType
{
// Token: 0x040000AC RID: 172
INT,
// Token: 0x040000AD RID: 173
BYTE
}
}
}
+317
View File
@@ -0,0 +1,317 @@
using System;
using Hjg.Pngcs.Chunks;
namespace Hjg.Pngcs
{
// Token: 0x02000022 RID: 34
public class ImageLineHelper
{
// Token: 0x06000123 RID: 291 RVA: 0x000059A4 File Offset: 0x00003BA4
public static int[] Palette2rgb(ImageLine line, PngChunkPLTE pal, PngChunkTRNS trns, int[] buf)
{
bool flag = trns != null;
int num = (flag ? 4 : 3);
int num2 = line.ImgInfo.Cols * num;
if (buf == null || buf.Length < num2)
{
buf = new int[num2];
}
if (!line.SamplesUnpacked)
{
line = line.unpackToNewImageLine();
}
bool flag2 = line.SampleType == ImageLine.ESampleType.BYTE;
int num3 = ((trns != null) ? trns.GetPalletteAlpha().Length : 0);
for (int i = 0; i < line.ImgInfo.Cols; i++)
{
int num4 = (flag2 ? ((int)(line.ScanlineB[i] & byte.MaxValue)) : line.Scanline[i]);
pal.GetEntryRgb(num4, buf, i * num);
if (flag)
{
int num5 = ((num4 < num3) ? trns.GetPalletteAlpha()[num4] : 255);
buf[i * num + 3] = num5;
}
}
return buf;
}
// Token: 0x06000124 RID: 292 RVA: 0x00005A76 File Offset: 0x00003C76
public static int[] Palette2rgb(ImageLine line, PngChunkPLTE pal, int[] buf)
{
return ImageLineHelper.Palette2rgb(line, pal, null, buf);
}
// Token: 0x06000125 RID: 293 RVA: 0x00005A81 File Offset: 0x00003C81
public static int ToARGB8(int r, int g, int b)
{
return -16777216 | (r << 16) | (g << 8) | b;
}
// Token: 0x06000126 RID: 294 RVA: 0x00005A93 File Offset: 0x00003C93
public static int ToARGB8(int r, int g, int b, int a)
{
return (a << 24) | (r << 16) | (g << 8) | b;
}
// Token: 0x06000127 RID: 295 RVA: 0x00005AA4 File Offset: 0x00003CA4
public static int ToARGB8(int[] buff, int offset, bool alpha)
{
if (!alpha)
{
return ImageLineHelper.ToARGB8(buff[offset++], buff[offset++], buff[offset++], buff[offset]);
}
return ImageLineHelper.ToARGB8(buff[offset++], buff[offset++], buff[offset]);
}
// Token: 0x06000128 RID: 296 RVA: 0x00005AE2 File Offset: 0x00003CE2
public static int ToARGB8(byte[] buff, int offset, bool alpha)
{
if (!alpha)
{
return ImageLineHelper.ToARGB8((int)buff[offset++], (int)buff[offset++], (int)buff[offset++], (int)buff[offset]);
}
return ImageLineHelper.ToARGB8((int)buff[offset++], (int)buff[offset++], (int)buff[offset]);
}
// Token: 0x06000129 RID: 297 RVA: 0x00005B20 File Offset: 0x00003D20
public static void FromARGB8(int val, int[] buff, int offset, bool alpha)
{
buff[offset++] = (val >> 16) & 255;
buff[offset++] = (val >> 8) & 255;
buff[offset] = val & 255;
if (alpha)
{
buff[offset + 1] = (val >> 24) & 255;
}
}
// Token: 0x0600012A RID: 298 RVA: 0x00005B6C File Offset: 0x00003D6C
public static void FromARGB8(int val, byte[] buff, int offset, bool alpha)
{
buff[offset++] = (byte)((val >> 16) & 255);
buff[offset++] = (byte)((val >> 8) & 255);
buff[offset] = (byte)(val & 255);
if (alpha)
{
buff[offset + 1] = (byte)((val >> 24) & 255);
}
}
// Token: 0x0600012B RID: 299 RVA: 0x00005BBC File Offset: 0x00003DBC
public static int GetPixelToARGB8(ImageLine line, int column)
{
if (line.IsInt())
{
return ImageLineHelper.ToARGB8(line.Scanline, column * line.channels, line.ImgInfo.Alpha);
}
return ImageLineHelper.ToARGB8(line.ScanlineB, column * line.channels, line.ImgInfo.Alpha);
}
// Token: 0x0600012C RID: 300 RVA: 0x00005C10 File Offset: 0x00003E10
public static void SetPixelFromARGB8(ImageLine line, int column, int argb)
{
if (line.IsInt())
{
ImageLineHelper.FromARGB8(argb, line.Scanline, column * line.channels, line.ImgInfo.Alpha);
return;
}
ImageLineHelper.FromARGB8(argb, line.ScanlineB, column * line.channels, line.ImgInfo.Alpha);
}
// Token: 0x0600012D RID: 301 RVA: 0x00005C64 File Offset: 0x00003E64
public static void SetPixel(ImageLine line, int col, int r, int g, int b, int a)
{
int num = col * line.channels;
if (line.IsInt())
{
line.Scanline[num++] = r;
line.Scanline[num++] = g;
line.Scanline[num] = b;
if (line.ImgInfo.Alpha)
{
line.Scanline[num + 1] = a;
return;
}
}
else
{
line.ScanlineB[num++] = (byte)r;
line.ScanlineB[num++] = (byte)g;
line.ScanlineB[num] = (byte)b;
if (line.ImgInfo.Alpha)
{
line.ScanlineB[num + 1] = (byte)a;
}
}
}
// Token: 0x0600012E RID: 302 RVA: 0x00005D01 File Offset: 0x00003F01
public static void SetPixel(ImageLine line, int col, int r, int g, int b)
{
ImageLineHelper.SetPixel(line, col, r, g, b, line.maxSampleVal);
}
// Token: 0x0600012F RID: 303 RVA: 0x00005D14 File Offset: 0x00003F14
public static double ReadDouble(ImageLine line, int pos)
{
if (line.IsInt())
{
return (double)line.Scanline[pos] / ((double)line.maxSampleVal + 0.9);
}
return (double)line.ScanlineB[pos] / ((double)line.maxSampleVal + 0.9);
}
// Token: 0x06000130 RID: 304 RVA: 0x00005D60 File Offset: 0x00003F60
public static void WriteDouble(ImageLine line, double d, int pos)
{
if (line.IsInt())
{
line.Scanline[pos] = (int)(d * ((double)line.maxSampleVal + 0.99));
return;
}
line.ScanlineB[pos] = (byte)(d * ((double)line.maxSampleVal + 0.99));
}
// Token: 0x06000131 RID: 305 RVA: 0x00005DB0 File Offset: 0x00003FB0
public static int Interpol(int a, int b, int c, int d, double dx, double dy)
{
double num = (double)a * (1.0 - dx) + (double)b * dx;
double num2 = (double)c * (1.0 - dx) + (double)d * dx;
return (int)(num * (1.0 - dy) + num2 * dy + 0.5);
}
// Token: 0x06000132 RID: 306 RVA: 0x00005E07 File Offset: 0x00004007
public static int ClampTo_0_255(int i)
{
if (i > 255)
{
return 255;
}
if (i >= 0)
{
return i;
}
return 0;
}
// Token: 0x06000133 RID: 307 RVA: 0x00005E1E File Offset: 0x0000401E
public static double ClampDouble(double i)
{
if (i < 0.0)
{
return 0.0;
}
if (i < 1.0)
{
return i;
}
return 0.999999;
}
// Token: 0x06000134 RID: 308 RVA: 0x00005E4D File Offset: 0x0000404D
public static int ClampTo_0_65535(int i)
{
if (i > 65535)
{
return 65535;
}
if (i >= 0)
{
return i;
}
return 0;
}
// Token: 0x06000135 RID: 309 RVA: 0x00005E64 File Offset: 0x00004064
public static int ClampTo_128_127(int x)
{
if (x > 127)
{
return 127;
}
if (x >= -128)
{
return x;
}
return -128;
}
// Token: 0x06000136 RID: 310 RVA: 0x00005E78 File Offset: 0x00004078
public static int[] Unpack(ImageInfo imgInfo, int[] src, int[] dst, bool scale)
{
int samplesPerRow = imgInfo.SamplesPerRow;
int samplesPerRowPacked = imgInfo.SamplesPerRowPacked;
if (dst == null || dst.Length < samplesPerRow)
{
dst = new int[samplesPerRow];
}
if (imgInfo.Packed)
{
ImageLine.unpackInplaceInt(imgInfo, src, dst, scale);
}
else
{
Array.Copy(src, 0, dst, 0, samplesPerRowPacked);
}
return dst;
}
// Token: 0x06000137 RID: 311 RVA: 0x00005EC4 File Offset: 0x000040C4
public static byte[] Unpack(ImageInfo imgInfo, byte[] src, byte[] dst, bool scale)
{
int samplesPerRow = imgInfo.SamplesPerRow;
int samplesPerRowPacked = imgInfo.SamplesPerRowPacked;
if (dst == null || dst.Length < samplesPerRow)
{
dst = new byte[samplesPerRow];
}
if (imgInfo.Packed)
{
ImageLine.unpackInplaceByte(imgInfo, src, dst, scale);
}
else
{
Array.Copy(src, 0, dst, 0, samplesPerRowPacked);
}
return dst;
}
// Token: 0x06000138 RID: 312 RVA: 0x00005F10 File Offset: 0x00004110
public static int[] Pack(ImageInfo imgInfo, int[] src, int[] dst, bool scale)
{
int samplesPerRowPacked = imgInfo.SamplesPerRowPacked;
if (dst == null || dst.Length < samplesPerRowPacked)
{
dst = new int[samplesPerRowPacked];
}
if (imgInfo.Packed)
{
ImageLine.packInplaceInt(imgInfo, src, dst, scale);
}
else
{
Array.Copy(src, 0, dst, 0, samplesPerRowPacked);
}
return dst;
}
// Token: 0x06000139 RID: 313 RVA: 0x00005F54 File Offset: 0x00004154
public static byte[] Pack(ImageInfo imgInfo, byte[] src, byte[] dst, bool scale)
{
int samplesPerRowPacked = imgInfo.SamplesPerRowPacked;
if (dst == null || dst.Length < samplesPerRowPacked)
{
dst = new byte[samplesPerRowPacked];
}
if (imgInfo.Packed)
{
ImageLine.packInplaceByte(imgInfo, src, dst, scale);
}
else
{
Array.Copy(src, 0, dst, 0, samplesPerRowPacked);
}
return dst;
}
}
}
+137
View File
@@ -0,0 +1,137 @@
using System;
namespace Hjg.Pngcs
{
// Token: 0x02000019 RID: 25
public class ImageLines
{
// Token: 0x1700000F RID: 15
// (get) Token: 0x060000BF RID: 191 RVA: 0x00004190 File Offset: 0x00002390
// (set) Token: 0x060000C0 RID: 192 RVA: 0x00004198 File Offset: 0x00002398
public ImageInfo ImgInfo { get; private set; }
// Token: 0x17000010 RID: 16
// (get) Token: 0x060000C1 RID: 193 RVA: 0x000041A1 File Offset: 0x000023A1
// (set) Token: 0x060000C2 RID: 194 RVA: 0x000041A9 File Offset: 0x000023A9
public ImageLine.ESampleType sampleType { get; private set; }
// Token: 0x17000011 RID: 17
// (get) Token: 0x060000C3 RID: 195 RVA: 0x000041B2 File Offset: 0x000023B2
// (set) Token: 0x060000C4 RID: 196 RVA: 0x000041BA File Offset: 0x000023BA
public bool SamplesUnpacked { get; private set; }
// Token: 0x17000012 RID: 18
// (get) Token: 0x060000C5 RID: 197 RVA: 0x000041C3 File Offset: 0x000023C3
// (set) Token: 0x060000C6 RID: 198 RVA: 0x000041CB File Offset: 0x000023CB
public int RowOffset { get; private set; }
// Token: 0x17000013 RID: 19
// (get) Token: 0x060000C7 RID: 199 RVA: 0x000041D4 File Offset: 0x000023D4
// (set) Token: 0x060000C8 RID: 200 RVA: 0x000041DC File Offset: 0x000023DC
public int Nrows { get; private set; }
// Token: 0x17000014 RID: 20
// (get) Token: 0x060000C9 RID: 201 RVA: 0x000041E5 File Offset: 0x000023E5
// (set) Token: 0x060000CA RID: 202 RVA: 0x000041ED File Offset: 0x000023ED
public int RowStep { get; private set; }
// Token: 0x17000015 RID: 21
// (get) Token: 0x060000CB RID: 203 RVA: 0x000041F6 File Offset: 0x000023F6
// (set) Token: 0x060000CC RID: 204 RVA: 0x000041FE File Offset: 0x000023FE
public int[][] Scanlines { get; private set; }
// Token: 0x17000016 RID: 22
// (get) Token: 0x060000CD RID: 205 RVA: 0x00004207 File Offset: 0x00002407
// (set) Token: 0x060000CE RID: 206 RVA: 0x0000420F File Offset: 0x0000240F
public byte[][] ScanlinesB { get; private set; }
// Token: 0x060000CF RID: 207 RVA: 0x00004218 File Offset: 0x00002418
public ImageLines(ImageInfo ImgInfo, ImageLine.ESampleType sampleType, bool unpackedMode, int rowOffset, int nRows, int rowStep)
{
this.ImgInfo = ImgInfo;
this.channels = ImgInfo.Channels;
this.bitDepth = ImgInfo.BitDepth;
this.sampleType = sampleType;
this.SamplesUnpacked = unpackedMode || !ImgInfo.Packed;
this.RowOffset = rowOffset;
this.Nrows = nRows;
this.RowStep = rowStep;
this.elementsPerRow = (unpackedMode ? ImgInfo.SamplesPerRow : ImgInfo.SamplesPerRowPacked);
if (sampleType == ImageLine.ESampleType.INT)
{
this.Scanlines = new int[nRows][];
for (int i = 0; i < nRows; i++)
{
this.Scanlines[i] = new int[this.elementsPerRow];
}
this.ScanlinesB = null;
return;
}
if (sampleType == ImageLine.ESampleType.BYTE)
{
this.ScanlinesB = new byte[nRows][];
for (int j = 0; j < nRows; j++)
{
this.ScanlinesB[j] = new byte[this.elementsPerRow];
}
this.Scanlines = null;
return;
}
throw new PngjExceptionInternal("bad ImageLine initialization");
}
// Token: 0x060000D0 RID: 208 RVA: 0x00004310 File Offset: 0x00002510
public int ImageRowToMatrixRow(int imrow)
{
int num = (imrow - this.RowOffset) / this.RowStep;
if (num < 0)
{
return 0;
}
if (num >= this.Nrows)
{
return this.Nrows - 1;
}
return num;
}
// Token: 0x060000D1 RID: 209 RVA: 0x00004348 File Offset: 0x00002548
public int ImageRowToMatrixRowStrict(int imrow)
{
imrow -= this.RowOffset;
int num = ((imrow >= 0 && imrow % this.RowStep == 0) ? (imrow / this.RowStep) : (-1));
if (num >= this.Nrows)
{
return -1;
}
return num;
}
// Token: 0x060000D2 RID: 210 RVA: 0x00004385 File Offset: 0x00002585
public int MatrixRowToImageRow(int mrow)
{
return mrow * this.RowStep + this.RowOffset;
}
// Token: 0x060000D3 RID: 211 RVA: 0x00004398 File Offset: 0x00002598
public ImageLine GetImageLineAtMatrixRow(int mrow)
{
if (mrow < 0 || mrow > this.Nrows)
{
throw new PngjException(string.Concat(new object[] { "Bad row ", mrow, ". Should be positive and less than ", this.Nrows }));
}
ImageLine imageLine = ((this.sampleType == ImageLine.ESampleType.INT) ? new ImageLine(this.ImgInfo, this.sampleType, this.SamplesUnpacked, this.Scanlines[mrow], null) : new ImageLine(this.ImgInfo, this.sampleType, this.SamplesUnpacked, null, this.ScanlinesB[mrow]));
imageLine.Rown = this.MatrixRowToImageRow(mrow);
return imageLine;
}
// Token: 0x0400006B RID: 107
internal readonly int channels;
// Token: 0x0400006C RID: 108
internal readonly int bitDepth;
// Token: 0x0400006D RID: 109
internal readonly int elementsPerRow;
}
}
+31
View File
@@ -0,0 +1,31 @@
using System;
namespace Hjg.Pngcs
{
// Token: 0x0200001E RID: 30
internal class PngCsUtils
{
// Token: 0x060000F6 RID: 246 RVA: 0x00004E3B File Offset: 0x0000303B
internal static bool arraysEqual4(byte[] ar1, byte[] ar2)
{
return ar1[0] == ar2[0] && ar1[1] == ar2[1] && ar1[2] == ar2[2] && ar1[3] == ar2[3];
}
// Token: 0x060000F7 RID: 247 RVA: 0x00004E60 File Offset: 0x00003060
internal static bool arraysEqual(byte[] a1, byte[] a2)
{
if (a1.Length != a2.Length)
{
return false;
}
for (int i = 0; i < a1.Length; i++)
{
if (a1[i] != a2[i])
{
return false;
}
}
return true;
}
}
}
+353
View File
@@ -0,0 +1,353 @@
using System;
namespace Hjg.Pngcs
{
// Token: 0x0200001A RID: 26
internal class PngDeinterlacer
{
// Token: 0x060000D4 RID: 212 RVA: 0x00004448 File Offset: 0x00002648
internal PngDeinterlacer(ImageInfo iminfo)
{
this.imi = iminfo;
this.pass = 0;
if (this.imi.Packed)
{
this.packedValsPerPixel = 8 / this.imi.BitDepth;
this.packedShift = this.imi.BitDepth;
if (this.imi.BitDepth == 1)
{
this.packedMask = 128;
}
else if (this.imi.BitDepth == 2)
{
this.packedMask = 192;
}
else
{
this.packedMask = 240;
}
}
else
{
this.packedMask = (this.packedShift = (this.packedValsPerPixel = 1));
}
this.setPass(1);
this.setRow(0);
}
// Token: 0x060000D5 RID: 213 RVA: 0x00004514 File Offset: 0x00002714
internal void setRow(int n)
{
this.currRowSubimg = n;
this.currRowReal = n * this.dY + this.oY;
if (this.currRowReal < 0 || this.currRowReal >= this.imi.Rows)
{
throw new PngjExceptionInternal("bad row - this should not happen");
}
}
// Token: 0x060000D6 RID: 214 RVA: 0x00004564 File Offset: 0x00002764
internal void setPass(int p)
{
if (this.pass == p)
{
return;
}
this.pass = p;
switch (this.pass)
{
case 1:
this.dY = (this.dX = 8);
this.oX = (this.oY = 0);
break;
case 2:
this.dY = (this.dX = 8);
this.oX = 4;
this.oY = 0;
break;
case 3:
this.dX = 4;
this.dY = 8;
this.oX = 0;
this.oY = 4;
break;
case 4:
this.dX = (this.dY = 4);
this.oX = 2;
this.oY = 0;
break;
case 5:
this.dX = 2;
this.dY = 4;
this.oX = 0;
this.oY = 2;
break;
case 6:
this.dX = (this.dY = 2);
this.oX = 1;
this.oY = 0;
break;
case 7:
this.dX = 1;
this.dY = 2;
this.oX = 0;
this.oY = 1;
break;
default:
throw new PngjExceptionInternal("bad interlace pass" + this.pass);
}
this.rows = (this.imi.Rows - this.oY) / this.dY + 1;
if ((this.rows - 1) * this.dY + this.oY >= this.imi.Rows)
{
this.rows--;
}
this.cols = (this.imi.Cols - this.oX) / this.dX + 1;
if ((this.cols - 1) * this.dX + this.oX >= this.imi.Cols)
{
this.cols--;
}
if (this.cols == 0)
{
this.rows = 0;
}
this.dXsamples = this.dX * this.imi.Channels;
this.oXsamples = this.oX * this.imi.Channels;
}
// Token: 0x060000D7 RID: 215 RVA: 0x0000479C File Offset: 0x0000299C
internal void deinterlaceInt(int[] src, int[] dst, bool readInPackedFormat)
{
if (!this.imi.Packed || !readInPackedFormat)
{
int i = 0;
int num = this.oXsamples;
while (i < this.cols * this.imi.Channels)
{
for (int j = 0; j < this.imi.Channels; j++)
{
dst[num + j] = src[i + j];
}
i += this.imi.Channels;
num += this.dXsamples;
}
return;
}
this.deinterlaceIntPacked(src, dst);
}
// Token: 0x060000D8 RID: 216 RVA: 0x0000481C File Offset: 0x00002A1C
private void deinterlaceIntPacked(int[] src, int[] dst)
{
int num = this.packedMask;
int num2 = -1;
int i = 0;
int num3 = this.oX;
while (i < this.cols)
{
int num4 = i / this.packedValsPerPixel;
num2++;
if (num2 >= this.packedValsPerPixel)
{
num2 = 0;
}
num >>= this.packedShift;
if (num2 == 0)
{
num = this.packedMask;
}
int num5 = num3 / this.packedValsPerPixel;
int num6 = num3 % this.packedValsPerPixel;
int num7 = src[num4] & num;
int num8 = num6 - num2;
if (num8 > 0)
{
num7 >>= num8 * this.packedShift;
}
else if (num8 < 0)
{
num7 <<= -num8 * this.packedShift;
}
dst[num5] |= num7;
i++;
num3 += this.dX;
}
}
// Token: 0x060000D9 RID: 217 RVA: 0x000048F8 File Offset: 0x00002AF8
internal void deinterlaceByte(byte[] src, byte[] dst, bool readInPackedFormat)
{
if (!this.imi.Packed || !readInPackedFormat)
{
int i = 0;
int num = this.oXsamples;
while (i < this.cols * this.imi.Channels)
{
for (int j = 0; j < this.imi.Channels; j++)
{
dst[num + j] = src[i + j];
}
i += this.imi.Channels;
num += this.dXsamples;
}
return;
}
this.deinterlacePackedByte(src, dst);
}
// Token: 0x060000DA RID: 218 RVA: 0x00004978 File Offset: 0x00002B78
private void deinterlacePackedByte(byte[] src, byte[] dst)
{
int num = this.packedMask;
int num2 = -1;
int i = 0;
int num3 = this.oX;
while (i < this.cols)
{
int num4 = i / this.packedValsPerPixel;
num2++;
if (num2 >= this.packedValsPerPixel)
{
num2 = 0;
}
num >>= this.packedShift;
if (num2 == 0)
{
num = this.packedMask;
}
int num5 = num3 / this.packedValsPerPixel;
int num6 = num3 % this.packedValsPerPixel;
int num7 = (int)src[num4] & num;
int num8 = num6 - num2;
if (num8 > 0)
{
num7 >>= num8 * this.packedShift;
}
else if (num8 < 0)
{
num7 <<= -num8 * this.packedShift;
}
int num9 = num5;
dst[num9] |= (byte)num7;
i++;
num3 += this.dX;
}
}
// Token: 0x060000DB RID: 219 RVA: 0x00004A55 File Offset: 0x00002C55
internal bool isAtLastRow()
{
return this.pass == 7 && this.currRowSubimg == this.rows - 1;
}
// Token: 0x060000DC RID: 220 RVA: 0x00004A72 File Offset: 0x00002C72
internal int getCurrRowSubimg()
{
return this.currRowSubimg;
}
// Token: 0x060000DD RID: 221 RVA: 0x00004A7A File Offset: 0x00002C7A
internal int getCurrRowReal()
{
return this.currRowReal;
}
// Token: 0x060000DE RID: 222 RVA: 0x00004A82 File Offset: 0x00002C82
internal int getPass()
{
return this.pass;
}
// Token: 0x060000DF RID: 223 RVA: 0x00004A8A File Offset: 0x00002C8A
internal int getRows()
{
return this.rows;
}
// Token: 0x060000E0 RID: 224 RVA: 0x00004A92 File Offset: 0x00002C92
internal int getCols()
{
return this.cols;
}
// Token: 0x060000E1 RID: 225 RVA: 0x00004A9A File Offset: 0x00002C9A
internal int getPixelsToRead()
{
return this.getCols();
}
// Token: 0x060000E2 RID: 226 RVA: 0x00004AA2 File Offset: 0x00002CA2
internal int[][] getImageInt()
{
return this.imageInt;
}
// Token: 0x060000E3 RID: 227 RVA: 0x00004AAA File Offset: 0x00002CAA
internal void setImageInt(int[][] imageInt)
{
this.imageInt = imageInt;
}
// Token: 0x060000E4 RID: 228 RVA: 0x00004AB3 File Offset: 0x00002CB3
internal byte[][] getImageByte()
{
return this.imageByte;
}
// Token: 0x060000E5 RID: 229 RVA: 0x00004ABB File Offset: 0x00002CBB
internal void setImageByte(byte[][] imageByte)
{
this.imageByte = imageByte;
}
// Token: 0x04000076 RID: 118
private readonly ImageInfo imi;
// Token: 0x04000077 RID: 119
private int pass;
// Token: 0x04000078 RID: 120
private int rows;
// Token: 0x04000079 RID: 121
private int cols;
// Token: 0x0400007A RID: 122
private int dY;
// Token: 0x0400007B RID: 123
private int dX;
// Token: 0x0400007C RID: 124
private int oY;
// Token: 0x0400007D RID: 125
private int oX;
// Token: 0x0400007E RID: 126
private int oXsamples;
// Token: 0x0400007F RID: 127
private int dXsamples;
// Token: 0x04000080 RID: 128
private int currRowSubimg = -1;
// Token: 0x04000081 RID: 129
private int currRowReal = -1;
// Token: 0x04000082 RID: 130
private readonly int packedValsPerPixel;
// Token: 0x04000083 RID: 131
private readonly int packedMask;
// Token: 0x04000084 RID: 132
private readonly int packedShift;
// Token: 0x04000085 RID: 133
private int[][] imageInt;
// Token: 0x04000086 RID: 134
private byte[][] imageByte;
}
}
+299
View File
@@ -0,0 +1,299 @@
using System;
using System.IO;
using System.Text;
using Hjg.Pngcs.Zlib;
namespace Hjg.Pngcs
{
// Token: 0x02000034 RID: 52
public class PngHelperInternal
{
// Token: 0x060001C4 RID: 452 RVA: 0x0000783C File Offset: 0x00005A3C
public static CRC32 GetCRC()
{
if (PngHelperInternal.crc32Engine == null)
{
PngHelperInternal.crc32Engine = new CRC32();
}
return PngHelperInternal.crc32Engine;
}
// Token: 0x060001C5 RID: 453 RVA: 0x00007854 File Offset: 0x00005A54
public static int DoubleToInt100000(double d)
{
return (int)(d * 100000.0 + 0.5);
}
// Token: 0x060001C6 RID: 454 RVA: 0x0000786C File Offset: 0x00005A6C
public static double IntToDouble100000(int i)
{
return (double)i / 100000.0;
}
// Token: 0x060001C7 RID: 455 RVA: 0x0000787C File Offset: 0x00005A7C
public static void WriteInt2(Stream os, int n)
{
byte[] array = new byte[]
{
(byte)((n >> 8) & 255),
(byte)(n & 255)
};
PngHelperInternal.WriteBytes(os, array);
}
// Token: 0x060001C8 RID: 456 RVA: 0x000078B4 File Offset: 0x00005AB4
public static int ReadInt2(Stream mask0)
{
int num3;
try
{
int num = mask0.ReadByte();
int num2 = mask0.ReadByte();
if (num == -1 || num2 == -1)
{
num3 = -1;
}
else
{
num3 = (num << 8) + num2;
}
}
catch (IOException ex)
{
throw new PngjInputException("error reading readInt2", ex);
}
return num3;
}
// Token: 0x060001C9 RID: 457 RVA: 0x00007904 File Offset: 0x00005B04
public static int ReadInt4(Stream mask0)
{
int num5;
try
{
int num = mask0.ReadByte();
int num2 = mask0.ReadByte();
int num3 = mask0.ReadByte();
int num4 = mask0.ReadByte();
if (num == -1 || num2 == -1 || num3 == -1 || num4 == -1)
{
num5 = -1;
}
else
{
num5 = (num << 24) + (num2 << 16) + (num3 << 8) + num4;
}
}
catch (IOException ex)
{
throw new PngjInputException("error reading readInt4", ex);
}
return num5;
}
// Token: 0x060001CA RID: 458 RVA: 0x00007978 File Offset: 0x00005B78
public static int ReadInt1fromByte(byte[] b, int offset)
{
return (int)(b[offset] & byte.MaxValue);
}
// Token: 0x060001CB RID: 459 RVA: 0x00007983 File Offset: 0x00005B83
public static int ReadInt2fromBytes(byte[] b, int offset)
{
return ((int)(b[offset] & byte.MaxValue) << 16) | (int)(b[offset + 1] & byte.MaxValue);
}
// Token: 0x060001CC RID: 460 RVA: 0x0000799D File Offset: 0x00005B9D
public static int ReadInt4fromBytes(byte[] b, int offset)
{
return ((int)(b[offset] & byte.MaxValue) << 24) | ((int)(b[offset + 1] & byte.MaxValue) << 16) | ((int)(b[offset + 2] & byte.MaxValue) << 8) | (int)(b[offset + 3] & byte.MaxValue);
}
// Token: 0x060001CD RID: 461 RVA: 0x000079D4 File Offset: 0x00005BD4
public static void WriteInt2tobytes(int n, byte[] b, int offset)
{
b[offset] = (byte)((n >> 8) & 255);
b[offset + 1] = (byte)(n & 255);
}
// Token: 0x060001CE RID: 462 RVA: 0x000079F0 File Offset: 0x00005BF0
public static void WriteInt4tobytes(int n, byte[] b, int offset)
{
b[offset] = (byte)((n >> 24) & 255);
b[offset + 1] = (byte)((n >> 16) & 255);
b[offset + 2] = (byte)((n >> 8) & 255);
b[offset + 3] = (byte)(n & 255);
}
// Token: 0x060001CF RID: 463 RVA: 0x00007A2C File Offset: 0x00005C2C
public static void WriteInt4(Stream os, int n)
{
byte[] array = new byte[4];
PngHelperInternal.WriteInt4tobytes(n, array, 0);
PngHelperInternal.WriteBytes(os, array);
}
// Token: 0x060001D0 RID: 464 RVA: 0x00007A50 File Offset: 0x00005C50
public static void ReadBytes(Stream mask0, byte[] b, int offset, int len)
{
if (len == 0)
{
return;
}
try
{
int num;
for (int i = 0; i < len; i += num)
{
num = mask0.Read(b, offset + i, len - i);
if (num < 1)
{
throw new Exception(string.Concat(new object[] { "error reading, ", num, " !=", len }));
}
}
}
catch (IOException ex)
{
throw new PngjInputException("error reading", ex);
}
}
// Token: 0x060001D1 RID: 465 RVA: 0x00007AD4 File Offset: 0x00005CD4
public static void SkipBytes(Stream ist, int len)
{
byte[] array = new byte[32768];
int i = len;
try
{
while (i > 0)
{
int num = ist.Read(array, 0, (i > array.Length) ? array.Length : i);
if (num < 0)
{
throw new PngjInputException("error reading (skipping) : EOF");
}
i -= num;
}
}
catch (IOException ex)
{
throw new PngjInputException("error reading (skipping)", ex);
}
}
// Token: 0x060001D2 RID: 466 RVA: 0x00007B3C File Offset: 0x00005D3C
public static void WriteBytes(Stream os, byte[] b)
{
try
{
os.Write(b, 0, b.Length);
}
catch (IOException ex)
{
throw new PngjOutputException(ex);
}
}
// Token: 0x060001D3 RID: 467 RVA: 0x00007B70 File Offset: 0x00005D70
public static void WriteBytes(Stream os, byte[] b, int offset, int n)
{
try
{
os.Write(b, offset, n);
}
catch (IOException ex)
{
throw new PngjOutputException(ex);
}
}
// Token: 0x060001D4 RID: 468 RVA: 0x00007BA0 File Offset: 0x00005DA0
public static int ReadByte(Stream mask0)
{
int num;
try
{
num = mask0.ReadByte();
}
catch (IOException ex)
{
throw new PngjOutputException(ex);
}
return num;
}
// Token: 0x060001D5 RID: 469 RVA: 0x00007BD0 File Offset: 0x00005DD0
public static void WriteByte(Stream os, byte b)
{
try
{
os.WriteByte(b);
}
catch (IOException ex)
{
throw new PngjOutputException(ex);
}
}
// Token: 0x060001D6 RID: 470 RVA: 0x00007C00 File Offset: 0x00005E00
public static int UnfilterRowPaeth(int r, int a, int b, int c)
{
return (r + PngHelperInternal.FilterPaethPredictor(a, b, c)) & 255;
}
// Token: 0x060001D7 RID: 471 RVA: 0x00007C14 File Offset: 0x00005E14
public static int FilterPaethPredictor(int a, int b, int c)
{
int num = a + b - c;
int num2 = ((num >= a) ? (num - a) : (a - num));
int num3 = ((num >= b) ? (num - b) : (b - num));
int num4 = ((num >= c) ? (num - c) : (c - num));
if (num2 <= num3 && num2 <= num4)
{
return a;
}
if (num3 <= num4)
{
return b;
}
return c;
}
// Token: 0x060001D8 RID: 472 RVA: 0x00007C5F File Offset: 0x00005E5F
public static void Logdebug(string msg)
{
if (PngHelperInternal.DEBUG)
{
Console.Out.WriteLine(msg);
}
}
// Token: 0x060001D9 RID: 473 RVA: 0x00007C73 File Offset: 0x00005E73
public static void InitCrcForTests(PngReader pngr)
{
pngr.InitCrctest();
}
// Token: 0x060001DA RID: 474 RVA: 0x00007C7B File Offset: 0x00005E7B
public static long GetCrctestVal(PngReader pngr)
{
return pngr.GetCrctestVal();
}
// Token: 0x040000FE RID: 254
[ThreadStatic]
private static CRC32 crc32Engine = null;
// Token: 0x040000FF RID: 255
public static readonly byte[] PNG_ID_SIGNATURE = new byte[] { 137, 80, 78, 71, 13, 10, 26, 10 };
// Token: 0x04000100 RID: 256
public static Encoding charsetLatin1 = Encoding.GetEncoding("ISO-8859-1");
// Token: 0x04000101 RID: 257
public static Encoding charsetUtf8 = Encoding.GetEncoding("UTF-8");
// Token: 0x04000102 RID: 258
public static bool DEBUG = false;
}
}
+288
View File
@@ -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;
}
}
}
+44
View File
@@ -0,0 +1,44 @@
using System;
using System.IO;
using Hjg.Pngcs.Chunks;
namespace Hjg.Pngcs
{
// Token: 0x02000038 RID: 56
internal class PngIDatChunkOutputStream : ProgressiveOutputStream
{
// Token: 0x060001FC RID: 508 RVA: 0x0000815E File Offset: 0x0000635E
public PngIDatChunkOutputStream(Stream outputStream_0)
: this(outputStream_0, 32768)
{
}
// Token: 0x060001FD RID: 509 RVA: 0x0000816C File Offset: 0x0000636C
public PngIDatChunkOutputStream(Stream outputStream_0, int size)
: base((size > 8) ? size : 32768)
{
this.outputStream = outputStream_0;
}
// Token: 0x060001FE RID: 510 RVA: 0x00008188 File Offset: 0x00006388
protected override void FlushBuffer(byte[] b, int len)
{
new ChunkRaw(len, ChunkHelper.b_IDAT, false)
{
Data = b
}.WriteChunk(this.outputStream);
}
// Token: 0x060001FF RID: 511 RVA: 0x000081B5 File Offset: 0x000063B5
public override void Close()
{
this.Flush();
}
// Token: 0x04000111 RID: 273
private const int SIZE_DEFAULT = 32768;
// Token: 0x04000112 RID: 274
private readonly Stream outputStream;
}
}
+904
View File
@@ -0,0 +1,904 @@
using System;
using System.Collections.Generic;
using System.IO;
using Hjg.Pngcs.Chunks;
using Hjg.Pngcs.Zlib;
namespace Hjg.Pngcs
{
// Token: 0x0200003E RID: 62
public class PngReader
{
// Token: 0x1700002F RID: 47
// (get) Token: 0x06000210 RID: 528 RVA: 0x0000825D File Offset: 0x0000645D
// (set) Token: 0x06000211 RID: 529 RVA: 0x00008265 File Offset: 0x00006465
public ImageInfo ImgInfo { get; private set; }
// Token: 0x17000030 RID: 48
// (get) Token: 0x06000212 RID: 530 RVA: 0x0000826E File Offset: 0x0000646E
// (set) Token: 0x06000213 RID: 531 RVA: 0x00008276 File Offset: 0x00006476
public ChunkLoadBehaviour ChunkLoadBehaviour { get; set; }
// Token: 0x17000031 RID: 49
// (get) Token: 0x06000214 RID: 532 RVA: 0x0000827F File Offset: 0x0000647F
// (set) Token: 0x06000215 RID: 533 RVA: 0x00008287 File Offset: 0x00006487
public bool ShouldCloseStream { get; set; }
// Token: 0x17000032 RID: 50
// (get) Token: 0x06000216 RID: 534 RVA: 0x00008290 File Offset: 0x00006490
// (set) Token: 0x06000217 RID: 535 RVA: 0x00008298 File Offset: 0x00006498
public long MaxBytesMetadata { get; set; }
// Token: 0x17000033 RID: 51
// (get) Token: 0x06000218 RID: 536 RVA: 0x000082A1 File Offset: 0x000064A1
// (set) Token: 0x06000219 RID: 537 RVA: 0x000082A9 File Offset: 0x000064A9
public long MaxTotalBytesRead { get; set; }
// Token: 0x17000034 RID: 52
// (get) Token: 0x0600021A RID: 538 RVA: 0x000082B2 File Offset: 0x000064B2
// (set) Token: 0x0600021B RID: 539 RVA: 0x000082BA File Offset: 0x000064BA
public int SkipChunkMaxSize { get; set; }
// Token: 0x17000035 RID: 53
// (get) Token: 0x0600021C RID: 540 RVA: 0x000082C3 File Offset: 0x000064C3
// (set) Token: 0x0600021D RID: 541 RVA: 0x000082CB File Offset: 0x000064CB
public string[] SkipChunkIds { get; set; }
// Token: 0x17000036 RID: 54
// (get) Token: 0x0600021E RID: 542 RVA: 0x000082D4 File Offset: 0x000064D4
// (set) Token: 0x0600021F RID: 543 RVA: 0x000082DC File Offset: 0x000064DC
public int CurrentChunkGroup { get; private set; }
// Token: 0x06000220 RID: 544 RVA: 0x000082E5 File Offset: 0x000064E5
public PngReader(Stream inputStream)
: this(inputStream, "[NO FILENAME AVAILABLE]")
{
}
// Token: 0x06000221 RID: 545 RVA: 0x000082F4 File Offset: 0x000064F4
public PngReader(Stream inputStream, string filename)
{
this.filename = ((filename == null) ? "" : filename);
this.inputStream = inputStream;
this.chunksList = new ChunksList(null);
this.metadata = new PngMetadata(this.chunksList);
this.offset = 0L;
this.CurrentChunkGroup = -1;
this.ShouldCloseStream = true;
this.MaxBytesMetadata = 5242880L;
this.MaxTotalBytesRead = 209715200L;
this.SkipChunkMaxSize = 2097152;
this.SkipChunkIds = new string[] { "fdAT" };
this.ChunkLoadBehaviour = ChunkLoadBehaviour.LOAD_CHUNK_ALWAYS;
byte[] array = new byte[8];
PngHelperInternal.ReadBytes(inputStream, array, 0, array.Length);
this.offset += (long)array.Length;
if (!PngCsUtils.arraysEqual(array, PngHelperInternal.PNG_ID_SIGNATURE))
{
throw new PngjInputException("Bad PNG signature");
}
this.CurrentChunkGroup = 0;
int num = PngHelperInternal.ReadInt4(inputStream);
this.offset += 4L;
if (num != 13)
{
throw new Exception("IDHR chunk len != 13 ?? " + num);
}
byte[] array2 = new byte[4];
PngHelperInternal.ReadBytes(inputStream, array2, 0, 4);
if (!PngCsUtils.arraysEqual4(array2, ChunkHelper.b_IHDR))
{
throw new PngjInputException("IHDR not found as first chunk??? [" + ChunkHelper.ToString(array2) + "]");
}
this.offset += 4L;
PngChunkIHDR pngChunkIHDR = (PngChunkIHDR)this.ReadChunk(array2, num, false);
bool flag = (pngChunkIHDR.Colormodel & 4) != 0;
bool flag2 = (pngChunkIHDR.Colormodel & 1) != 0;
bool flag3 = pngChunkIHDR.Colormodel == 0 || pngChunkIHDR.Colormodel == 4;
this.ImgInfo = new ImageInfo(pngChunkIHDR.Cols, pngChunkIHDR.Rows, pngChunkIHDR.Bitspc, flag, flag3, flag2);
this.rowb = new byte[this.ImgInfo.BytesPerRow + 1];
this.rowbprev = new byte[this.rowb.Length];
this.rowbfilter = new byte[this.rowb.Length];
this.interlaced = pngChunkIHDR.Interlaced == 1;
this.deinterlacer = (this.interlaced ? new PngDeinterlacer(this.ImgInfo) : null);
if (pngChunkIHDR.Filmeth != 0 || pngChunkIHDR.Compmeth != 0 || (pngChunkIHDR.Interlaced & 65534) != 0)
{
throw new PngjInputException("compmethod or filtermethod or interlaced unrecognized");
}
if (pngChunkIHDR.Colormodel < 0 || pngChunkIHDR.Colormodel > 6 || pngChunkIHDR.Colormodel == 1 || pngChunkIHDR.Colormodel == 5)
{
throw new PngjInputException("Invalid colormodel " + pngChunkIHDR.Colormodel);
}
if (pngChunkIHDR.Bitspc != 1 && pngChunkIHDR.Bitspc != 2 && pngChunkIHDR.Bitspc != 4 && pngChunkIHDR.Bitspc != 8 && pngChunkIHDR.Bitspc != 16)
{
throw new PngjInputException("Invalid bit depth " + pngChunkIHDR.Bitspc);
}
}
// Token: 0x06000222 RID: 546 RVA: 0x000085DF File Offset: 0x000067DF
private bool FirstChunksNotYetRead()
{
return this.CurrentChunkGroup < 1;
}
// Token: 0x06000223 RID: 547 RVA: 0x000085EC File Offset: 0x000067EC
private void ReadLastAndClose()
{
if (this.CurrentChunkGroup < 5)
{
try
{
this.idatIstream.Close();
}
catch (Exception)
{
}
this.ReadLastChunks();
}
this.Close();
}
// Token: 0x06000224 RID: 548 RVA: 0x00008630 File Offset: 0x00006830
private void Close()
{
if (this.CurrentChunkGroup < 6)
{
try
{
this.idatIstream.Close();
}
catch (Exception)
{
}
this.CurrentChunkGroup = 6;
}
if (this.ShouldCloseStream)
{
this.inputStream.Close();
}
}
// Token: 0x06000225 RID: 549 RVA: 0x00008680 File Offset: 0x00006880
private void UnfilterRow(int nbytes)
{
int num = (int)this.rowbfilter[0];
switch (num)
{
case 0:
this.UnfilterRowNone(nbytes);
break;
case 1:
this.UnfilterRowSub(nbytes);
break;
case 2:
this.UnfilterRowUp(nbytes);
break;
case 3:
this.UnfilterRowAverage(nbytes);
break;
case 4:
this.UnfilterRowPaeth(nbytes);
break;
default:
throw new PngjInputException("Filter type " + num + " not implemented");
}
if (this.crctest != null)
{
this.crctest.Update(this.rowb, 1, nbytes);
}
}
// Token: 0x06000226 RID: 550 RVA: 0x0000871C File Offset: 0x0000691C
private void UnfilterRowAverage(int nbytes)
{
int num = 1 - this.ImgInfo.BytesPixel;
int i = 1;
while (i <= nbytes)
{
int num2 = (int)((num > 0) ? this.rowb[num] : 0);
this.rowb[i] = (byte)((int)this.rowbfilter[i] + (num2 + (int)(this.rowbprev[i] & byte.MaxValue)) / 2);
i++;
num++;
}
}
// Token: 0x06000227 RID: 551 RVA: 0x0000877C File Offset: 0x0000697C
private void UnfilterRowNone(int nbytes)
{
for (int i = 1; i <= nbytes; i++)
{
this.rowb[i] = this.rowbfilter[i];
}
}
// Token: 0x06000228 RID: 552 RVA: 0x000087A8 File Offset: 0x000069A8
private void UnfilterRowPaeth(int nbytes)
{
int num = 1 - this.ImgInfo.BytesPixel;
int i = 1;
while (i <= nbytes)
{
int num2 = (int)((num > 0) ? this.rowb[num] : 0);
int num3 = (int)((num > 0) ? this.rowbprev[num] : 0);
this.rowb[i] = (byte)((int)this.rowbfilter[i] + PngHelperInternal.FilterPaethPredictor(num2, (int)this.rowbprev[i], num3));
i++;
num++;
}
}
// Token: 0x06000229 RID: 553 RVA: 0x00008814 File Offset: 0x00006A14
private void UnfilterRowSub(int nbytes)
{
int i;
for (i = 1; i <= this.ImgInfo.BytesPixel; i++)
{
this.rowb[i] = this.rowbfilter[i];
}
int num = 1;
i = this.ImgInfo.BytesPixel + 1;
while (i <= nbytes)
{
this.rowb[i] = this.rowbfilter[i] + this.rowb[num];
i++;
num++;
}
}
// Token: 0x0600022A RID: 554 RVA: 0x00008880 File Offset: 0x00006A80
private void UnfilterRowUp(int nbytes)
{
for (int i = 1; i <= nbytes; i++)
{
this.rowb[i] = this.rowbfilter[i] + this.rowbprev[i];
}
}
// Token: 0x0600022B RID: 555 RVA: 0x000088B4 File Offset: 0x00006AB4
private void ReadFirstChunks()
{
if (!this.FirstChunksNotYetRead())
{
return;
}
int num = 0;
bool flag = false;
byte[] array = new byte[4];
this.CurrentChunkGroup = 1;
while (!flag)
{
num = PngHelperInternal.ReadInt4(this.inputStream);
this.offset += 4L;
if (num < 0)
{
break;
}
PngHelperInternal.ReadBytes(this.inputStream, array, 0, 4);
this.offset += 4L;
if (PngCsUtils.arraysEqual4(array, ChunkHelper.b_IDAT))
{
flag = true;
this.CurrentChunkGroup = 4;
this.chunksList.AppendReadChunk(new PngChunkIDAT(this.ImgInfo, num, this.offset - 8L), this.CurrentChunkGroup);
break;
}
if (PngCsUtils.arraysEqual4(array, ChunkHelper.b_IEND))
{
throw new PngjInputException("END chunk found before image data (IDAT) at offset=" + this.offset);
}
string text = ChunkHelper.ToString(array);
if (text.Equals("PLTE"))
{
this.CurrentChunkGroup = 2;
}
this.ReadChunk(array, num, false);
if (text.Equals("PLTE"))
{
this.CurrentChunkGroup = 3;
}
}
int num2 = (flag ? num : (-1));
if (num2 < 0)
{
throw new PngjInputException("first idat chunk not found!");
}
this.iIdatCstream = new PngIDatChunkInputStream(this.inputStream, num2, this.offset);
this.idatIstream = ZlibStreamFactory.createZlibInputStream(this.iIdatCstream, true);
if (!this.crcEnabled)
{
this.iIdatCstream.DisableCrcCheck();
}
}
// Token: 0x0600022C RID: 556 RVA: 0x00008A1C File Offset: 0x00006C1C
private void ReadLastChunks()
{
this.CurrentChunkGroup = 5;
if (!this.iIdatCstream.IsEnded())
{
this.iIdatCstream.ForceChunkEnd();
}
int num = this.iIdatCstream.GetLenLastChunk();
byte[] idLastChunk = this.iIdatCstream.GetIdLastChunk();
bool flag = false;
bool flag2 = true;
while (!flag)
{
bool flag3 = false;
if (!flag2)
{
num = PngHelperInternal.ReadInt4(this.inputStream);
this.offset += 4L;
if (num < 0)
{
throw new PngjInputException("bad len " + num);
}
PngHelperInternal.ReadBytes(this.inputStream, idLastChunk, 0, 4);
this.offset += 4L;
}
flag2 = false;
if (PngCsUtils.arraysEqual4(idLastChunk, ChunkHelper.b_IDAT))
{
flag3 = true;
}
else if (PngCsUtils.arraysEqual4(idLastChunk, ChunkHelper.b_IEND))
{
this.CurrentChunkGroup = 6;
flag = true;
}
this.ReadChunk(idLastChunk, num, flag3);
}
if (!flag)
{
throw new PngjInputException("end chunk not found - offset=" + this.offset);
}
}
// Token: 0x0600022D RID: 557 RVA: 0x00008B20 File Offset: 0x00006D20
private PngChunk ReadChunk(byte[] chunkid, int clen, bool skipforced)
{
if (clen < 0)
{
throw new PngjInputException("invalid chunk lenght: " + clen);
}
if (this.skipChunkIdsSet == null && this.CurrentChunkGroup > 0)
{
this.skipChunkIdsSet = new Dictionary<string, int>();
if (this.SkipChunkIds != null)
{
foreach (string text in this.SkipChunkIds)
{
this.skipChunkIdsSet.Add(text, 1);
}
}
}
string text2 = ChunkHelper.ToString(chunkid);
bool flag = ChunkHelper.IsCritical(text2);
bool flag2 = skipforced;
if (this.MaxTotalBytesRead > 0L && (long)clen + this.offset > this.MaxTotalBytesRead)
{
throw new PngjInputException(string.Concat(new object[] { "Maximum total bytes to read exceeeded: ", this.MaxTotalBytesRead, " offset:", this.offset, " clen=", clen }));
}
if (this.CurrentChunkGroup > 0 && !ChunkHelper.IsCritical(text2))
{
flag2 = flag2 || (this.SkipChunkMaxSize > 0 && clen >= this.SkipChunkMaxSize) || this.skipChunkIdsSet.ContainsKey(text2) || (this.MaxBytesMetadata > 0L && (long)clen > this.MaxBytesMetadata - (long)this.bytesChunksLoaded) || !ChunkHelper.ShouldLoad(text2, this.ChunkLoadBehaviour);
}
PngChunk pngChunk;
if (flag2)
{
PngHelperInternal.SkipBytes(this.inputStream, clen);
PngHelperInternal.ReadInt4(this.inputStream);
pngChunk = new PngChunkSkipped(text2, this.ImgInfo, clen);
}
else
{
ChunkRaw chunkRaw = new ChunkRaw(clen, chunkid, true);
chunkRaw.ReadChunkData(this.inputStream, this.crcEnabled || flag);
pngChunk = PngChunk.Factory(chunkRaw, this.ImgInfo);
if (!pngChunk.Crit)
{
this.bytesChunksLoaded += chunkRaw.Length;
}
}
pngChunk.Offset = this.offset - 8L;
this.chunksList.AppendReadChunk(pngChunk, this.CurrentChunkGroup);
this.offset += (long)clen + 4L;
return pngChunk;
}
// Token: 0x0600022E RID: 558 RVA: 0x00008D32 File Offset: 0x00006F32
internal void logWarn(string warn)
{
Console.Error.WriteLine(warn);
}
// Token: 0x0600022F RID: 559 RVA: 0x00008D3F File Offset: 0x00006F3F
public ChunksList GetChunksList()
{
if (this.FirstChunksNotYetRead())
{
this.ReadFirstChunks();
}
return this.chunksList;
}
// Token: 0x06000230 RID: 560 RVA: 0x00008D55 File Offset: 0x00006F55
public PngMetadata GetMetadata()
{
if (this.FirstChunksNotYetRead())
{
this.ReadFirstChunks();
}
return this.metadata;
}
// Token: 0x06000231 RID: 561 RVA: 0x00008D6B File Offset: 0x00006F6B
public ImageLine ReadRow(int nrow)
{
if (this.imgLine != null && this.imgLine.SampleType == ImageLine.ESampleType.BYTE)
{
return this.ReadRowByte(nrow);
}
return this.ReadRowInt(nrow);
}
// Token: 0x06000232 RID: 562 RVA: 0x00008D94 File Offset: 0x00006F94
public ImageLine ReadRowInt(int nrow)
{
if (this.imgLine == null)
{
this.imgLine = new ImageLine(this.ImgInfo, ImageLine.ESampleType.INT, this.unpackedMode);
}
if (this.imgLine.Rown == nrow)
{
return this.imgLine;
}
this.ReadRowInt(this.imgLine.Scanline, nrow);
this.imgLine.FilterUsed = (FilterType)this.rowbfilter[0];
this.imgLine.Rown = nrow;
return this.imgLine;
}
// Token: 0x06000233 RID: 563 RVA: 0x00008E10 File Offset: 0x00007010
public ImageLine ReadRowByte(int nrow)
{
if (this.imgLine == null)
{
this.imgLine = new ImageLine(this.ImgInfo, ImageLine.ESampleType.BYTE, this.unpackedMode);
}
if (this.imgLine.Rown == nrow)
{
return this.imgLine;
}
this.ReadRowByte(this.imgLine.ScanlineB, nrow);
this.imgLine.FilterUsed = (FilterType)this.rowbfilter[0];
this.imgLine.Rown = nrow;
return this.imgLine;
}
// Token: 0x06000234 RID: 564 RVA: 0x00008E8A File Offset: 0x0000708A
public int[] ReadRow(int[] buffer, int nrow)
{
return this.ReadRowInt(buffer, nrow);
}
// Token: 0x06000235 RID: 565 RVA: 0x00008E94 File Offset: 0x00007094
public int[] ReadRowInt(int[] buffer, int nrow)
{
if (buffer == null)
{
buffer = new int[this.unpackedMode ? this.ImgInfo.SamplesPerRow : this.ImgInfo.SamplesPerRowPacked];
}
if (!this.interlaced)
{
if (nrow <= this.rowNum)
{
throw new PngjInputException("rows must be read in increasing order: " + nrow);
}
int num = 0;
while (this.rowNum < nrow)
{
num = this.ReadRowRaw(this.rowNum + 1);
}
this.decodeLastReadRowToInt(buffer, num);
}
else
{
if (this.deinterlacer.getImageInt() == null)
{
this.deinterlacer.setImageInt(this.ReadRowsInt().Scanlines);
}
Array.Copy(this.deinterlacer.getImageInt()[nrow], 0, buffer, 0, this.unpackedMode ? this.ImgInfo.SamplesPerRow : this.ImgInfo.SamplesPerRowPacked);
}
return buffer;
}
// Token: 0x06000236 RID: 566 RVA: 0x00008F74 File Offset: 0x00007174
public byte[] ReadRowByte(byte[] buffer, int nrow)
{
if (buffer == null)
{
buffer = new byte[this.unpackedMode ? this.ImgInfo.SamplesPerRow : this.ImgInfo.SamplesPerRowPacked];
}
if (!this.interlaced)
{
if (nrow <= this.rowNum)
{
throw new PngjInputException("rows must be read in increasing order: " + nrow);
}
int num = 0;
while (this.rowNum < nrow)
{
num = this.ReadRowRaw(this.rowNum + 1);
}
this.decodeLastReadRowToByte(buffer, num);
}
else
{
if (this.deinterlacer.getImageByte() == null)
{
this.deinterlacer.setImageByte(this.ReadRowsByte().ScanlinesB);
}
Array.Copy(this.deinterlacer.getImageByte()[nrow], 0, buffer, 0, this.unpackedMode ? this.ImgInfo.SamplesPerRow : this.ImgInfo.SamplesPerRowPacked);
}
return buffer;
}
// Token: 0x06000237 RID: 567 RVA: 0x00009051 File Offset: 0x00007251
[Obsolete("GetRow is deprecated, use ReadRow/ReadRowInt/ReadRowByte instead.")]
public ImageLine GetRow(int nrow)
{
return this.ReadRow(nrow);
}
// Token: 0x06000238 RID: 568 RVA: 0x0000905C File Offset: 0x0000725C
private void decodeLastReadRowToInt(int[] buffer, int bytesRead)
{
if (this.ImgInfo.BitDepth <= 8)
{
int i = 0;
int num = 1;
while (i < bytesRead)
{
buffer[i] = (int)this.rowb[num++];
i++;
}
}
else
{
int num2 = 0;
int j = 1;
while (j < bytesRead)
{
buffer[num2] = ((int)this.rowb[j++] << 8) + (int)this.rowb[j++];
num2++;
}
}
if (this.ImgInfo.Packed && this.unpackedMode)
{
ImageLine.unpackInplaceInt(this.ImgInfo, buffer, buffer, false);
}
}
// Token: 0x06000239 RID: 569 RVA: 0x000090E8 File Offset: 0x000072E8
private void decodeLastReadRowToByte(byte[] buffer, int bytesRead)
{
if (this.ImgInfo.BitDepth <= 8)
{
Array.Copy(this.rowb, 1, buffer, 0, bytesRead);
}
else
{
int num = 0;
for (int i = 1; i < bytesRead; i += 2)
{
buffer[num] = this.rowb[i];
num++;
}
}
if (this.ImgInfo.Packed && this.unpackedMode)
{
ImageLine.unpackInplaceByte(this.ImgInfo, buffer, buffer, false);
}
}
// Token: 0x0600023A RID: 570 RVA: 0x00009154 File Offset: 0x00007354
public ImageLines ReadRowsInt(int rowOffset, int nRows, int rowStep)
{
if (nRows < 0)
{
nRows = (this.ImgInfo.Rows - rowOffset) / rowStep;
}
if (rowStep < 1 || rowOffset < 0 || nRows * rowStep + rowOffset > this.ImgInfo.Rows)
{
throw new PngjInputException("bad args");
}
ImageLines imageLines = new ImageLines(this.ImgInfo, ImageLine.ESampleType.INT, this.unpackedMode, rowOffset, nRows, rowStep);
if (!this.interlaced)
{
for (int i = 0; i < this.ImgInfo.Rows; i++)
{
int num = this.ReadRowRaw(i);
int num2 = imageLines.ImageRowToMatrixRowStrict(i);
if (num2 >= 0)
{
this.decodeLastReadRowToInt(imageLines.Scanlines[num2], num);
}
}
}
else
{
int[] array = new int[this.unpackedMode ? this.ImgInfo.SamplesPerRow : this.ImgInfo.SamplesPerRowPacked];
for (int j = 1; j <= 7; j++)
{
this.deinterlacer.setPass(j);
for (int k = 0; k < this.deinterlacer.getRows(); k++)
{
int num3 = this.ReadRowRaw(k);
int currRowReal = this.deinterlacer.getCurrRowReal();
int num4 = imageLines.ImageRowToMatrixRowStrict(currRowReal);
if (num4 >= 0)
{
this.decodeLastReadRowToInt(array, num3);
this.deinterlacer.deinterlaceInt(array, imageLines.Scanlines[num4], !this.unpackedMode);
}
}
}
}
this.End();
return imageLines;
}
// Token: 0x0600023B RID: 571 RVA: 0x000092AE File Offset: 0x000074AE
public ImageLines ReadRowsInt()
{
return this.ReadRowsInt(0, this.ImgInfo.Rows, 1);
}
// Token: 0x0600023C RID: 572 RVA: 0x000092C4 File Offset: 0x000074C4
public ImageLines ReadRowsByte(int rowOffset, int nRows, int rowStep)
{
if (nRows < 0)
{
nRows = (this.ImgInfo.Rows - rowOffset) / rowStep;
}
if (rowStep < 1 || rowOffset < 0 || nRows * rowStep + rowOffset > this.ImgInfo.Rows)
{
throw new PngjInputException("bad args");
}
ImageLines imageLines = new ImageLines(this.ImgInfo, ImageLine.ESampleType.BYTE, this.unpackedMode, rowOffset, nRows, rowStep);
if (!this.interlaced)
{
for (int i = 0; i < this.ImgInfo.Rows; i++)
{
int num = this.ReadRowRaw(i);
int num2 = imageLines.ImageRowToMatrixRowStrict(i);
if (num2 >= 0)
{
this.decodeLastReadRowToByte(imageLines.ScanlinesB[num2], num);
}
}
}
else
{
byte[] array = new byte[this.unpackedMode ? this.ImgInfo.SamplesPerRow : this.ImgInfo.SamplesPerRowPacked];
for (int j = 1; j <= 7; j++)
{
this.deinterlacer.setPass(j);
for (int k = 0; k < this.deinterlacer.getRows(); k++)
{
int num3 = this.ReadRowRaw(k);
int currRowReal = this.deinterlacer.getCurrRowReal();
int num4 = imageLines.ImageRowToMatrixRowStrict(currRowReal);
if (num4 >= 0)
{
this.decodeLastReadRowToByte(array, num3);
this.deinterlacer.deinterlaceByte(array, imageLines.ScanlinesB[num4], !this.unpackedMode);
}
}
}
}
this.End();
return imageLines;
}
// Token: 0x0600023D RID: 573 RVA: 0x0000941E File Offset: 0x0000761E
public ImageLines ReadRowsByte()
{
return this.ReadRowsByte(0, this.ImgInfo.Rows, 1);
}
// Token: 0x0600023E RID: 574 RVA: 0x00009434 File Offset: 0x00007634
private int ReadRowRaw(int nrow)
{
if (nrow == 0 && this.FirstChunksNotYetRead())
{
this.ReadFirstChunks();
}
if (nrow == 0 && this.interlaced)
{
Array.Clear(this.rowb, 0, this.rowb.Length);
}
int num = this.ImgInfo.BytesPerRow;
if (this.interlaced)
{
if (nrow < 0 || nrow > this.deinterlacer.getRows() || (nrow != 0 && nrow != this.deinterlacer.getCurrRowSubimg() + 1))
{
throw new PngjInputException("invalid row in interlaced mode: " + nrow);
}
this.deinterlacer.setRow(nrow);
num = (this.ImgInfo.BitspPixel * this.deinterlacer.getPixelsToRead() + 7) / 8;
if (num < 1)
{
throw new PngjExceptionInternal("wtf??");
}
}
else if (nrow < 0 || nrow >= this.ImgInfo.Rows || nrow != this.rowNum + 1)
{
throw new PngjInputException("invalid row: " + nrow);
}
this.rowNum = nrow;
byte[] array = this.rowb;
this.rowb = this.rowbprev;
this.rowbprev = array;
PngHelperInternal.ReadBytes(this.idatIstream, this.rowbfilter, 0, num + 1);
this.offset = this.iIdatCstream.GetOffset();
if (this.offset < 0L)
{
throw new PngjExceptionInternal("bad offset ??" + this.offset);
}
if (this.MaxTotalBytesRead > 0L && this.offset >= this.MaxTotalBytesRead)
{
throw new PngjInputException(string.Concat(new object[] { "Reading IDAT: Maximum total bytes to read exceeeded: ", this.MaxTotalBytesRead, " offset:", this.offset }));
}
this.rowb[0] = 0;
this.UnfilterRow(num);
this.rowb[0] = this.rowbfilter[0];
if ((this.rowNum == this.ImgInfo.Rows - 1 && !this.interlaced) || (this.interlaced && this.deinterlacer.isAtLastRow()))
{
this.ReadLastAndClose();
}
return num;
}
// Token: 0x0600023F RID: 575 RVA: 0x00009648 File Offset: 0x00007848
public void ReadSkippingAllRows()
{
if (this.FirstChunksNotYetRead())
{
this.ReadFirstChunks();
}
this.iIdatCstream.DisableCrcCheck();
try
{
int num;
do
{
num = this.iIdatCstream.Read(this.rowbfilter, 0, this.rowbfilter.Length);
}
while (num >= 0);
}
catch (IOException ex)
{
throw new PngjInputException("error in raw read of IDAT", ex);
}
this.offset = this.iIdatCstream.GetOffset();
if (this.offset < 0L)
{
throw new PngjExceptionInternal("bad offset ??" + this.offset);
}
if (this.MaxTotalBytesRead > 0L && this.offset >= this.MaxTotalBytesRead)
{
throw new PngjInputException(string.Concat(new object[] { "Reading IDAT: Maximum total bytes to read exceeeded: ", this.MaxTotalBytesRead, " offset:", this.offset }));
}
this.ReadLastAndClose();
}
// Token: 0x06000240 RID: 576 RVA: 0x00009740 File Offset: 0x00007940
public override string ToString()
{
return "filename=" + this.filename + " " + this.ImgInfo.ToString();
}
// Token: 0x06000241 RID: 577 RVA: 0x00009762 File Offset: 0x00007962
public void End()
{
if (this.CurrentChunkGroup < 6)
{
this.Close();
}
}
// Token: 0x06000242 RID: 578 RVA: 0x00009773 File Offset: 0x00007973
public bool IsInterlaced()
{
return this.interlaced;
}
// Token: 0x06000243 RID: 579 RVA: 0x0000977B File Offset: 0x0000797B
public void SetUnpackedMode(bool unPackedMode)
{
this.unpackedMode = unPackedMode;
}
// Token: 0x06000244 RID: 580 RVA: 0x00009784 File Offset: 0x00007984
public bool IsUnpackedMode()
{
return this.unpackedMode;
}
// Token: 0x06000245 RID: 581 RVA: 0x0000978C File Offset: 0x0000798C
public void SetCrcCheckDisabled()
{
this.crcEnabled = false;
}
// Token: 0x06000246 RID: 582 RVA: 0x00009795 File Offset: 0x00007995
internal long GetCrctestVal()
{
return (long)((ulong)this.crctest.GetValue());
}
// Token: 0x06000247 RID: 583 RVA: 0x000097A3 File Offset: 0x000079A3
internal void InitCrctest()
{
this.crctest = new Adler32();
}
// Token: 0x04000118 RID: 280
protected readonly string filename;
// Token: 0x04000119 RID: 281
private Dictionary<string, int> skipChunkIdsSet;
// Token: 0x0400011A RID: 282
private readonly PngMetadata metadata;
// Token: 0x0400011B RID: 283
private readonly ChunksList chunksList;
// Token: 0x0400011C RID: 284
protected ImageLine imgLine;
// Token: 0x0400011D RID: 285
protected byte[] rowb;
// Token: 0x0400011E RID: 286
protected byte[] rowbprev;
// Token: 0x0400011F RID: 287
protected byte[] rowbfilter;
// Token: 0x04000120 RID: 288
public readonly bool interlaced;
// Token: 0x04000121 RID: 289
private readonly PngDeinterlacer deinterlacer;
// Token: 0x04000122 RID: 290
private bool crcEnabled = true;
// Token: 0x04000123 RID: 291
private bool unpackedMode;
// Token: 0x04000124 RID: 292
protected int rowNum = -1;
// Token: 0x04000125 RID: 293
private long offset;
// Token: 0x04000126 RID: 294
private int bytesChunksLoaded;
// Token: 0x04000127 RID: 295
private readonly Stream inputStream;
// Token: 0x04000128 RID: 296
internal AZlibInputStream idatIstream;
// Token: 0x04000129 RID: 297
internal PngIDatChunkInputStream iIdatCstream;
// Token: 0x0400012A RID: 298
protected Adler32 crctest;
}
}
+669
View File
@@ -0,0 +1,669 @@
using System;
using System.Collections.Generic;
using System.IO;
using Hjg.Pngcs.Chunks;
using Hjg.Pngcs.Zlib;
namespace Hjg.Pngcs
{
// Token: 0x0200003F RID: 63
public class PngWriter
{
// Token: 0x17000037 RID: 55
// (get) Token: 0x06000248 RID: 584 RVA: 0x000097B0 File Offset: 0x000079B0
// (set) Token: 0x06000249 RID: 585 RVA: 0x000097B8 File Offset: 0x000079B8
public EDeflateCompressStrategy CompressionStrategy { get; set; }
// Token: 0x17000038 RID: 56
// (get) Token: 0x0600024A RID: 586 RVA: 0x000097C1 File Offset: 0x000079C1
// (set) Token: 0x0600024B RID: 587 RVA: 0x000097C9 File Offset: 0x000079C9
public int CompLevel { get; set; }
// Token: 0x17000039 RID: 57
// (get) Token: 0x0600024C RID: 588 RVA: 0x000097D2 File Offset: 0x000079D2
// (set) Token: 0x0600024D RID: 589 RVA: 0x000097DA File Offset: 0x000079DA
public bool ShouldCloseStream { get; set; }
// Token: 0x1700003A RID: 58
// (get) Token: 0x0600024E RID: 590 RVA: 0x000097E3 File Offset: 0x000079E3
// (set) Token: 0x0600024F RID: 591 RVA: 0x000097EB File Offset: 0x000079EB
public int IdatMaxSize { get; set; }
// Token: 0x1700003B RID: 59
// (get) Token: 0x06000250 RID: 592 RVA: 0x000097F4 File Offset: 0x000079F4
// (set) Token: 0x06000251 RID: 593 RVA: 0x000097FC File Offset: 0x000079FC
public int CurrentChunkGroup { get; private set; }
// Token: 0x06000252 RID: 594 RVA: 0x00009805 File Offset: 0x00007A05
public PngWriter(Stream outputStream, ImageInfo imgInfo)
: this(outputStream, imgInfo, "[NO FILENAME AVAILABLE]")
{
}
// Token: 0x06000253 RID: 595 RVA: 0x00009814 File Offset: 0x00007A14
public PngWriter(Stream outputStream, ImageInfo imgInfo, string filename)
{
this.filename = ((filename == null) ? "" : filename);
this.outputStream = outputStream;
this.ImgInfo = imgInfo;
this.CompLevel = 6;
this.ShouldCloseStream = true;
this.IdatMaxSize = 0;
this.CompressionStrategy = EDeflateCompressStrategy.Filtered;
this.rowb = new byte[imgInfo.BytesPerRow + 1];
this.rowbprev = new byte[this.rowb.Length];
this.rowbfilter = new byte[this.rowb.Length];
this.chunksList = new ChunksListForWrite(this.ImgInfo);
this.metadata = new PngMetadata(this.chunksList);
this.filterStrat = new FilterWriteStrategy(this.ImgInfo, FilterType.FILTER_DEFAULT);
this.unpackedMode = false;
this.needsPack = this.unpackedMode && imgInfo.Packed;
}
// Token: 0x06000254 RID: 596 RVA: 0x00009904 File Offset: 0x00007B04
private void init()
{
this.datStream = new PngIDatChunkOutputStream(this.outputStream, this.IdatMaxSize);
this.datStreamDeflated = ZlibStreamFactory.createZlibOutputStream(this.datStream, this.CompLevel, this.CompressionStrategy, true);
this.WriteSignatureAndIHDR();
this.WriteFirstChunks();
}
// Token: 0x06000255 RID: 597 RVA: 0x00009954 File Offset: 0x00007B54
private void reportResultsForFilter(int rown, FilterType type, bool tentative)
{
for (int i = 0; i < this.histox.Length; i++)
{
this.histox[i] = 0;
}
int num = 0;
for (int j = 1; j <= this.ImgInfo.BytesPerRow; j++)
{
int num2 = (int)this.rowbfilter[j];
if (num2 < 0)
{
num -= num2;
}
else
{
num += num2;
}
this.histox[num2 & 255]++;
}
this.filterStrat.fillResultsForFilter(rown, type, (double)num, this.histox, tentative);
}
// Token: 0x06000256 RID: 598 RVA: 0x000099E4 File Offset: 0x00007BE4
private void WriteEndChunk()
{
PngChunkIEND pngChunkIEND = new PngChunkIEND(this.ImgInfo);
pngChunkIEND.CreateRawChunk().WriteChunk(this.outputStream);
}
// Token: 0x06000257 RID: 599 RVA: 0x00009A10 File Offset: 0x00007C10
private void WriteFirstChunks()
{
this.CurrentChunkGroup = 1;
int num = this.chunksList.writeChunks(this.outputStream, this.CurrentChunkGroup);
this.CurrentChunkGroup = 2;
num = this.chunksList.writeChunks(this.outputStream, this.CurrentChunkGroup);
if (num > 0 && this.ImgInfo.Greyscale)
{
throw new PngjOutputException("cannot write palette for this format");
}
if (num == 0 && this.ImgInfo.Indexed)
{
throw new PngjOutputException("missing palette");
}
this.CurrentChunkGroup = 3;
num = this.chunksList.writeChunks(this.outputStream, this.CurrentChunkGroup);
this.CurrentChunkGroup = 4;
}
// Token: 0x06000258 RID: 600 RVA: 0x00009ABC File Offset: 0x00007CBC
private void WriteLastChunks()
{
this.CurrentChunkGroup = 5;
this.chunksList.writeChunks(this.outputStream, this.CurrentChunkGroup);
List<PngChunk> queuedChunks = this.chunksList.GetQueuedChunks();
if (queuedChunks.Count > 0)
{
throw new PngjOutputException(queuedChunks.Count + " chunks were not written! Eg: " + queuedChunks[0].ToString());
}
this.CurrentChunkGroup = 6;
}
// Token: 0x06000259 RID: 601 RVA: 0x00009B2C File Offset: 0x00007D2C
private void WriteSignatureAndIHDR()
{
this.CurrentChunkGroup = 0;
PngHelperInternal.WriteBytes(this.outputStream, PngHelperInternal.PNG_ID_SIGNATURE);
PngChunkIHDR pngChunkIHDR = new PngChunkIHDR(this.ImgInfo);
pngChunkIHDR.Cols = this.ImgInfo.Cols;
pngChunkIHDR.Rows = this.ImgInfo.Rows;
pngChunkIHDR.Bitspc = this.ImgInfo.BitDepth;
int num = 0;
if (this.ImgInfo.Alpha)
{
num += 4;
}
if (this.ImgInfo.Indexed)
{
num++;
}
if (!this.ImgInfo.Greyscale)
{
num += 2;
}
pngChunkIHDR.Colormodel = num;
pngChunkIHDR.Compmeth = 0;
pngChunkIHDR.Filmeth = 0;
pngChunkIHDR.Interlaced = 0;
pngChunkIHDR.CreateRawChunk().WriteChunk(this.outputStream);
}
// Token: 0x0600025A RID: 602 RVA: 0x00009BF4 File Offset: 0x00007DF4
protected void encodeRowFromByte(byte[] row)
{
if (row.Length == this.ImgInfo.SamplesPerRowPacked && !this.needsPack)
{
int num = 1;
if (this.ImgInfo.BitDepth <= 8)
{
foreach (byte b in row)
{
this.rowb[num++] = b;
}
return;
}
foreach (byte b2 in row)
{
this.rowb[num] = b2;
num += 2;
}
return;
}
else
{
if (row.Length >= this.ImgInfo.SamplesPerRow && this.needsPack)
{
ImageLine.packInplaceByte(this.ImgInfo, row, row, false);
}
if (this.ImgInfo.BitDepth <= 8)
{
int k = 0;
int num2 = 1;
while (k < this.ImgInfo.SamplesPerRowPacked)
{
this.rowb[num2++] = row[k];
k++;
}
return;
}
int l = 0;
int num3 = 1;
while (l < this.ImgInfo.SamplesPerRowPacked)
{
this.rowb[num3++] = row[l];
this.rowb[num3++] = 0;
l++;
}
return;
}
}
// Token: 0x0600025B RID: 603 RVA: 0x00009D1C File Offset: 0x00007F1C
protected void encodeRowFromInt(int[] row)
{
if (row.Length == this.ImgInfo.SamplesPerRowPacked && !this.needsPack)
{
int num = 1;
if (this.ImgInfo.BitDepth <= 8)
{
foreach (int num2 in row)
{
this.rowb[num++] = (byte)num2;
}
return;
}
foreach (int num3 in row)
{
this.rowb[num++] = (byte)(num3 >> 8);
this.rowb[num++] = (byte)num3;
}
return;
}
else
{
if (row.Length >= this.ImgInfo.SamplesPerRow && this.needsPack)
{
ImageLine.packInplaceInt(this.ImgInfo, row, row, false);
}
if (this.ImgInfo.BitDepth <= 8)
{
int k = 0;
int num4 = 1;
while (k < this.ImgInfo.SamplesPerRowPacked)
{
this.rowb[num4++] = (byte)row[k];
k++;
}
return;
}
int l = 0;
int num5 = 1;
while (l < this.ImgInfo.SamplesPerRowPacked)
{
this.rowb[num5++] = (byte)(row[l] >> 8);
this.rowb[num5++] = (byte)row[l];
l++;
}
return;
}
}
// Token: 0x0600025C RID: 604 RVA: 0x00009E5C File Offset: 0x0000805C
private void FilterRow(int rown)
{
if (this.filterStrat.shouldTestAll(rown))
{
this.FilterRowNone();
this.reportResultsForFilter(rown, FilterType.FILTER_NONE, true);
this.FilterRowSub();
this.reportResultsForFilter(rown, FilterType.FILTER_SUB, true);
this.FilterRowUp();
this.reportResultsForFilter(rown, FilterType.FILTER_UP, true);
this.FilterRowAverage();
this.reportResultsForFilter(rown, FilterType.FILTER_AVERAGE, true);
this.FilterRowPaeth();
this.reportResultsForFilter(rown, FilterType.FILTER_PAETH, true);
}
FilterType filterType = this.filterStrat.gimmeFilterType(rown, true);
this.rowbfilter[0] = (byte)filterType;
switch (filterType)
{
case FilterType.FILTER_NONE:
this.FilterRowNone();
break;
case FilterType.FILTER_SUB:
this.FilterRowSub();
break;
case FilterType.FILTER_UP:
this.FilterRowUp();
break;
case FilterType.FILTER_AVERAGE:
this.FilterRowAverage();
break;
case FilterType.FILTER_PAETH:
this.FilterRowPaeth();
break;
default:
throw new PngjOutputException("Filter type " + filterType + " not implemented");
}
this.reportResultsForFilter(rown, filterType, false);
}
// Token: 0x0600025D RID: 605 RVA: 0x00009F44 File Offset: 0x00008144
private void prepareEncodeRow(int rown)
{
if (this.datStream == null)
{
this.init();
}
this.rowNum++;
if (rown >= 0 && this.rowNum != rown)
{
throw new PngjOutputException(string.Concat(new object[] { "rows must be written in order: expected:", this.rowNum, " passed:", rown }));
}
byte[] array = this.rowb;
this.rowb = this.rowbprev;
this.rowbprev = array;
}
// Token: 0x0600025E RID: 606 RVA: 0x00009FCE File Offset: 0x000081CE
private void filterAndSend(int rown)
{
this.FilterRow(rown);
this.datStreamDeflated.Write(this.rowbfilter, 0, this.ImgInfo.BytesPerRow + 1);
}
// Token: 0x0600025F RID: 607 RVA: 0x00009FF8 File Offset: 0x000081F8
private void FilterRowAverage()
{
int bytesPerRow = this.ImgInfo.BytesPerRow;
int num = 1 - this.ImgInfo.BytesPixel;
int i = 1;
while (i <= bytesPerRow)
{
this.rowbfilter[i] = this.rowb[i] - (this.rowbprev[i] + ((num > 0) ? this.rowb[num] : 0)) / 2;
i++;
num++;
}
}
// Token: 0x06000260 RID: 608 RVA: 0x0000A05C File Offset: 0x0000825C
private void FilterRowNone()
{
for (int i = 1; i <= this.ImgInfo.BytesPerRow; i++)
{
this.rowbfilter[i] = this.rowb[i];
}
}
// Token: 0x06000261 RID: 609 RVA: 0x0000A090 File Offset: 0x00008290
private void FilterRowPaeth()
{
int bytesPerRow = this.ImgInfo.BytesPerRow;
int num = 1 - this.ImgInfo.BytesPixel;
int i = 1;
while (i <= bytesPerRow)
{
this.rowbfilter[i] = (byte)((int)this.rowb[i] - PngHelperInternal.FilterPaethPredictor((int)((num > 0) ? this.rowb[num] : 0), (int)this.rowbprev[i], (int)((num > 0) ? this.rowbprev[num] : 0)));
i++;
num++;
}
}
// Token: 0x06000262 RID: 610 RVA: 0x0000A104 File Offset: 0x00008304
private void FilterRowSub()
{
int i;
for (i = 1; i <= this.ImgInfo.BytesPixel; i++)
{
this.rowbfilter[i] = this.rowb[i];
}
int num = 1;
i = this.ImgInfo.BytesPixel + 1;
while (i <= this.ImgInfo.BytesPerRow)
{
this.rowbfilter[i] = this.rowb[i] - this.rowb[num];
i++;
num++;
}
}
// Token: 0x06000263 RID: 611 RVA: 0x0000A17C File Offset: 0x0000837C
private void FilterRowUp()
{
for (int i = 1; i <= this.ImgInfo.BytesPerRow; i++)
{
this.rowbfilter[i] = this.rowb[i] - this.rowbprev[i];
}
}
// Token: 0x06000264 RID: 612 RVA: 0x0000A1BC File Offset: 0x000083BC
private long SumRowbfilter()
{
long num = 0L;
for (int i = 1; i <= this.ImgInfo.BytesPerRow; i++)
{
if (this.rowbfilter[i] < 0)
{
num -= (long)((ulong)this.rowbfilter[i]);
}
else
{
num += (long)((ulong)this.rowbfilter[i]);
}
}
return num;
}
// Token: 0x06000265 RID: 613 RVA: 0x0000A208 File Offset: 0x00008408
private void CopyChunks(PngReader reader, int copy_mask, bool onlyAfterIdat)
{
bool flag = this.CurrentChunkGroup >= 4;
if (onlyAfterIdat && reader.CurrentChunkGroup < 6)
{
throw new PngjException("tried to copy last chunks but reader has not ended");
}
foreach (PngChunk pngChunk in reader.GetChunksList().GetChunks())
{
int chunkGroup = pngChunk.ChunkGroup;
if (chunkGroup >= 4 || !flag)
{
bool flag2 = false;
if (pngChunk.Crit)
{
if (pngChunk.Id.Equals("PLTE"))
{
if (this.ImgInfo.Indexed && ChunkHelper.maskMatch(copy_mask, ChunkCopyBehaviour.COPY_PALETTE))
{
flag2 = true;
}
if (!this.ImgInfo.Greyscale && ChunkHelper.maskMatch(copy_mask, ChunkCopyBehaviour.COPY_ALL))
{
flag2 = true;
}
}
}
else
{
bool flag3 = pngChunk is PngChunkTextVar;
bool safe = pngChunk.Safe;
if (ChunkHelper.maskMatch(copy_mask, ChunkCopyBehaviour.COPY_ALL))
{
flag2 = true;
}
if (safe && ChunkHelper.maskMatch(copy_mask, ChunkCopyBehaviour.COPY_ALL_SAFE))
{
flag2 = true;
}
if (pngChunk.Id.Equals("tRNS") && ChunkHelper.maskMatch(copy_mask, ChunkCopyBehaviour.COPY_TRANSPARENCY))
{
flag2 = true;
}
if (pngChunk.Id.Equals("pHYs") && ChunkHelper.maskMatch(copy_mask, ChunkCopyBehaviour.COPY_PHYS))
{
flag2 = true;
}
if (flag3 && ChunkHelper.maskMatch(copy_mask, ChunkCopyBehaviour.COPY_TEXTUAL))
{
flag2 = true;
}
if (ChunkHelper.maskMatch(copy_mask, ChunkCopyBehaviour.COPY_ALMOSTALL) && !ChunkHelper.IsUnknown(pngChunk) && !flag3 && !pngChunk.Id.Equals("hIST") && !pngChunk.Id.Equals("tIME"))
{
flag2 = true;
}
if (pngChunk is PngChunkSkipped)
{
flag2 = false;
}
}
if (flag2)
{
this.chunksList.Queue(PngChunk.CloneChunk<PngChunk>(pngChunk, this.ImgInfo));
}
}
}
}
// Token: 0x06000266 RID: 614 RVA: 0x0000A3F4 File Offset: 0x000085F4
public void CopyChunksFirst(PngReader reader, int copy_mask)
{
this.CopyChunks(reader, copy_mask, false);
}
// Token: 0x06000267 RID: 615 RVA: 0x0000A3FF File Offset: 0x000085FF
public void CopyChunksLast(PngReader reader, int copy_mask)
{
this.CopyChunks(reader, copy_mask, true);
}
// Token: 0x06000268 RID: 616 RVA: 0x0000A40C File Offset: 0x0000860C
public double ComputeCompressionRatio()
{
if (this.CurrentChunkGroup < 6)
{
throw new PngjException("must be called after End()");
}
double num = (double)this.datStream.GetCountFlushed();
double num2 = (double)((this.ImgInfo.BytesPerRow + 1) * this.ImgInfo.Rows);
return num / num2;
}
// Token: 0x06000269 RID: 617 RVA: 0x0000A458 File Offset: 0x00008658
public void End()
{
if (this.rowNum != this.ImgInfo.Rows - 1)
{
throw new PngjOutputException("all rows have not been written");
}
try
{
this.datStreamDeflated.Close();
this.datStream.Close();
this.WriteLastChunks();
this.WriteEndChunk();
if (this.ShouldCloseStream)
{
this.outputStream.Close();
}
}
catch (IOException ex)
{
throw new PngjOutputException(ex);
}
}
// Token: 0x0600026A RID: 618 RVA: 0x0000A4D4 File Offset: 0x000086D4
public string GetFilename()
{
return this.filename;
}
// Token: 0x0600026B RID: 619 RVA: 0x0000A4DC File Offset: 0x000086DC
public void WriteRow(ImageLine imgline, int rownumber)
{
this.SetUseUnPackedMode(imgline.SamplesUnpacked);
if (imgline.SampleType == ImageLine.ESampleType.INT)
{
this.WriteRowInt(imgline.Scanline, rownumber);
return;
}
this.WriteRowByte(imgline.ScanlineB, rownumber);
}
// Token: 0x0600026C RID: 620 RVA: 0x0000A50D File Offset: 0x0000870D
public void WriteRow(int[] newrow)
{
this.WriteRow(newrow, -1);
}
// Token: 0x0600026D RID: 621 RVA: 0x0000A517 File Offset: 0x00008717
public void WriteRow(int[] newrow, int rown)
{
this.WriteRowInt(newrow, rown);
}
// Token: 0x0600026E RID: 622 RVA: 0x0000A521 File Offset: 0x00008721
public void WriteRowInt(int[] newrow, int rown)
{
this.prepareEncodeRow(rown);
this.encodeRowFromInt(newrow);
this.filterAndSend(rown);
}
// Token: 0x0600026F RID: 623 RVA: 0x0000A538 File Offset: 0x00008738
public void WriteRowByte(byte[] newrow, int rown)
{
this.prepareEncodeRow(rown);
this.encodeRowFromByte(newrow);
this.filterAndSend(rown);
}
// Token: 0x06000270 RID: 624 RVA: 0x0000A550 File Offset: 0x00008750
public void WriteRowsInt(int[][] image)
{
for (int i = 0; i < this.ImgInfo.Rows; i++)
{
this.WriteRowInt(image[i], i);
}
}
// Token: 0x06000271 RID: 625 RVA: 0x0000A580 File Offset: 0x00008780
public void WriteRowsByte(byte[][] image)
{
for (int i = 0; i < this.ImgInfo.Rows; i++)
{
this.WriteRowByte(image[i], i);
}
}
// Token: 0x06000272 RID: 626 RVA: 0x0000A5AD File Offset: 0x000087AD
public PngMetadata GetMetadata()
{
return this.metadata;
}
// Token: 0x06000273 RID: 627 RVA: 0x0000A5B5 File Offset: 0x000087B5
public ChunksListForWrite GetChunksList()
{
return this.chunksList;
}
// Token: 0x06000274 RID: 628 RVA: 0x0000A5BD File Offset: 0x000087BD
public void SetFilterType(FilterType filterType)
{
this.filterStrat = new FilterWriteStrategy(this.ImgInfo, filterType);
}
// Token: 0x06000275 RID: 629 RVA: 0x0000A5D1 File Offset: 0x000087D1
public bool IsUnpackedMode()
{
return this.unpackedMode;
}
// Token: 0x06000276 RID: 630 RVA: 0x0000A5D9 File Offset: 0x000087D9
public void SetUseUnPackedMode(bool useUnpackedMode)
{
this.unpackedMode = useUnpackedMode;
this.needsPack = this.unpackedMode && this.ImgInfo.Packed;
}
// Token: 0x04000133 RID: 307
public readonly ImageInfo ImgInfo;
// Token: 0x04000134 RID: 308
protected readonly string filename;
// Token: 0x04000135 RID: 309
private FilterWriteStrategy filterStrat;
// Token: 0x04000136 RID: 310
private readonly PngMetadata metadata;
// Token: 0x04000137 RID: 311
private readonly ChunksListForWrite chunksList;
// Token: 0x04000138 RID: 312
protected byte[] rowb;
// Token: 0x04000139 RID: 313
protected byte[] rowbprev;
// Token: 0x0400013A RID: 314
protected byte[] rowbfilter;
// Token: 0x0400013B RID: 315
private int rowNum = -1;
// Token: 0x0400013C RID: 316
private readonly Stream outputStream;
// Token: 0x0400013D RID: 317
private PngIDatChunkOutputStream datStream;
// Token: 0x0400013E RID: 318
private AZlibOutputStream datStreamDeflated;
// Token: 0x0400013F RID: 319
private int[] histox = new int[256];
// Token: 0x04000140 RID: 320
private bool unpackedMode;
// Token: 0x04000141 RID: 321
private bool needsPack;
}
}
+120
View File
@@ -0,0 +1,120 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{99604A24-13D0-4C83-A3AA-9A315339FA4F}</ProjectGuid>
<OutputType>Library</OutputType>
<RootNamespace>Hjg.Pngcs</RootNamespace>
<AssemblyName>Pngcs</AssemblyName>
<TargetFrameworkVersion>v2.0</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<NoStdLib>true</NoStdLib>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<NoStdLib>true</NoStdLib>
</PropertyGroup>
<ItemGroup />
<ItemGroup>
<AppDesigner Include="Properties\" />
</ItemGroup>
<ItemGroup>
<Compile Include="Chunks\ChunkCopyBehaviour.cs" />
<Compile Include="Chunks\ChunkHelper.cs" />
<Compile Include="Chunks\ChunkLoadBehaviour.cs" />
<Compile Include="Chunks\ChunkPredicate.cs" />
<Compile Include="Chunks\ChunkPredicateEquiv.cs" />
<Compile Include="Chunks\ChunkPredicateId.cs" />
<Compile Include="Chunks\ChunkPredicateId2.cs" />
<Compile Include="Chunks\ChunkRaw.cs" />
<Compile Include="Chunks\ChunksList.cs" />
<Compile Include="Chunks\ChunksListForWrite.cs" />
<Compile Include="Chunks\PngChunk.cs" />
<Compile Include="Chunks\PngChunkBKGD.cs" />
<Compile Include="Chunks\PngChunkCHRM.cs" />
<Compile Include="Chunks\PngChunkGAMA.cs" />
<Compile Include="Chunks\PngChunkHIST.cs" />
<Compile Include="Chunks\PngChunkICCP.cs" />
<Compile Include="Chunks\PngChunkIDAT.cs" />
<Compile Include="Chunks\PngChunkIEND.cs" />
<Compile Include="Chunks\PngChunkIHDR.cs" />
<Compile Include="Chunks\PngChunkITXT.cs" />
<Compile Include="Chunks\PngChunkMultiple.cs" />
<Compile Include="Chunks\PngChunkOFFS.cs" />
<Compile Include="Chunks\PngChunkPHYS.cs" />
<Compile Include="Chunks\PngChunkPLTE.cs" />
<Compile Include="Chunks\PngChunkSBIT.cs" />
<Compile Include="Chunks\PngChunkSingle.cs" />
<Compile Include="Chunks\PngChunkSkipped.cs" />
<Compile Include="Chunks\PngChunkSPLT.cs" />
<Compile Include="Chunks\PngChunkSRGB.cs" />
<Compile Include="Chunks\PngChunkSTER.cs" />
<Compile Include="Chunks\PngChunkTEXT.cs" />
<Compile Include="Chunks\PngChunkTextVar.cs" />
<Compile Include="Chunks\PngChunkTIME.cs" />
<Compile Include="Chunks\PngChunkTRNS.cs" />
<Compile Include="Chunks\PngChunkUNKNOWN.cs" />
<Compile Include="Chunks\PngChunkZTXT.cs" />
<Compile Include="Chunks\PngMetadata.cs" />
<Compile Include="FileHelper.cs" />
<Compile Include="FilterType.cs" />
<Compile Include="FilterWriteStrategy.cs" />
<Compile Include="ImageInfo.cs" />
<Compile Include="ImageLine.cs" />
<Compile Include="ImageLineHelper.cs" />
<Compile Include="ImageLines.cs" />
<Compile Include="PngCsUtils.cs" />
<Compile Include="PngDeinterlacer.cs" />
<Compile Include="PngHelperInternal.cs" />
<Compile Include="PngIDatChunkInputStream.cs" />
<Compile Include="PngIDatChunkOutputStream.cs" />
<Compile Include="PngjBadCrcException.cs" />
<Compile Include="PngjException.cs" />
<Compile Include="PngjExceptionInternal.cs" />
<Compile Include="PngjInputException.cs" />
<Compile Include="PngjOutputException.cs" />
<Compile Include="PngjUnsupportedException.cs" />
<Compile Include="PngReader.cs" />
<Compile Include="PngWriter.cs" />
<Compile Include="ProgressiveOutputStream.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="Zlib\Adler32.cs" />
<Compile Include="Zlib\AZlibInputStream.cs" />
<Compile Include="Zlib\AZlibOutputStream.cs" />
<Compile Include="Zlib\CRC32.cs" />
<Compile Include="Zlib\DeflateCompressLevel.cs" />
<Compile Include="Zlib\EDeflateCompressStrategy.cs" />
<Compile Include="Zlib\ZlibInputStreamIs.cs" />
<Compile Include="Zlib\ZlibOutputStreamIs.cs" />
<Compile Include="Zlib\ZlibStreamFactory.cs" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\ICSharpCode.SharpZipLib\ICSharpCode.SharpZipLib.csproj">
<Project>{99604a24-13d0-4c83-a3aa-9a315339fa47}</Project>
<Name>ICSharpCode.SharpZipLib</Name>
</ProjectReference>
<ProjectReference Include="..\mscorlib\mscorlib.csproj">
<Project>{99604a24-13d0-4c83-a3aa-9a315339fa4c}</Project>
<Name>mscorlib</Name>
</ProjectReference>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project>
+30
View File
@@ -0,0 +1,30 @@
using System;
namespace Hjg.Pngcs
{
// Token: 0x0200003A RID: 58
[Serializable]
public class PngjBadCrcException : PngjException
{
// Token: 0x06000203 RID: 515 RVA: 0x000081DF File Offset: 0x000063DF
public PngjBadCrcException(string message, Exception cause)
: base(message, cause)
{
}
// Token: 0x06000204 RID: 516 RVA: 0x000081E9 File Offset: 0x000063E9
public PngjBadCrcException(string message)
: base(message)
{
}
// Token: 0x06000205 RID: 517 RVA: 0x000081F2 File Offset: 0x000063F2
public PngjBadCrcException(Exception cause)
: base(cause)
{
}
// Token: 0x04000114 RID: 276
private const long serialVersionUID = 1L;
}
}
+30
View File
@@ -0,0 +1,30 @@
using System;
namespace Hjg.Pngcs
{
// Token: 0x02000039 RID: 57
[Serializable]
public class PngjException : Exception
{
// Token: 0x06000200 RID: 512 RVA: 0x000081BD File Offset: 0x000063BD
public PngjException(string message, Exception cause)
: base(message, cause)
{
}
// Token: 0x06000201 RID: 513 RVA: 0x000081C7 File Offset: 0x000063C7
public PngjException(string message)
: base(message)
{
}
// Token: 0x06000202 RID: 514 RVA: 0x000081D0 File Offset: 0x000063D0
public PngjException(Exception cause)
: base(cause.Message, cause)
{
}
// Token: 0x04000113 RID: 275
private const long serialVersionUID = 1L;
}
}
+35
View File
@@ -0,0 +1,35 @@
using System;
namespace Hjg.Pngcs
{
// Token: 0x0200001B RID: 27
[Serializable]
public class PngjExceptionInternal : Exception
{
// Token: 0x060000E6 RID: 230 RVA: 0x00004AC4 File Offset: 0x00002CC4
public PngjExceptionInternal()
{
}
// Token: 0x060000E7 RID: 231 RVA: 0x00004ACC File Offset: 0x00002CCC
public PngjExceptionInternal(string message, Exception cause)
: base(message, cause)
{
}
// Token: 0x060000E8 RID: 232 RVA: 0x00004AD6 File Offset: 0x00002CD6
public PngjExceptionInternal(string message)
: base(message)
{
}
// Token: 0x060000E9 RID: 233 RVA: 0x00004ADF File Offset: 0x00002CDF
public PngjExceptionInternal(Exception cause)
: base(cause.Message, cause)
{
}
// Token: 0x04000087 RID: 135
private const long serialVersionUID = 1L;
}
}
+30
View File
@@ -0,0 +1,30 @@
using System;
namespace Hjg.Pngcs
{
// Token: 0x0200003B RID: 59
[Serializable]
public class PngjInputException : PngjException
{
// Token: 0x06000206 RID: 518 RVA: 0x000081FB File Offset: 0x000063FB
public PngjInputException(string message, Exception cause)
: base(message, cause)
{
}
// Token: 0x06000207 RID: 519 RVA: 0x00008205 File Offset: 0x00006405
public PngjInputException(string message)
: base(message)
{
}
// Token: 0x06000208 RID: 520 RVA: 0x0000820E File Offset: 0x0000640E
public PngjInputException(Exception cause)
: base(cause)
{
}
// Token: 0x04000115 RID: 277
private const long serialVersionUID = 1L;
}
}
+30
View File
@@ -0,0 +1,30 @@
using System;
namespace Hjg.Pngcs
{
// Token: 0x0200003C RID: 60
[Serializable]
public class PngjOutputException : PngjException
{
// Token: 0x06000209 RID: 521 RVA: 0x00008217 File Offset: 0x00006417
public PngjOutputException(string message, Exception cause)
: base(message, cause)
{
}
// Token: 0x0600020A RID: 522 RVA: 0x00008221 File Offset: 0x00006421
public PngjOutputException(string message)
: base(message)
{
}
// Token: 0x0600020B RID: 523 RVA: 0x0000822A File Offset: 0x0000642A
public PngjOutputException(Exception cause)
: base(cause)
{
}
// Token: 0x04000116 RID: 278
private const long serialVersionUID = 1L;
}
}
+35
View File
@@ -0,0 +1,35 @@
using System;
namespace Hjg.Pngcs
{
// Token: 0x0200003D RID: 61
[Serializable]
public class PngjUnsupportedException : Exception
{
// Token: 0x0600020C RID: 524 RVA: 0x00008233 File Offset: 0x00006433
public PngjUnsupportedException()
{
}
// Token: 0x0600020D RID: 525 RVA: 0x0000823B File Offset: 0x0000643B
public PngjUnsupportedException(string message, Exception cause)
: base(message, cause)
{
}
// Token: 0x0600020E RID: 526 RVA: 0x00008245 File Offset: 0x00006445
public PngjUnsupportedException(string message)
: base(message)
{
}
// Token: 0x0600020F RID: 527 RVA: 0x0000824E File Offset: 0x0000644E
public PngjUnsupportedException(Exception cause)
: base(cause.Message, cause)
{
}
// Token: 0x04000117 RID: 279
private const long serialVersionUID = 1L;
}
}
+90
View File
@@ -0,0 +1,90 @@
using System;
using System.IO;
namespace Hjg.Pngcs
{
// Token: 0x02000037 RID: 55
internal abstract class ProgressiveOutputStream : MemoryStream
{
// Token: 0x060001F4 RID: 500 RVA: 0x00008072 File Offset: 0x00006272
public ProgressiveOutputStream(int size_0)
{
this.size = size_0;
if (this.size < 8)
{
throw new PngjException("bad size for ProgressiveOutputStream: " + this.size);
}
}
// Token: 0x060001F5 RID: 501 RVA: 0x000080A5 File Offset: 0x000062A5
public override void Close()
{
this.Flush();
base.Close();
}
// Token: 0x060001F6 RID: 502 RVA: 0x000080B3 File Offset: 0x000062B3
public override void Flush()
{
base.Flush();
this.CheckFlushBuffer(true);
}
// Token: 0x060001F7 RID: 503 RVA: 0x000080C2 File Offset: 0x000062C2
public override void Write(byte[] b, int off, int len)
{
base.Write(b, off, len);
this.CheckFlushBuffer(false);
}
// Token: 0x060001F8 RID: 504 RVA: 0x000080D4 File Offset: 0x000062D4
public void Write(byte[] b)
{
this.Write(b, 0, b.Length);
this.CheckFlushBuffer(false);
}
// Token: 0x060001F9 RID: 505 RVA: 0x000080E8 File Offset: 0x000062E8
private void CheckFlushBuffer(bool forced)
{
int num = (int)this.Position;
byte[] buffer = this.GetBuffer();
while (forced || num >= this.size)
{
int num2 = this.size;
if (num2 > num)
{
num2 = num;
}
if (num2 == 0)
{
return;
}
this.FlushBuffer(buffer, num2);
this.countFlushed += (long)num2;
int num3 = num - num2;
num = num3;
this.Position = (long)num;
if (num3 > 0)
{
Array.Copy(buffer, num2, buffer, 0, num3);
}
}
}
// Token: 0x060001FA RID: 506
protected abstract void FlushBuffer(byte[] b, int n);
// Token: 0x060001FB RID: 507 RVA: 0x00008156 File Offset: 0x00006356
public long GetCountFlushed()
{
return this.countFlushed;
}
// Token: 0x0400010F RID: 271
private readonly int size;
// Token: 0x04000110 RID: 272
private long countFlushed;
}
}
+17
View File
@@ -0,0 +1,17 @@
using System;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
[assembly: AssemblyVersion("1.1.4.1")]
[assembly: Guid("57660689-c667-4a9e-9b21-ef4e21754425")]
[assembly: AssemblyFileVersion("1.1.4.1")]
[assembly: ComVisible(false)]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyTitle("Hjg.Pngcs")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCopyright("Copyright © 2012")]
[assembly: AssemblyDescription("PNGCS: A library for read-write PNG images")]
[assembly: AssemblyCompany("http://hjg.com.ar/")]
[assembly: AssemblyProduct("Hjg.Pngcs")]
+108
View File
@@ -0,0 +1,108 @@
using System;
using System.IO;
namespace Hjg.Pngcs.Zlib
{
// Token: 0x02000043 RID: 67
public abstract class AZlibInputStream : Stream
{
// Token: 0x06000291 RID: 657 RVA: 0x0000A853 File Offset: 0x00008A53
public AZlibInputStream(Stream st, bool leaveOpen)
{
this.rawStream = st;
this.leaveOpen = leaveOpen;
}
// Token: 0x17000042 RID: 66
// (get) Token: 0x06000292 RID: 658 RVA: 0x0000A869 File Offset: 0x00008A69
public override bool CanRead
{
get
{
return true;
}
}
// Token: 0x17000043 RID: 67
// (get) Token: 0x06000293 RID: 659 RVA: 0x0000A86C File Offset: 0x00008A6C
public override bool CanWrite
{
get
{
return false;
}
}
// Token: 0x06000294 RID: 660 RVA: 0x0000A86F File Offset: 0x00008A6F
public override void SetLength(long value)
{
throw new NotImplementedException();
}
// Token: 0x17000044 RID: 68
// (get) Token: 0x06000295 RID: 661 RVA: 0x0000A876 File Offset: 0x00008A76
public override bool CanSeek
{
get
{
return false;
}
}
// Token: 0x06000296 RID: 662 RVA: 0x0000A879 File Offset: 0x00008A79
public override long Seek(long offset, SeekOrigin origin)
{
throw new NotImplementedException();
}
// Token: 0x17000045 RID: 69
// (get) Token: 0x06000297 RID: 663 RVA: 0x0000A880 File Offset: 0x00008A80
// (set) Token: 0x06000298 RID: 664 RVA: 0x0000A887 File Offset: 0x00008A87
public override long Position
{
get
{
throw new NotImplementedException();
}
set
{
throw new NotImplementedException();
}
}
// Token: 0x17000046 RID: 70
// (get) Token: 0x06000299 RID: 665 RVA: 0x0000A88E File Offset: 0x00008A8E
public override long Length
{
get
{
throw new NotImplementedException();
}
}
// Token: 0x0600029A RID: 666 RVA: 0x0000A895 File Offset: 0x00008A95
public override void Write(byte[] buffer, int offset, int count)
{
throw new NotImplementedException();
}
// Token: 0x17000047 RID: 71
// (get) Token: 0x0600029B RID: 667 RVA: 0x0000A89C File Offset: 0x00008A9C
public override bool CanTimeout
{
get
{
return false;
}
}
// Token: 0x0600029C RID: 668
public abstract string getImplementationId();
// Token: 0x04000152 RID: 338
protected readonly Stream rawStream;
// Token: 0x04000153 RID: 339
protected readonly bool leaveOpen;
}
}
+116
View File
@@ -0,0 +1,116 @@
using System;
using System.IO;
namespace Hjg.Pngcs.Zlib
{
// Token: 0x02000041 RID: 65
public abstract class AZlibOutputStream : Stream
{
// Token: 0x0600027E RID: 638 RVA: 0x0000A73B File Offset: 0x0000893B
public AZlibOutputStream(Stream st, int compressLevel, EDeflateCompressStrategy strat, bool leaveOpen)
{
this.rawStream = st;
this.leaveOpen = leaveOpen;
this.strategy = strat;
this.compressLevel = compressLevel;
}
// Token: 0x0600027F RID: 639 RVA: 0x0000A760 File Offset: 0x00008960
public override void SetLength(long value)
{
throw new NotImplementedException();
}
// Token: 0x1700003C RID: 60
// (get) Token: 0x06000280 RID: 640 RVA: 0x0000A767 File Offset: 0x00008967
public override bool CanSeek
{
get
{
return false;
}
}
// Token: 0x06000281 RID: 641 RVA: 0x0000A76A File Offset: 0x0000896A
public override long Seek(long offset, SeekOrigin origin)
{
throw new NotImplementedException();
}
// Token: 0x1700003D RID: 61
// (get) Token: 0x06000282 RID: 642 RVA: 0x0000A771 File Offset: 0x00008971
// (set) Token: 0x06000283 RID: 643 RVA: 0x0000A778 File Offset: 0x00008978
public override long Position
{
get
{
throw new NotImplementedException();
}
set
{
throw new NotImplementedException();
}
}
// Token: 0x1700003E RID: 62
// (get) Token: 0x06000284 RID: 644 RVA: 0x0000A77F File Offset: 0x0000897F
public override long Length
{
get
{
throw new NotImplementedException();
}
}
// Token: 0x06000285 RID: 645 RVA: 0x0000A786 File Offset: 0x00008986
public override int Read(byte[] buffer, int offset, int count)
{
throw new NotImplementedException();
}
// Token: 0x1700003F RID: 63
// (get) Token: 0x06000286 RID: 646 RVA: 0x0000A78D File Offset: 0x0000898D
public override bool CanRead
{
get
{
return false;
}
}
// Token: 0x17000040 RID: 64
// (get) Token: 0x06000287 RID: 647 RVA: 0x0000A790 File Offset: 0x00008990
public override bool CanWrite
{
get
{
return true;
}
}
// Token: 0x17000041 RID: 65
// (get) Token: 0x06000288 RID: 648 RVA: 0x0000A793 File Offset: 0x00008993
public override bool CanTimeout
{
get
{
return false;
}
}
// Token: 0x06000289 RID: 649
public abstract string getImplementationId();
// Token: 0x0400014C RID: 332
protected readonly Stream rawStream;
// Token: 0x0400014D RID: 333
protected readonly bool leaveOpen;
// Token: 0x0400014E RID: 334
protected int compressLevel;
// Token: 0x0400014F RID: 335
protected EDeflateCompressStrategy strategy;
}
}
+84
View File
@@ -0,0 +1,84 @@
using System;
namespace Hjg.Pngcs.Zlib
{
// Token: 0x02000040 RID: 64
public class Adler32
{
// Token: 0x06000277 RID: 631 RVA: 0x0000A600 File Offset: 0x00008800
public void Update(byte data)
{
if (this.pend >= 5550)
{
this.updateModulus();
}
this.a += (uint)data;
this.b += this.a;
this.pend++;
}
// Token: 0x06000278 RID: 632 RVA: 0x0000A64F File Offset: 0x0000884F
public void Update(byte[] data)
{
this.Update(data, 0, data.Length);
}
// Token: 0x06000279 RID: 633 RVA: 0x0000A65C File Offset: 0x0000885C
public void Update(byte[] data, int offset, int length)
{
int num = 5550 - this.pend;
for (int i = 0; i < length; i++)
{
if (i == num)
{
this.updateModulus();
num = i + 5550;
}
this.a += (uint)data[i + offset];
this.b += this.a;
this.pend++;
}
}
// Token: 0x0600027A RID: 634 RVA: 0x0000A6C7 File Offset: 0x000088C7
public void Reset()
{
this.a = 1U;
this.b = 0U;
this.pend = 0;
}
// Token: 0x0600027B RID: 635 RVA: 0x0000A6DE File Offset: 0x000088DE
private void updateModulus()
{
this.a %= 65521U;
this.b %= 65521U;
this.pend = 0;
}
// Token: 0x0600027C RID: 636 RVA: 0x0000A70B File Offset: 0x0000890B
public uint GetValue()
{
if (this.pend > 0)
{
this.updateModulus();
}
return (this.b << 16) | this.a;
}
// Token: 0x04000147 RID: 327
private const int _base = 65521;
// Token: 0x04000148 RID: 328
private const int _nmax = 5550;
// Token: 0x04000149 RID: 329
private uint a = 1U;
// Token: 0x0400014A RID: 330
private uint b;
// Token: 0x0400014B RID: 331
private int pend;
}
}
+102
View File
@@ -0,0 +1,102 @@
using System;
namespace Hjg.Pngcs.Zlib
{
// Token: 0x02000047 RID: 71
public class CRC32
{
// Token: 0x060002A4 RID: 676 RVA: 0x0000A90A File Offset: 0x00008B0A
public CRC32()
: this(3988292384U, uint.MaxValue)
{
}
// Token: 0x060002A5 RID: 677 RVA: 0x0000A918 File Offset: 0x00008B18
public CRC32(uint polynomial, uint seed)
{
this.table = CRC32.InitializeTable(polynomial);
this.seed = seed;
this.hash = seed;
}
// Token: 0x060002A6 RID: 678 RVA: 0x0000A93A File Offset: 0x00008B3A
public void Update(byte[] buffer)
{
this.Update(buffer, 0, buffer.Length);
}
// Token: 0x060002A7 RID: 679 RVA: 0x0000A948 File Offset: 0x00008B48
public void Update(byte[] buffer, int start, int length)
{
int i = 0;
int num = start;
while (i < length)
{
this.hash = (this.hash >> 8) ^ this.table[(int)((UIntPtr)((uint)buffer[num] ^ (this.hash & 255U)))];
i++;
num++;
}
}
// Token: 0x060002A8 RID: 680 RVA: 0x0000A98E File Offset: 0x00008B8E
public uint GetValue()
{
return ~this.hash;
}
// Token: 0x060002A9 RID: 681 RVA: 0x0000A997 File Offset: 0x00008B97
public void Reset()
{
this.hash = this.seed;
}
// Token: 0x060002AA RID: 682 RVA: 0x0000A9A8 File Offset: 0x00008BA8
private static uint[] InitializeTable(uint polynomial)
{
if (polynomial == 3988292384U && CRC32.defaultTable != null)
{
return CRC32.defaultTable;
}
uint[] array = new uint[256];
for (int i = 0; i < 256; i++)
{
uint num = (uint)i;
for (int j = 0; j < 8; j++)
{
if ((num & 1U) == 1U)
{
num = (num >> 1) ^ polynomial;
}
else
{
num >>= 1;
}
}
array[i] = num;
}
if (polynomial == 3988292384U)
{
CRC32.defaultTable = array;
}
return array;
}
// Token: 0x0400015D RID: 349
private const uint defaultPolynomial = 3988292384U;
// Token: 0x0400015E RID: 350
private const uint defaultSeed = 4294967295U;
// Token: 0x0400015F RID: 351
private static uint[] defaultTable;
// Token: 0x04000160 RID: 352
private uint hash;
// Token: 0x04000161 RID: 353
private uint seed;
// Token: 0x04000162 RID: 354
private uint[] table;
}
}
+20
View File
@@ -0,0 +1,20 @@
using System;
namespace Hjg.Pngcs.Zlib
{
// Token: 0x02000045 RID: 69
public class DeflateCompressLevel
{
// Token: 0x04000155 RID: 341
public const int NO_COMPRESSION = 0;
// Token: 0x04000156 RID: 342
public const int FASTEST = 3;
// Token: 0x04000157 RID: 343
public const int DEFAULT = 6;
// Token: 0x04000158 RID: 344
public const int OPTIMAL = 9;
}
}
+15
View File
@@ -0,0 +1,15 @@
using System;
namespace Hjg.Pngcs.Zlib
{
// Token: 0x02000046 RID: 70
public enum EDeflateCompressStrategy
{
// Token: 0x0400015A RID: 346
Filtered,
// Token: 0x0400015B RID: 347
Huffman,
// Token: 0x0400015C RID: 348
Default
}
}
+51
View File
@@ -0,0 +1,51 @@
using System;
using System.IO;
using ICSharpCode.SharpZipLib.Zip.Compression.Streams;
namespace Hjg.Pngcs.Zlib
{
// Token: 0x02000044 RID: 68
internal class ZlibInputStreamIs : AZlibInputStream
{
// Token: 0x0600029D RID: 669 RVA: 0x0000A89F File Offset: 0x00008A9F
public ZlibInputStreamIs(Stream st, bool leaveOpen)
: base(st, leaveOpen)
{
this.ist = new InflaterInputStream(st);
this.ist.IsStreamOwner = !leaveOpen;
}
// Token: 0x0600029E RID: 670 RVA: 0x0000A8C4 File Offset: 0x00008AC4
public override int Read(byte[] array, int offset, int count)
{
return this.ist.Read(array, offset, count);
}
// Token: 0x0600029F RID: 671 RVA: 0x0000A8D4 File Offset: 0x00008AD4
public override int ReadByte()
{
return this.ist.ReadByte();
}
// Token: 0x060002A0 RID: 672 RVA: 0x0000A8E1 File Offset: 0x00008AE1
public override void Close()
{
this.ist.Close();
}
// Token: 0x060002A1 RID: 673 RVA: 0x0000A8EE File Offset: 0x00008AEE
public override void Flush()
{
this.ist.Flush();
}
// Token: 0x060002A2 RID: 674 RVA: 0x0000A8FB File Offset: 0x00008AFB
public override string getImplementationId()
{
return "Zlib inflater: SharpZipLib";
}
// Token: 0x04000154 RID: 340
private InflaterInputStream ist;
}
}
+73
View File
@@ -0,0 +1,73 @@
using System;
using System.IO;
using ICSharpCode.SharpZipLib.Zip.Compression;
using ICSharpCode.SharpZipLib.Zip.Compression.Streams;
namespace Hjg.Pngcs.Zlib
{
// Token: 0x02000042 RID: 66
internal class ZlibOutputStreamIs : AZlibOutputStream
{
// Token: 0x0600028A RID: 650 RVA: 0x0000A798 File Offset: 0x00008998
public ZlibOutputStreamIs(Stream st, int compressLevel, EDeflateCompressStrategy strat, bool leaveOpen)
: base(st, compressLevel, strat, leaveOpen)
{
this.deflater = new Deflater(compressLevel);
this.setStrat(strat);
this.ost = new DeflaterOutputStream(st, this.deflater);
this.ost.IsStreamOwner = !leaveOpen;
}
// Token: 0x0600028B RID: 651 RVA: 0x0000A7E5 File Offset: 0x000089E5
public void setStrat(EDeflateCompressStrategy strat)
{
if (strat == EDeflateCompressStrategy.Filtered)
{
this.deflater.SetStrategy(DeflateStrategy.Filtered);
return;
}
if (strat == EDeflateCompressStrategy.Huffman)
{
this.deflater.SetStrategy(DeflateStrategy.HuffmanOnly);
return;
}
this.deflater.SetStrategy(DeflateStrategy.Default);
}
// Token: 0x0600028C RID: 652 RVA: 0x0000A814 File Offset: 0x00008A14
public override void Write(byte[] buffer, int offset, int count)
{
this.ost.Write(buffer, offset, count);
}
// Token: 0x0600028D RID: 653 RVA: 0x0000A824 File Offset: 0x00008A24
public override void WriteByte(byte value)
{
this.ost.WriteByte(value);
}
// Token: 0x0600028E RID: 654 RVA: 0x0000A832 File Offset: 0x00008A32
public override void Close()
{
this.ost.Close();
}
// Token: 0x0600028F RID: 655 RVA: 0x0000A83F File Offset: 0x00008A3F
public override void Flush()
{
this.ost.Flush();
}
// Token: 0x06000290 RID: 656 RVA: 0x0000A84C File Offset: 0x00008A4C
public override string getImplementationId()
{
return "Zlib deflater: SharpZipLib";
}
// Token: 0x04000150 RID: 336
private DeflaterOutputStream ost;
// Token: 0x04000151 RID: 337
private Deflater deflater;
}
}
+39
View File
@@ -0,0 +1,39 @@
using System;
using System.IO;
namespace Hjg.Pngcs.Zlib
{
// Token: 0x02000048 RID: 72
public class ZlibStreamFactory
{
// Token: 0x060002AB RID: 683 RVA: 0x0000AA18 File Offset: 0x00008C18
public static AZlibInputStream createZlibInputStream(Stream st, bool leaveOpen)
{
return new ZlibInputStreamIs(st, leaveOpen);
}
// Token: 0x060002AC RID: 684 RVA: 0x0000AA21 File Offset: 0x00008C21
public static AZlibInputStream createZlibInputStream(Stream st)
{
return ZlibStreamFactory.createZlibInputStream(st, false);
}
// Token: 0x060002AD RID: 685 RVA: 0x0000AA2A File Offset: 0x00008C2A
public static AZlibOutputStream createZlibOutputStream(Stream st, int compressLevel, EDeflateCompressStrategy strat, bool leaveOpen)
{
return new ZlibOutputStreamIs(st, compressLevel, strat, leaveOpen);
}
// Token: 0x060002AE RID: 686 RVA: 0x0000AA35 File Offset: 0x00008C35
public static AZlibOutputStream createZlibOutputStream(Stream st)
{
return ZlibStreamFactory.createZlibOutputStream(st, false);
}
// Token: 0x060002AF RID: 687 RVA: 0x0000AA3E File Offset: 0x00008C3E
public static AZlibOutputStream createZlibOutputStream(Stream st, bool leaveOpen)
{
return ZlibStreamFactory.createZlibOutputStream(st, 6, EDeflateCompressStrategy.Default, leaveOpen);
}
}
}