Files
2026-06-04 11:42:34 +02:00

154 lines
4.0 KiB
C#

using System;
namespace Hjg.Pngcs.Chunks
{
// Token: 0x02000023 RID: 35
public class PngChunkBKGD : PngChunkSingle
{
// Token: 0x0600013B RID: 315 RVA: 0x00005F9F File Offset: 0x0000419F
public PngChunkBKGD(ImageInfo info)
: base("bKGD", info)
{
}
// Token: 0x0600013C RID: 316 RVA: 0x00005FAD File Offset: 0x000041AD
public override PngChunk.ChunkOrderingConstraint GetOrderingConstraint()
{
return PngChunk.ChunkOrderingConstraint.AFTER_PLTE_BEFORE_IDAT;
}
// Token: 0x0600013D RID: 317 RVA: 0x00005FB0 File Offset: 0x000041B0
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(1, true);
chunkRaw.Data[0] = (byte)this.paletteIndex;
}
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: 0x0600013E RID: 318 RVA: 0x00006050 File Offset: 0x00004250
public override void ParseFromRaw(ChunkRaw c)
{
if (this.ImgInfo.Greyscale)
{
this.gray = PngHelperInternal.ReadInt2fromBytes(c.Data, 0);
return;
}
if (this.ImgInfo.Indexed)
{
this.paletteIndex = (int)(c.Data[0] & 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: 0x0600013F RID: 319 RVA: 0x000060D8 File Offset: 0x000042D8
public override void CloneDataFromRead(PngChunk other)
{
PngChunkBKGD pngChunkBKGD = (PngChunkBKGD)other;
this.gray = pngChunkBKGD.gray;
this.red = pngChunkBKGD.red;
this.green = pngChunkBKGD.red;
this.blue = pngChunkBKGD.red;
this.paletteIndex = pngChunkBKGD.paletteIndex;
}
// Token: 0x06000140 RID: 320 RVA: 0x00006128 File Offset: 0x00004328
public void SetGray(int gray)
{
if (!this.ImgInfo.Greyscale)
{
throw new PngjException("only gray images support this");
}
this.gray = gray;
}
// Token: 0x06000141 RID: 321 RVA: 0x00006149 File Offset: 0x00004349
public int GetGray()
{
if (!this.ImgInfo.Greyscale)
{
throw new PngjException("only gray images support this");
}
return this.gray;
}
// Token: 0x06000142 RID: 322 RVA: 0x00006169 File Offset: 0x00004369
public void SetPaletteIndex(int index)
{
if (!this.ImgInfo.Indexed)
{
throw new PngjException("only indexed (pallete) images support this");
}
this.paletteIndex = index;
}
// Token: 0x06000143 RID: 323 RVA: 0x0000618A File Offset: 0x0000438A
public int GetPaletteIndex()
{
if (!this.ImgInfo.Indexed)
{
throw new PngjException("only indexed (pallete) images support this");
}
return this.paletteIndex;
}
// Token: 0x06000144 RID: 324 RVA: 0x000061AA File Offset: 0x000043AA
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: 0x06000145 RID: 325 RVA: 0x000061E8 File Offset: 0x000043E8
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: 0x040000AE RID: 174
public const string ID = "bKGD";
// Token: 0x040000AF RID: 175
private int gray;
// Token: 0x040000B0 RID: 176
private int red;
// Token: 0x040000B1 RID: 177
private int green;
// Token: 0x040000B2 RID: 178
private int blue;
// Token: 0x040000B3 RID: 179
private int paletteIndex;
}
}