Files
Dec2017-Script-Dump/Pngcs/ImageInfo.cs
T
2026-06-04 11:42:34 +02:00

161 lines
4.4 KiB
C#

using System;
namespace Hjg.Pngcs
{
// Token: 0x0200001F RID: 31
public class ImageInfo
{
// Token: 0x060000F9 RID: 249 RVA: 0x00004E98 File Offset: 0x00003098
public ImageInfo(int cols, int rows, int bitdepth, bool alpha)
: this(cols, rows, bitdepth, alpha, false, false)
{
}
// Token: 0x060000FA RID: 250 RVA: 0x00004EA8 File Offset: 0x000030A8
public ImageInfo(int cols, int rows, int bitdepth, bool alpha, bool grayscale, bool palette)
{
this.Cols = cols;
this.Rows = rows;
this.Alpha = alpha;
this.Indexed = palette;
this.Greyscale = grayscale;
if (this.Greyscale && palette)
{
throw new PngjException("palette and greyscale are exclusive");
}
this.Channels = ((grayscale || palette) ? (alpha ? 2 : 1) : (alpha ? 4 : 3));
this.BitDepth = bitdepth;
this.Packed = bitdepth < 8;
this.BitspPixel = this.Channels * this.BitDepth;
this.BytesPixel = (this.BitspPixel + 7) / 8;
this.BytesPerRow = (this.BitspPixel * cols + 7) / 8;
this.SamplesPerRow = this.Channels * this.Cols;
this.SamplesPerRowPacked = (this.Packed ? this.BytesPerRow : this.SamplesPerRow);
int bitDepth = this.BitDepth;
switch (bitDepth)
{
case 1:
case 2:
case 4:
if (!this.Indexed && !this.Greyscale)
{
throw new PngjException("only indexed or grayscale can have bitdepth=" + this.BitDepth);
}
goto IL_16B;
case 3:
break;
default:
if (bitDepth == 8)
{
goto IL_16B;
}
if (bitDepth == 16)
{
if (this.Indexed)
{
throw new PngjException("indexed can't have bitdepth=" + this.BitDepth);
}
goto IL_16B;
}
break;
}
throw new PngjException("invalid bitdepth=" + this.BitDepth);
IL_16B:
if (cols < 1 || cols > 400000)
{
throw new PngjException("invalid cols=" + cols + " ???");
}
if (rows < 1 || rows > 400000)
{
throw new PngjException("invalid rows=" + rows + " ???");
}
}
// Token: 0x060000FB RID: 251 RVA: 0x00005070 File Offset: 0x00003270
public override string ToString()
{
return string.Concat(new object[]
{
"ImageInfo [cols=", this.Cols, ", rows=", this.Rows, ", bitDepth=", this.BitDepth, ", channels=", this.Channels, ", bitspPixel=", this.BitspPixel,
", bytesPixel=", this.BytesPixel, ", bytesPerRow=", this.BytesPerRow, ", samplesPerRow=", this.SamplesPerRow, ", samplesPerRowP=", this.SamplesPerRowPacked, ", alpha=", this.Alpha,
", greyscale=", this.Greyscale, ", indexed=", this.Indexed, ", packed=", this.Packed, "]"
});
}
// Token: 0x060000FC RID: 252 RVA: 0x000051C4 File Offset: 0x000033C4
public override int GetHashCode()
{
int num = 31;
int num2 = 1;
num2 = num * num2 + (this.Alpha ? 1231 : 1237);
num2 = num * num2 + this.BitDepth;
num2 = num * num2 + this.Channels;
num2 = num * num2 + this.Cols;
num2 = num * num2 + (this.Greyscale ? 1231 : 1237);
num2 = num * num2 + (this.Indexed ? 1231 : 1237);
return num * num2 + this.Rows;
}
// Token: 0x060000FD RID: 253 RVA: 0x00005250 File Offset: 0x00003450
public override bool Equals(object obj)
{
if (this == obj)
{
return true;
}
if (obj == null)
{
return false;
}
if (base.GetType() != obj.GetType())
{
return false;
}
ImageInfo imageInfo = (ImageInfo)obj;
return this.Alpha == imageInfo.Alpha && this.BitDepth == imageInfo.BitDepth && this.Channels == imageInfo.Channels && this.Cols == imageInfo.Cols && this.Greyscale == imageInfo.Greyscale && this.Indexed == imageInfo.Indexed && this.Rows == imageInfo.Rows;
}
// Token: 0x04000092 RID: 146
private const int MAX_COLS_ROWS_VAL = 400000;
// Token: 0x04000093 RID: 147
public readonly int Cols;
// Token: 0x04000094 RID: 148
public readonly int Rows;
// Token: 0x04000095 RID: 149
public readonly int BitDepth;
// Token: 0x04000096 RID: 150
public readonly int Channels;
// Token: 0x04000097 RID: 151
public readonly int BitspPixel;
// Token: 0x04000098 RID: 152
public readonly int BytesPixel;
// Token: 0x04000099 RID: 153
public readonly int BytesPerRow;
// Token: 0x0400009A RID: 154
public readonly int SamplesPerRow;
// Token: 0x0400009B RID: 155
public readonly int SamplesPerRowPacked;
// Token: 0x0400009C RID: 156
public readonly bool Alpha;
// Token: 0x0400009D RID: 157
public readonly bool Greyscale;
// Token: 0x0400009E RID: 158
public readonly bool Indexed;
// Token: 0x0400009F RID: 159
public readonly bool Packed;
}
}