Ejemplo n.º 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);
        }
Ejemplo n.º 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);
        }
Ejemplo n.º 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
        }
Ejemplo n.º 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));
 }
Ejemplo n.º 5
0
        public override void CloneDataFromRead(PngChunk other)
        {
            PngChunkSTER otherx = (PngChunkSTER)other;

            this.Mode = otherx.Mode;
        }
Ejemplo n.º 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);
 }
Ejemplo n.º 7
0
 public static bool IsUnknown(PngChunk chunk)
 {
     return(chunk is PngChunkUNKNOWN);
 }
Ejemplo n.º 8
0
 public static bool IsText(PngChunk c)
 {
     return(c is PngChunkTextVar);
 }
Ejemplo n.º 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)));
 }
Ejemplo n.º 10
0
        public override void CloneDataFromRead(PngChunk other)
        {
            PngChunkSRGB otherx = (PngChunkSRGB)other;

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

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