142 lines
3.9 KiB
C#
142 lines
3.9 KiB
C#
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;
|
|
}
|
|
}
|