/// <summary> /// Creates one new blank chunk of the corresponding type, according to factoryMap (PngChunkUNKNOWN if not known) /// </summary> /// <param name="cid">Chunk Id</param> /// <param name="info"></param> /// <returns></returns> internal static PngChunk FactoryFromId(String cid, ImageInfo info) { PngChunk chunk = null; if (factoryMap == null) { initFactory(); } if (isKnown(cid)) { chunk = factoryMap[cid](info); } if (chunk == null) { Console.WriteLine("unknown chunk " + cid); chunk = new PngChunkUNKNOWN(cid, info); } return(chunk); }
internal static PngChunk FactoryFromId(string cid, ImageInfo info) { PngChunk pngChunk = null; if (factoryMap == null) { initFactory(); } if (isKnown(cid)) { pngChunk = (PngChunk)factoryMap[cid].GetTypeInfo().DeclaredConstructors.First().Invoke(new object[1] { info }); } if (pngChunk == null) { pngChunk = new PngChunkUNKNOWN(cid, info); } return(pngChunk); }
/// <summary> /// Decides if a chunk should be loaded, according to a ChunkLoadBehaviour /// </summary> /// <param name="id"></param> /// <param name="behav"></param> /// <returns></returns> public static bool ShouldLoad(String id, ChunkLoadBehaviour behav) { if (IsCritical(id)) { return(true); } bool kwown = PngChunk.isKnown(id); switch (behav) { case ChunkLoadBehaviour.LOAD_CHUNK_ALWAYS: return(true); case ChunkLoadBehaviour.LOAD_CHUNK_IF_SAFE: return(kwown || IsSafeToCopy(id)); case ChunkLoadBehaviour.LOAD_CHUNK_KNOWN: return(kwown); case ChunkLoadBehaviour.LOAD_CHUNK_NEVER: return(false); } return(false); // should not reach here }
/// <summary> ///Remove Chunk: only from queued /// </summary> /// <remarks> /// WARNING: this depends on chunk.Equals() implementation, which is straightforward for SingleChunks. For /// MultipleChunks, it will normally check for reference equality! /// </remarks> /// <param name="c"></param> /// <returns></returns> public bool RemoveChunk(PngChunk c) { return(queuedChunks.Remove(c)); }
public override void CloneDataFromRead(PngChunk other) { PngChunkSTER otherx = (PngChunkSTER)other; this.Mode = otherx.Mode; }
/// <summary>Queues the chunk at the writer</summary> /// <param name="chunk">Chunk, ready for write</param> public void QueueChunk(PngChunk chunk) { QueueChunk(chunk, true); }
public static bool IsUnknown(PngChunk chunk) { return(chunk is PngChunkUNKNOWN); }
public static bool IsText(PngChunk c) { return(c is PngChunkTextVar); }
/// <summary> /// Finds all chunks "equivalent" to this one /// </summary> /// <param name="chunk"></param> /// <returns>Empty if nothing found</returns> public List <PngChunk> GetEquivalent(PngChunk chunk) { return(ChunkHelper.FilterList(chunks, new ChunkPredicateEquiv(chunk))); }
public override void CloneDataFromRead(PngChunk other) { PngChunkSRGB otherx = (PngChunkSRGB)other; Intent = otherx.Intent; }
/// <summary> /// Adds chunk to queue /// </summary> /// <remarks>Does not check for duplicated or anything</remarks> /// <param name="chunk"></param> /// <returns></returns> public bool Queue(PngChunk chunk) { queuedChunks.Add(chunk); return(true); }
/// <summary> /// Override to make a copy (normally deep) from other chunk /// </summary> /// <param name="other"></param> public abstract void CloneDataFromRead(PngChunk other);
public override void CloneDataFromRead(PngChunk other) { // THIS SHOULD NOT BE CALLED IF ALREADY CLONED WITH COPY CONSTRUCTOR PngChunkUNKNOWN c = (PngChunkUNKNOWN)other; data = c.data; // not deep copy }
public override void CloneDataFromRead(PngChunk other) { PngChunkUNKNOWN pngChunkUNKNOWN = (PngChunkUNKNOWN)other; data = pngChunkUNKNOWN.data; }
public bool Matches(PngChunk c) { return(c.Id.Equals(id, StringComparison.InvariantCultureIgnoreCase)); }
/// <summary> /// Creates predicate based of reference chunk /// </summary> /// <param name="chunk"></param> public ChunkPredicateEquiv(PngChunk chunk) { this.chunk = chunk; }
/// <summary> /// Check for match /// </summary> /// <param name="c"></param> /// <returns></returns> public bool Matches(PngChunk c) { return(ChunkHelper.Equivalent(c, chunk)); }
public override void CloneDataFromRead(PngChunk other) { }
public sealed override void CloneDataFromRead(PngChunk other) { throw new PngjException("Non supported for a skipped chunk"); }
public override void CloneDataFromRead(PngChunk other) { gamma = ((PngChunkGAMA)other).gamma; }
public bool Matches(PngChunk c) { return(c.Id.Equals(id)); }
/// <summary> /// Adds chunk in next position. This is used only by the pngReader /// </summary> /// <param name="chunk"></param> /// <param name="chunkGroup"></param> public void AppendReadChunk(PngChunk chunk, int chunkGroup) { chunk.ChunkGroup = chunkGroup; chunks.Add(chunk); }
public void QueueChunk(PngChunk chunk) { QueueChunk(chunk, lazyOverwrite: true); }