Пример #1
0
            /// <summary>
            /// Constructor which takes an existing APNGChunk object and
            /// verifies that its type matches that which is expected
            /// </summary>
            /// <param name="chunk">The APNGChunk to copy</param>
            /// <param name="expectedType">The input APNGChunk expected type</param>
            public APNGChunk(APNGChunk chunk, String expectedType)
            {
                // Copy the existing chunks members
                chunkLength = chunk.chunkLength;
                chunkType   = chunk.chunkType;
                chunkData   = chunk.chunkData;
                chunkCRC    = chunk.chunkCRC;

                // Verify the chunk type is as expected
                if (ChunkType != expectedType)
                {
                    throw new ArgumentException(
                              String.Format("Specified chunk type is not {0} as expected", expectedType));
                }

                // Parse the chunk's data
                ParseData(chunkData);
            }
Пример #2
0
            public void Load(Stream stream)
            {
                chunks = new List <APNGChunk>();
                pngs   = new List <PNG>();

                // Create a new header (should be 1 per file) and
                // read it from the stream
                var header = new APNGHeader();

                try
                {
                    header.Read(stream);
                }
                catch (Exception)
                {
                    stream.Close();
                    throw;
                }

                APNGChunk chunk;
                PNG       png = null;

                // Read chunks from the stream until we reach the MEND chunk
                do
                {
                    // Read a generic Chunk
                    chunk = new APNGChunk();
                    try
                    {
                        chunk.Read(stream);
                    }
                    catch (Exception)
                    {
                        stream.Close();
                        throw;
                    }

                    // Take a look at the chunk type and decide what derived class to
                    // use to create a specific chunk
                    switch (chunk.ChunkType)
                    {
                    case acTLChunk.NAME:
                        if (headerChunk != null)
                        {
                            throw new ApplicationException(String.Format(
                                                               "Only one chunk of type {0} is allowed", chunk.ChunkType));
                        }
                        chunk = headerChunk = new acTLChunk(chunk);
                        break;

                    case MENDChunk.NAME:
                        chunk = new MENDChunk(chunk);
                        break;

                    case TERMChunk.NAME:
                        chunk = new TERMChunk(chunk);
                        break;

                    case BACKChunk.NAME:
                        chunk = new BACKChunk(chunk);
                        break;

                    case BKGDChunk.NAME:
                        chunk = new BKGDChunk(chunk);
                        break;

                    case fcTLChunk.NAME:
                        // This is the beginning of a new embedded PNG
                        chunk = new fcTLChunk(chunk);
                        png   = new PNG {
                            FCTL = chunk as fcTLChunk, IHDR = ihdrChunk
                        };
                        pngs.Add(png);
                        break;

                    case IHDRChunk.NAME:
                        chunk     = new IHDRChunk(chunk);
                        ihdrChunk = chunk as IHDRChunk;
                        break;

                    case IDATChunk.NAME:
                        chunk = new IDATChunk(chunk);
                        if (png != null)
                        {
                            png.IDAT = chunk as IDATChunk;
                        }
                        break;

                    case fdATChunk.NAME:
                        chunk = new fdATChunk(chunk);
                        if (png != null)
                        {
                            chunk.ChunkType = IDATChunk.NAME;
                            png.IDAT        = new IDATChunk(chunk);
                        }
                        break;

                    case IENDChunk.NAME:
                        chunk = new IENDChunk(chunk);
                        for (var i = 0; i < pngs.Count; i++)
                        {
                            pngs[i].IEND = chunk as IENDChunk;
                        }
                        break;

                    default:
                        break;
                    }
                    // Add the chunk to our list of chunks
                    chunks.Add(chunk);
                }while (chunk.ChunkType != IENDChunk.NAME);
            }
Пример #3
0
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="chunk">The APNG chunk containing the data for this specific chunk</param>
 public fdATChunk(APNGChunk chunk)
     : base(chunk, NAME)
 {
 }
Пример #4
0
            ///// <summary>
            ///// The APNG frame rate
            ///// </summary>
            //private uint ticksPerSecond;
            ///// <summary>
            ///// The APNG layer count
            ///// </summary>
            //private uint nominalLayerCount;
            ///// <summary>
            ///// The APNG frame count
            ///// </summary>
            //private uint nominalFrameCount;
            ///// <summary>
            ///// The APNG play time
            ///// </summary>
            //private uint nominalPlayTime;
            ///// <summary>
            ///// The APNG simplicity profile
            ///// </summary>
            //private uint simplicityProfile;

            /// <summary>
            /// Constructor
            /// </summary>
            /// <param name="chunk">The APNG chunk containing the data for this specific chunk</param>
            public acTLChunk(APNGChunk chunk)
                : base(chunk, NAME)
            {
            }
Пример #5
0
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="chunk">The APNG chunk containing the data for this specific chunk</param>
 public IENDChunk(APNGChunk chunk)
     : base(chunk, NAME)
 {
 }
Пример #6
0
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="chunk">The APNG chunk containing the data for this specific chunk</param>
 public IHDRChunk(APNGChunk chunk)
     : base(chunk, NAME)
 {
 }
Пример #7
0
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="chunk">The APNG chunk containing the data for this specific chunk</param>
 public BACKChunk(APNGChunk chunk)
     : base(chunk, NAME)
 {
 }
Пример #8
0
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="chunk">The APNG chunk containing the data for this specific chunk</param>
 public BKGDChunk(APNGChunk chunk)
     : base(chunk, NAME)
 {
 }
Пример #9
0
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="chunk">The APNG chunk containing the data for this specific chunk</param>
 public TERMChunk(APNGChunk chunk)
     : base(chunk, NAME)
 {
 }