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; } }