Browse Source

Cleanup Zlib streams

Former-commit-id: acb424add8f9fb1d9f2c969c6a829714a12e5fe7
Former-commit-id: 8b0842a6f600d46375748e9ac2ec126c940b51a1
Former-commit-id: aed00a6f60d7d62baad5f82695c541942b939d30
af/merge-core
James Jackson-South 10 years ago
parent
commit
b869ea8fb1
  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
{
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
/// <inheritdoc/>
public override int Read(byte[] buffer, int offset, int count)
{
throw new NotImplementedException();
throw new NotSupportedException();
}
/// <inheritdoc/>
public override long Seek(long offset, SeekOrigin origin)
{
throw new NotImplementedException();
throw new NotSupportedException();
}
/// <inheritdoc/>
public override void SetLength(long value)
{
throw new NotImplementedException();
throw new NotSupportedException();
}
/// <inheritdoc/>

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

@ -32,24 +32,6 @@ namespace ImageProcessorCore.Formats
/// </summary>
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>
/// The read crc data.
/// </summary>
@ -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
/// <inheritdoc/>
public override long Seek(long offset, SeekOrigin origin)
{
throw new NotImplementedException();
throw new NotSupportedException();
}
/// <inheritdoc/>
public override void SetLength(long value)
{
throw new NotImplementedException();
throw new NotSupportedException();
}
/// <inheritdoc/>
public override void Write(byte[] buffer, int offset, int count)
{
throw new NotImplementedException();
throw new NotSupportedException();
}
/// <inheritdoc/>

Loading…
Cancel
Save