Exemplo n.º 1
0
        public Png(string fileName)
        {
            using (Stream stream = new FileStream(fileName, FileMode.Open))
            {
                using (PngBinaryReader reader = new PngBinaryReader(stream))
                {
                    reader.ReadSignature();

                    // Header lesen
                    Chunk chunk = reader.ReadChunk();
                    if ((chunk.Length != 13) || (chunk.Type != PngHelper.TxtToInt(PngHelper.IHDR)))
                    {
                        throw new InvalidDataException("Wrong IHDR Chunk!");
                    }
                    header = PngHelper.ConvertIHDR(chunk);

                    using (MemoryStream outMemoryStream = new MemoryStream())
                    {
                        // Daten Stream bis zum Ende
                        while (chunk.Type != PngHelper.TxtToInt(PngHelper.IEND))
                        {
                            if (chunk.Type == PngHelper.TxtToInt(PngHelper.IDAT))
                            {
                                outMemoryStream.Write(chunk.Data, 0, chunk.Data.Length);
                                dataChunk = chunk;
                            }

                            chunk = reader.ReadChunk();
                        }
                    }
                }
            }
        }
Exemplo n.º 2
0
 public int ReadDWord()
 {
     return(PngHelper.DWordToInt(ReadInt32()));
 }