From b869ea8fb1e7ac3800e1e49f4401c73ebe722ec9 Mon Sep 17 00:00:00 2001 From: James Jackson-South Date: Mon, 14 Mar 2016 19:29:29 +1100 Subject: [PATCH] Cleanup Zlib streams Former-commit-id: acb424add8f9fb1d9f2c969c6a829714a12e5fe7 Former-commit-id: 8b0842a6f600d46375748e9ac2ec126c940b51a1 Former-commit-id: aed00a6f60d7d62baad5f82695c541942b939d30 --- .../Formats/Png/Zlib/ZlibDeflateStream.cs | 12 ++--- .../Formats/Png/Zlib/ZlibInflateStream.cs | 48 +++++++------------ 2 files changed, 24 insertions(+), 36 deletions(-) diff --git a/src/ImageProcessorCore/Formats/Png/Zlib/ZlibDeflateStream.cs b/src/ImageProcessorCore/Formats/Png/Zlib/ZlibDeflateStream.cs index a621542007..a2c0ca202f 100644 --- a/src/ImageProcessorCore/Formats/Png/Zlib/ZlibDeflateStream.cs +++ b/src/ImageProcessorCore/Formats/Png/Zlib/ZlibDeflateStream.cs @@ -119,7 +119,7 @@ namespace ImageProcessorCore.Formats { get { - throw new NotImplementedException(); + throw new NotSupportedException(); } } @@ -128,12 +128,12 @@ namespace ImageProcessorCore.Formats { get { - throw new NotImplementedException(); + throw new NotSupportedException(); } set { - throw new NotImplementedException(); + throw new NotSupportedException(); } } @@ -146,19 +146,19 @@ namespace ImageProcessorCore.Formats /// public override int Read(byte[] buffer, int offset, int count) { - throw new NotImplementedException(); + throw new NotSupportedException(); } /// public override long Seek(long offset, SeekOrigin origin) { - throw new NotImplementedException(); + throw new NotSupportedException(); } /// public override void SetLength(long value) { - throw new NotImplementedException(); + throw new NotSupportedException(); } /// diff --git a/src/ImageProcessorCore/Formats/Png/Zlib/ZlibInflateStream.cs b/src/ImageProcessorCore/Formats/Png/Zlib/ZlibInflateStream.cs index b0afac69cb..4373b5fd17 100644 --- a/src/ImageProcessorCore/Formats/Png/Zlib/ZlibInflateStream.cs +++ b/src/ImageProcessorCore/Formats/Png/Zlib/ZlibInflateStream.cs @@ -32,24 +32,6 @@ namespace ImageProcessorCore.Formats /// private readonly Stream rawStream; - /// - /// The preset dictionary. - /// Merely informational, not used. - /// - private bool fdict; - - /// - /// The DICT dictionary identifier identifying the used dictionary. - /// Merely informational, not used. - /// - private byte[] dictId; - - /// - /// CINFO is the base-2 logarithm of the LZ77 window size, minus eight. - /// Merely informational, not used. - /// - private int cinfo; - /// /// The read crc data. /// @@ -60,6 +42,10 @@ namespace ImageProcessorCore.Formats public ZlibInflateStream(Stream stream) { + // The DICT dictionary identifier identifying the used dictionary. + + // The preset dictionary. + bool fdict; this.rawStream = stream; // Read the zlib header : http://tools.ietf.org/html/rfc1950 @@ -85,17 +71,19 @@ namespace ImageProcessorCore.Formats throw new Exception($"Bad compression method for ZLIB header: cmf={cmf}"); } - this.cinfo = ((cmf & (0xf0)) >> 8); - this.fdict = (flag & 32) != 0; + // CINFO is the base-2 logarithm of the LZ77 window size, minus eight. + // int cinfo = ((cmf & (0xf0)) >> 8); + fdict = (flag & 32) != 0; - if (this.fdict) + if (fdict) { - this.dictId = new byte[4]; + // The DICT dictionary identifier identifying the used dictionary. + byte[] dictId = new byte[4]; for (int i = 0; i < 4; i++) { // We consume but don't use this. - this.dictId[i] = (byte)this.rawStream.ReadByte(); + dictId[i] = (byte)this.rawStream.ReadByte(); } } @@ -117,7 +105,7 @@ namespace ImageProcessorCore.Formats { get { - throw new NotImplementedException(); + throw new NotSupportedException(); } } @@ -126,12 +114,12 @@ namespace ImageProcessorCore.Formats { get { - throw new NotImplementedException(); + throw new NotSupportedException(); } set { - throw new NotImplementedException(); + throw new NotSupportedException(); } } @@ -154,7 +142,7 @@ namespace ImageProcessorCore.Formats { // we dont really check/use this this.crcread[i] = (byte)this.rawStream.ReadByte(); - } + } } return read; @@ -163,19 +151,19 @@ namespace ImageProcessorCore.Formats /// public override long Seek(long offset, SeekOrigin origin) { - throw new NotImplementedException(); + throw new NotSupportedException(); } /// public override void SetLength(long value) { - throw new NotImplementedException(); + throw new NotSupportedException(); } /// public override void Write(byte[] buffer, int offset, int count) { - throw new NotImplementedException(); + throw new NotSupportedException(); } ///