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