Browse Source

Cleanup Zlib streams

Former-commit-id: acb424add8f9fb1d9f2c969c6a829714a12e5fe7
Former-commit-id: 8b0842a6f600d46375748e9ac2ec126c940b51a1
Former-commit-id: aed00a6f60d7d62baad5f82695c541942b939d30
pull/1/head
James Jackson-South 11 years ago
parent
commit
fa40867c7b
  1. 12
      src/ImageProcessorCore/Formats/Png/Zlib/ZlibDeflateStream.cs
  2. 48
      src/ImageProcessorCore/Formats/Png/Zlib/ZlibInflateStream.cs

12
src/ImageProcessorCore/Formats/Png/Zlib/ZlibDeflateStream.cs

@ -119,7 +119,7 @@ namespace ImageProcessorCore.Formats
{ {
get get
{ {
throw new NotImplementedException(); throw new NotSupportedException();
} }
} }
@ -128,12 +128,12 @@ namespace ImageProcessorCore.Formats
{ {
get get
{ {
throw new NotImplementedException(); throw new NotSupportedException();
} }
set set
{ {
throw new NotImplementedException(); throw new NotSupportedException();
} }
} }
@ -146,19 +146,19 @@ namespace ImageProcessorCore.Formats
/// <inheritdoc/> /// <inheritdoc/>
public override int Read(byte[] buffer, int offset, int count) public override int Read(byte[] buffer, int offset, int count)
{ {
throw new NotImplementedException(); throw new NotSupportedException();
} }
/// <inheritdoc/> /// <inheritdoc/>
public override long Seek(long offset, SeekOrigin origin) public override long Seek(long offset, SeekOrigin origin)
{ {
throw new NotImplementedException(); throw new NotSupportedException();
} }
/// <inheritdoc/> /// <inheritdoc/>
public override void SetLength(long value) public override void SetLength(long value)
{ {
throw new NotImplementedException(); throw new NotSupportedException();
} }
/// <inheritdoc/> /// <inheritdoc/>

48
src/ImageProcessorCore/Formats/Png/Zlib/ZlibInflateStream.cs

@ -32,24 +32,6 @@ namespace ImageProcessorCore.Formats
/// </summary> /// </summary>
private readonly Stream rawStream; private readonly Stream rawStream;
/// <summary>
/// The preset dictionary.
/// Merely informational, not used.
/// </summary>
private bool fdict;
/// <summary>
/// The DICT dictionary identifier identifying the used dictionary.
/// Merely informational, not used.
/// </summary>
private byte[] dictId;
/// <summary>
/// CINFO is the base-2 logarithm of the LZ77 window size, minus eight.
/// Merely informational, not used.
/// </summary>
private int cinfo;
/// <summary> /// <summary>
/// The read crc data. /// The read crc data.
/// </summary> /// </summary>
@ -60,6 +42,10 @@ namespace ImageProcessorCore.Formats
public ZlibInflateStream(Stream stream) public ZlibInflateStream(Stream stream)
{ {
// The DICT dictionary identifier identifying the used dictionary.
// The preset dictionary.
bool fdict;
this.rawStream = stream; this.rawStream = stream;
// Read the zlib header : http://tools.ietf.org/html/rfc1950 // 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}"); throw new Exception($"Bad compression method for ZLIB header: cmf={cmf}");
} }
this.cinfo = ((cmf & (0xf0)) >> 8); // CINFO is the base-2 logarithm of the LZ77 window size, minus eight.
this.fdict = (flag & 32) != 0; // 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++) for (int i = 0; i < 4; i++)
{ {
// We consume but don't use this. // 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 get
{ {
throw new NotImplementedException(); throw new NotSupportedException();
} }
} }
@ -126,12 +114,12 @@ namespace ImageProcessorCore.Formats
{ {
get get
{ {
throw new NotImplementedException(); throw new NotSupportedException();
} }
set set
{ {
throw new NotImplementedException(); throw new NotSupportedException();
} }
} }
@ -154,7 +142,7 @@ namespace ImageProcessorCore.Formats
{ {
// we dont really check/use this // we dont really check/use this
this.crcread[i] = (byte)this.rawStream.ReadByte(); this.crcread[i] = (byte)this.rawStream.ReadByte();
} }
} }
return read; return read;
@ -163,19 +151,19 @@ namespace ImageProcessorCore.Formats
/// <inheritdoc/> /// <inheritdoc/>
public override long Seek(long offset, SeekOrigin origin) public override long Seek(long offset, SeekOrigin origin)
{ {
throw new NotImplementedException(); throw new NotSupportedException();
} }
/// <inheritdoc/> /// <inheritdoc/>
public override void SetLength(long value) public override void SetLength(long value)
{ {
throw new NotImplementedException(); throw new NotSupportedException();
} }
/// <inheritdoc/> /// <inheritdoc/>
public override void Write(byte[] buffer, int offset, int count) public override void Write(byte[] buffer, int offset, int count)
{ {
throw new NotImplementedException(); throw new NotSupportedException();
} }
/// <inheritdoc/> /// <inheritdoc/>

Loading…
Cancel
Save