scripts
This commit is contained in:
@@ -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
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user