예제 #1
0
        public void Load(Stream streamFilePNG)
        {
            //cargo los datos del archivo
            //firma,IHDR,IDAT,IEND
            byte[] firmaAComprobar = null;
            Chunk  chunk;

            firmaAComprobar = streamFilePNG.Read(PNG.Header.Length);
            for (int i = 0; i < firmaAComprobar.Length; i++)
            {
                if (firmaAComprobar[i] != PNG.Header[i])
                {
                    throw new Exception("El archivo no tiene la firma APNG correcta!");
                }
            }
            IHDR = new IHDRChunk(Chunk.ReadChunk(streamFilePNG));
            do
            {
                chunk = Chunk.ReadChunk(streamFilePNG);
                if (chunk.ChunkType != IENDChunk.NAME)
                {
                    Add(chunk);
                }
            } while (chunk.ChunkType != IENDChunk.NAME);
            IEND = new IENDChunk(chunk);
        }
예제 #2
0
        void AñadirChunk(Chunk chunk)
        {
            //controlo que esten bien puestos y todo eso...
            switch (chunk.ChunkType)
            {
            case IHDRChunk.NAME:
                if (IhdrChunk != null)
                {
                    throw new Exception("Solo puede haber uno por archivo");
                }
                IhdrChunk = new IHDRChunk(chunk);
                break;

            case acTLChunk.NAME:
                if (HeaderChunk != null)
                {
                    throw new Exception("Solo puede haber uno por archivo");
                }
                HeaderChunk = new acTLChunk(chunk);
                break;

            case fcTLChunk.NAME:
                chunks.Add(new fcTLChunk(chunk));
                break;

            case IDATChunk.NAME:
                chunks.Add(chunk);
                break;

            case IENDChunk.NAME:
                if (IendChunk != null)
                {
                    throw new Exception("Solo puede haber uno por archivo");
                }
                IendChunk = new IENDChunk(chunk);
                break;

            case tEXtChunk.NAME:
                metadata.Add(new tEXtChunk(chunk)); break;

            default:
                chunks.Add(chunk);    //pos si hay de extras no contemplados...
                break;
            }
        }