Example #1
0
        /// <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);
        }
Example #2
0
        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);
        }
Example #3
0
        /// <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
        }
Example #4
0
 /// <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;
        }
Example #6
0
 /// <summary>Queues the chunk at the writer</summary>
 /// <param name="chunk">Chunk, ready for write</param>
 public void QueueChunk(PngChunk chunk)
 {
     QueueChunk(chunk, true);
 }
Example #7
0
 public static bool IsUnknown(PngChunk chunk)
 {
     return(chunk is PngChunkUNKNOWN);
 }
Example #8
0
 public static bool IsText(PngChunk c)
 {
     return(c is PngChunkTextVar);
 }
Example #9
0
 /// <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)));
 }
Example #10
0
        public override void CloneDataFromRead(PngChunk other)
        {
            PngChunkSRGB otherx = (PngChunkSRGB)other;

            Intent = otherx.Intent;
        }
Example #11
0
 /// <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);
 }
Example #12
0
 /// <summary>
 /// Override to make a copy (normally deep) from other chunk
 /// </summary>
 /// <param name="other"></param>
 public abstract void CloneDataFromRead(PngChunk other);
Example #13
0
 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
 }
Example #14
0
        public override void CloneDataFromRead(PngChunk other)
        {
            PngChunkUNKNOWN pngChunkUNKNOWN = (PngChunkUNKNOWN)other;

            data = pngChunkUNKNOWN.data;
        }
Example #15
0
 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)
 {
 }
Example #19
0
 public sealed override void CloneDataFromRead(PngChunk other)
 {
     throw new PngjException("Non supported for a skipped chunk");
 }
Example #20
0
 public override void CloneDataFromRead(PngChunk other)
 {
     gamma = ((PngChunkGAMA)other).gamma;
 }
Example #21
0
 public bool Matches(PngChunk c)
 {
     return(c.Id.Equals(id));
 }
Example #22
0
 /// <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);
 }
Example #23
0
 public void QueueChunk(PngChunk chunk)
 {
     QueueChunk(chunk, lazyOverwrite: true);
 }