protected override void FlushBuffer(byte[] b, int len) { var c = new Chunks.ChunkRaw(len, Chunks.ChunkHelper.b_IDAT, false); c.Data = b; c.WriteChunk(outputStream); }
public override void ParseFromRaw(ChunkRaw chunk) { if (chunk.Len != 9) { throw new PngjException("bad chunk length " + chunk); } posX = PngHelperInternal.ReadInt4fromBytes(chunk.Data, 0); if (posX < 0) { posX += 0x100000000L; } posY = PngHelperInternal.ReadInt4fromBytes(chunk.Data, 4); if (posY < 0) { posY += 0x100000000L; } units = PngHelperInternal.ReadInt1fromByte(chunk.Data, 8); }
public override ChunkRaw CreateRawChunk() { ChunkRaw chunk = new ChunkRaw(13, ChunkHelper.b_IHDR, true); byte[] data = chunk.Data; int offset = 0; PngHelperInternal.WriteInt4tobytes(Cols, data, offset); offset += 4; PngHelperInternal.WriteInt4tobytes(Rows, data, offset); offset += 4; data[offset++] = (byte)Bitspc; data[offset++] = (byte)Colormodel; data[offset++] = (byte)Compmeth; data[offset++] = (byte)Filmeth; data[offset++] = (byte)Interlaced; return(chunk); }
public override void ParseFromRaw(ChunkRaw chunk) { if (chunk.Len != 9) { throw new PngjException("bad chunk length " + chunk); } PixelsxUnitX = Pngcs.PngHelperInternal.ReadInt4fromBytes(chunk.Data, 0); if (PixelsxUnitX < 0) { PixelsxUnitX += 0x100000000L; } PixelsxUnitY = Pngcs.PngHelperInternal.ReadInt4fromBytes(chunk.Data, 4); if (PixelsxUnitY < 0) { PixelsxUnitY += 0x100000000L; } Units = Pngcs.PngHelperInternal.ReadInt1fromByte(chunk.Data, 8); }
public override void ParseFromRaw(ChunkRaw chunk) { byte[] data = chunk.Data; if (ImgInfo.Greyscale) { gray = PngHelperInternal.ReadInt2fromBytes(data, 0); } else if (ImgInfo.Indexed) { paletteIndex = (int)(data[0] & 0xff); } else { red = PngHelperInternal.ReadInt2fromBytes(data, 0); green = PngHelperInternal.ReadInt2fromBytes(data, 2); blue = PngHelperInternal.ReadInt2fromBytes(data, 4); } }
public override ChunkRaw CreateRawChunk() { if (key.Length == 0) { throw new PngjException("Text chunk key must be non empty"); } MemoryStream ba = new MemoryStream(); ChunkHelper.WriteBytesToStream(ba, ChunkHelper.ToBytes(key)); ba.WriteByte(0); // separator ba.WriteByte(0); // compression method: 0 byte[] textbytes = ChunkHelper.compressBytes(ChunkHelper.ToBytes(val), true); ChunkHelper.WriteBytesToStream(ba, textbytes); byte[] b = ba.ToArray(); ChunkRaw chunk = createEmptyChunk(b.Length, false); chunk.Data = b; return(chunk); }
public override void ParseFromRaw(ChunkRaw c) { if (ImgInfo.Greyscale) { gray = Pngcs.PngHelperInternal.ReadInt2fromBytes(c.Data, 0); } else if (ImgInfo.Indexed) { int nentries = c.Data.Length; paletteAlpha = new int[nentries]; for (int n = 0; n < nentries; n++) { paletteAlpha[n] = (int)(c.Data[n] & 0xff); } } else { red = Pngcs.PngHelperInternal.ReadInt2fromBytes(c.Data, 0); green = Pngcs.PngHelperInternal.ReadInt2fromBytes(c.Data, 2); blue = Pngcs.PngHelperInternal.ReadInt2fromBytes(c.Data, 4); } }
public override ChunkRaw CreateRawChunk() { ChunkRaw c = null; if (ImgInfo.Greyscale) { c = createEmptyChunk(2, true); Pngcs.PngHelperInternal.WriteInt2tobytes(gray, c.Data, 0); } else if (ImgInfo.Indexed) { c = createEmptyChunk(1, true); c.Data[0] = (byte)paletteIndex; } else { c = createEmptyChunk(6, true); PngHelperInternal.WriteInt2tobytes(red, c.Data, 0); Pngcs.PngHelperInternal.WriteInt2tobytes(green, c.Data, 0); Pngcs.PngHelperInternal.WriteInt2tobytes(blue, c.Data, 0); } return(c); }
public override ChunkRaw CreateRawChunk() { ChunkRaw chunk = null; byte[] data = chunk.Data; if (ImgInfo.Greyscale) { chunk = CreateEmptyChunk(2, true); PngHelperInternal.WriteInt2tobytes(gray, data, 0); } else if (ImgInfo.Indexed) { chunk = CreateEmptyChunk(1, true); data[0] = (byte)paletteIndex; } else { chunk = CreateEmptyChunk(6, true); PngHelperInternal.WriteInt2tobytes(red, data, 0); PngHelperInternal.WriteInt2tobytes(green, data, 0); PngHelperInternal.WriteInt2tobytes(blue, data, 0); } return(chunk); }
public override void ParseFromRaw(ChunkRaw c) { data = c.Data; }
public override void ParseFromRaw(ChunkRaw c) { // this is not used }
public override ChunkRaw CreateRawChunk() { ChunkRaw c = new ChunkRaw(0, ChunkHelper.b_IEND, false); return(c); }
public override void ParseFromRaw(ChunkRaw c) { throw new NotImplementedException(); }
/// <summary> /// Deserialization. Given a Raw chunk, just rad, fills this chunk content /// </summary> public abstract void ParseFromRaw(ChunkRaw c);
public ChunkRaw createEmptyChunk(int len, bool alloc) { ChunkRaw c = new ChunkRaw(len, ChunkHelper.ToBytes(Id), alloc); return(c); }
public sealed override void ParseFromRaw(ChunkRaw c) { throw new PngjException("Non supported for a skipped chunk"); }
public override void ParseFromRaw(ChunkRaw c) // does nothing { }