private static Color[] m0002c3(byte[] p0, struct01c7 p1, struct01de p2) { int num3; int num4; int num5; int num6; int num7; int num8; byte num9; int num10; int num12; int num13; int num14; int num = (int) (p1.f00001b * p1.f00005f); int index = 0; if (num > f000051.Length) { f000051 = new Color[num]; } MemoryStream stream = new MemoryStream(p0); switch (p1.f00001d) { case 0: if (p1.f000008 >= 8) { if (p1.f000008 != 8) { while (((num3 = stream.ReadByte()) > -1) && (index < num)) { num8 = 0; while (num8 < p1.f00001b) { num9 = (byte) stream.ReadByte(); stream.ReadByte(); f000051[index] = new Color(num9, num9, num9); index++; num8++; } } break; } while (((num3 = stream.ReadByte()) > -1) && (index < num)) { for (num8 = 0; num8 < p1.f00001b; num8++) { float num15 = stream.ReadByte(); num9 = (byte) ((num15 / ((float) ((((int) 1) << p1.f000008) - 1))) * 255f); f000051[index] = new Color(num9, num9, num9); index++; } } break; } num12 = 8 / p1.f000008; num13 = ((int) 0xff) >> (8 - p1.f000008); while (((num3 = stream.ReadByte()) > -1) && (index < num)) { num8 = 0; while (num8 < (((ulong) p1.f00001b) / ((long) num12))) { num10 = stream.ReadByte(); num14 = 8 - p1.f000008; while (num14 >= 0) { float num11 = (num10 & (num13 << (num14 & 0x1f))) >> num14; num9 = (byte) ((num11 / ((float) ((((int) 1) << p1.f000008) - 1))) * 255f); f000051[index] = new Color(num9, num9, num9); index++; num14 -= p1.f000008; } num8++; } } break; case 2: if (p1.f000008 <= 8) { while (((num3 = stream.ReadByte()) > -1) && (index < num)) { num8 = 0; while (num8 < p1.f00001b) { f000051[index] = new Color((byte) stream.ReadByte(), (byte) stream.ReadByte(), (byte) stream.ReadByte()); index++; num8++; } } break; } num4 = ((int) ((p1.f00001b * p1.f000008) * 3)) + 1; num5 = 0; num6 = 0; num7 = 0; while (((num3 = stream.ReadByte()) > -1) && (index < num)) { num8 = 0; while (num8 < p1.f00001b) { num5 = stream.ReadByte(); stream.ReadByte(); num6 = stream.ReadByte(); stream.ReadByte(); num7 = stream.ReadByte(); stream.ReadByte(); f000051[index] = new Color((byte) num5, (byte) num6, (byte) num7); index++; num8++; } } break; case 3: num12 = 8 / p1.f000008; num13 = ((int) 0xff) >> (8 - p1.f000008); while (((num3 = stream.ReadByte()) > -1) && (index < num)) { num8 = 0; while (num8 < (((ulong) p1.f00001b) / ((long) num12))) { num10 = stream.ReadByte(); for (num14 = 8 - p1.f000008; num14 >= 0; num14 -= p1.f000008) { int num16 = (num10 & (num13 << (num14 & 0x1f))) >> num14; struct01df structdf = p2.f000018[num16]; f000051[index] = new Color(structdf.f000008, structdf.f00001d, structdf.f000025); if (f000010 >= num16) { f000051[index].A = f00001d[num16]; } index++; } num8++; } } break; case 4: switch (p1.f000008) { case 8: while (((num3 = stream.ReadByte()) > -1) && (index < num)) { num8 = 0; while (num8 < p1.f00001b) { num9 = (byte) stream.ReadByte(); f000051[index] = new Color(num9, num9, num9, (byte) stream.ReadByte()); index++; num8++; } } break; case 0x10: while (((num3 = stream.ReadByte()) > -1) && (index < num)) { num8 = 0; while (num8 < p1.f00001b) { num9 = (byte) stream.ReadByte(); stream.ReadByte(); f000051[index] = new Color(num9, num9, num9, (byte) stream.ReadByte()); stream.ReadByte(); index++; num8++; } } break; } break; case 6: switch (p1.f000008) { case 8: while (((num3 = stream.ReadByte()) > -1) && (index < num)) { num8 = 0; while (num8 < p1.f00001b) { f000051[index] = new Color((byte) stream.ReadByte(), (byte) stream.ReadByte(), (byte) stream.ReadByte(), (byte) stream.ReadByte()); index++; num8++; } } break; case 0x10: { num4 = ((int) ((p1.f00001b * p1.f000008) * 3)) + 1; num5 = 0; num6 = 0; num7 = 0; int num17 = 0; while (((num3 = stream.ReadByte()) > -1) && (index < num)) { for (num8 = 0; num8 < p1.f00001b; num8++) { num5 = stream.ReadByte(); stream.ReadByte(); num6 = stream.ReadByte(); stream.ReadByte(); num7 = stream.ReadByte(); stream.ReadByte(); num17 = stream.ReadByte(); stream.ReadByte(); f000051[index] = new Color((byte) num5, (byte) num6, (byte) num7, (byte) num17); index++; } } break; } } break; } stream.Close(); return f000051; }
private static byte[] m0002b9(byte[] p0, struct01c7 p1) { float num; uint num2; uint num3; int num4; if (p1.f0001f6 == 0) { num = m0002b2(p1); num2 = (uint) Math.Ceiling((double) (num * p1.f00001b)); num3 = 0; for (num4 = 0; num4 < p1.f00005f; num4++) { switch (p0[(int) ((IntPtr) (num4 * (num2 + 1)))]) { case 1: m0002b4(ref p0, num3 + 1, num2, num, p1.f000008); break; case 2: m0002b5(ref p0, num3 + 1, num2, num, p1.f000008); break; case 3: m0002b6(ref p0, num3 + 1, num2, num, p1.f000008); break; case 4: m0002b7(ref p0, num3 + 1, num2, num, p1.f000008); break; } num3 += num2 + 1; } return p0; } num = m0002b2(p1); byte[] buffer = new byte[((int) ((p1.f00001b * p1.f00005f) * num)) + p1.f00005f]; byte[][] bufferArray = new byte[7][]; uint num5 = 0; uint num6 = 0; int num7 = 0; int num8 = 0; int num9 = 0; int num10 = 0; for (num4 = 0; num4 < 7; num4++) { int num11; int num12; int num13; float num14; switch (num4) { case 0: num7 = 0; num8 = 0; num9 = 8; num10 = 8; num5 = (uint) Math.Ceiling((double) (((double) p1.f00001b) / 8.0)); num6 = (uint) Math.Ceiling((double) (((double) p1.f00005f) / 8.0)); bufferArray[num4] = new byte[(((int) Math.Ceiling((double) (num5 * num))) * num6) + num6]; break; case 1: num7 = 4; num8 = 0; num9 = 8; num10 = 8; num5 = (uint) Math.Ceiling((double) ((p1.f00001b - 4.0) / 8.0)); num6 = (uint) Math.Ceiling((double) (((double) p1.f00005f) / 8.0)); bufferArray[num4] = new byte[(((int) Math.Ceiling((double) (num5 * num))) * num6) + num6]; break; case 2: num7 = 0; num8 = 4; num9 = 4; num10 = 8; num5 = (uint) Math.Ceiling((double) (((double) p1.f00001b) / 4.0)); num6 = (uint) Math.Ceiling((double) ((p1.f00005f - 4.0) / 8.0)); bufferArray[num4] = new byte[(((int) Math.Ceiling((double) (num5 * num))) * num6) + num6]; break; case 3: num7 = 2; num8 = 0; num9 = 4; num10 = 4; num5 = (uint) Math.Ceiling((double) ((p1.f00001b - 2.0) / 4.0)); num6 = (uint) Math.Ceiling((double) (((double) p1.f00005f) / 4.0)); bufferArray[num4] = new byte[(((int) Math.Ceiling((double) (num5 * num))) * num6) + num6]; break; case 4: num7 = 0; num8 = 2; num9 = 2; num10 = 4; num5 = (uint) Math.Ceiling((double) (((double) p1.f00001b) / 2.0)); num6 = (uint) Math.Ceiling((double) ((p1.f00005f - 2.0) / 4.0)); bufferArray[num4] = new byte[(((int) Math.Ceiling((double) (num5 * num))) * num6) + num6]; break; case 5: num7 = 1; num8 = 0; num9 = 2; num10 = 2; num5 = (uint) Math.Ceiling((double) ((p1.f00001b - 1.0) / 2.0)); num6 = (uint) Math.Ceiling((double) (((double) p1.f00005f) / 2.0)); bufferArray[num4] = new byte[(((int) Math.Ceiling((double) (num5 * num))) * num6) + num6]; break; case 6: num7 = 0; num8 = 1; num9 = 1; num10 = 2; num5 = p1.f00001b; num6 = (uint) Math.Ceiling((double) ((p1.f00005f - 1.0) / 2.0)); bufferArray[num4] = new byte[(((int) Math.Ceiling((double) (num5 * num))) * num6) + num6]; break; } if (num4 == 0) { num3 = 0; } else { num3 = 0; num11 = num4 - 1; while (num11 >= 0) { num3 += (uint) bufferArray[num11].Length; num11--; } } num2 = (uint) Math.Ceiling((double) (num * num5)); Array.Copy(p0, (int) num3, bufferArray[num4], 0, bufferArray[num4].Length); num3 = 0; for (num11 = 0; num11 < num6; num11++) { switch (bufferArray[num4][(int) ((IntPtr) (num11 * (num2 + 1)))]) { case 0: break; case 1: m0002b4(ref bufferArray[num4], num3 + 1, num2, num, p1.f000008); break; case 2: m0002b5(ref bufferArray[num4], num3 + 1, num2, num, p1.f000008); break; case 3: m0002b6(ref bufferArray[num4], num3 + 1, num2, num, p1.f000008); break; case 4: m0002b7(ref bufferArray[num4], num3 + 1, num2, num, p1.f000008); break; default: throw new Exception("WRONG!"); } num3 += num2 + 1; } if (num >= 1f) { num14 = 0f; while (num14 < bufferArray[num4].Length) { if ((num14 % ((float) (num2 + 1))) == 0f) { num14++; } num13 = num8 + ((int) (num10 * Math.Floor((double) (num14 / ((float) (num2 + 1)))))); num12 = num7 + ((int) ((num9 * ((num14 % ((float) (num2 + 1))) - 1f)) / num)); num3 = (uint) (((num13 * ((num * p1.f00001b) + 1f)) + (num12 * num)) + 1f); for (int i = 0; i < num; i++) { buffer[(int) ((IntPtr) (num3 + i))] = bufferArray[num4][((int) num14) + i]; } num14 += num; } } else { int num16 = (int) (8.0 / ((double) p1.f000008)); for (int j = 0; j < bufferArray[num4].Length; j++) { if ((((long) j) % ((ulong) (num2 + 1))) == 0L) { j++; } num13 = num8 + ((int) (num10 * Math.Floor((double) (((float) j) / ((float) (num2 + 1)))))); num12 = num7 + ((int) (num9 * (((((long) j) % ((ulong) (num2 + 1))) - ((ulong) 1L)) * num16))); for (num14 = 0f; num14 < 8f; num14 += p1.f000008) { int num22 = num12 + ((int) (num9 * (num14 / ((float) p1.f000008)))); if (num22 >= p1.f00001b) { break; } num3 = (uint) ((Math.Ceiling((double) (num * p1.f00001b)) + 1.0) * num13); num3 = (uint) ((num3 + (num22 / num16)) + ((ulong) 1L)); int num17 = (num22 % num16) * p1.f000008; int num19 = (8 - p1.f000008) - num17; int num20 = (8 - p1.f000008) - ((int) num14); byte num18 = m0002ba(bufferArray[num4][j], num20, p1.f000008); buffer[num3] = (byte) (buffer[num3] | ((byte) (num18 << num19))); } } } } return buffer; }
private static byte[] m0002c0(List<struct01c6> p0, struct01c7 p1, ref struct01de p2) { int num = 0; using (List<struct01c6>.Enumerator enumerator = p0.GetEnumerator()) { Label_000B: if (!enumerator.MoveNext()) { goto Label_01D6; } struct01c6 current = enumerator.Current; enum01c5 enumc = current.f000001; if (enumc <= enum01c5.f000085) { if (enumc != enum01c5.f000001) { if (enumc == enum01c5.f000045) { goto Label_011A; } if (enumc == enum01c5.f000085) { goto Label_012C; } } goto Label_000B; } if (enumc != enum01c5.f000043) { if (enumc == enum01c5.f000044) { goto Label_00AF; } if (enumc == enum01c5.f000086) { goto Label_017C; } goto Label_000B; } throw new Exception(string.Format("List<Chunk> chunks still contains IHDR chunk info.", new object[0])); Label_00AF: if ((p1.f00001d == 0) || (p1.f00001d == 4)) { throw new Exception(string.Format("The given ColorType, {0}, does not support the use of a Palette.", p1.f00001d)); } p2.f000018 = new struct01df[(((int) 1) << (p1.f000008 + 1)) - 1]; m0002bf(current, ref p2); goto Label_000B; Label_011A: m0002c2(current, ref f000025, ref num); goto Label_000B; Label_012C: if (p0.IndexOf(current) != (p0.Count - 1)) { throw new Exception(string.Format("IEND chunk does not appear to be the last chunk in the image.", new object[0])); } MemoryStream stream = new MemoryStream(f000025, 0, num); c0000cf ccf = new c0000cf(stream); m000140(ref ccf); goto Label_000B; Label_017C: f000010 = ((int) current.f00001b) - 1; for (int i = 0; i < current.f00001b; i++) { f00001d[i] = (byte) current.f0001f4.ReadByte(); } goto Label_000B; } Label_01D6: return f000008; }
private static float m0002b2(struct01c7 p0) { switch (p0.f00001d) { case 0: return (((float) p0.f000008) / 8f); case 2: return ((3f * p0.f000008) / 8f); case 3: return (((float) p0.f000008) / 8f); case 4: return ((2f * p0.f000008) / 8f); case 6: return (4f * (((float) p0.f000008) / 8f)); } return -1f; }