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(); } } } } }
public int ReadDWord() { return(PngHelper.DWordToInt(ReadInt32())); }