/// <summary> /// Finishes writing uncompressed data to the output stream without closing /// the underlying stream. Use this method when applying multiple filters in /// succession to the same output stream. /// </summary> /// <exception cref="IOException"> if an I/O error occurs or this stream is already /// closed </exception> //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET: //ORIGINAL LINE: public void finish() throws java.io.IOException public virtual void Finish() { EnsureOpen(); // Finish decompressing and writing pending output data Flush(); if (UsesDefaultInflater) { Inf.End(); } }
public void decode(ByteBuffer buffer, int stride, Format fmt) { int offset = buffer.Position(); int lineSize = ((width * bitdepth + 7) / 8) * bytesPerPixel; byte[] curLine = new byte[lineSize + 1]; byte[] prevLine = new byte[lineSize + 1]; byte[] palLine = (bitdepth < 8) ? new byte[width + 1] : null; Inflater inflater = new Inflater(); try { for (int y = 0; y < height; y++) { readChunkUnzip(inflater, curLine, 0, curLine.Length); unfilter(curLine, prevLine); buffer.Position(offset + y * stride); switch (colorType) { case COLOR_TRUECOLOR: switch (fmt) { case Format.ABGR: copyRGBtoABGR(buffer, curLine); break; case Format.RGBA: copyRGBtoRGBA(buffer, curLine); break; case Format.BGRA: copyRGBtoBGRA(buffer, curLine); break; case Format.RGB: copy(buffer, curLine); break; default: throw new UnsupportedOperationException("Unsupported format for this image"); } break; case COLOR_TRUEALPHA: switch (fmt) { case Format.ABGR: copyRGBAtoABGR(buffer, curLine); break; case Format.RGBA: copy(buffer, curLine); break; case Format.BGRA: copyRGBAtoBGRA(buffer, curLine); break; case Format.RGB: copyRGBAtoRGB(buffer, curLine); break; default: throw new UnsupportedOperationException("Unsupported format for this image"); } break; case COLOR_GREYSCALE: switch (fmt) { case Format.LUMINANCE: case Format.ALPHA: copy(buffer, curLine); break; default: throw new UnsupportedOperationException("Unsupported format for this image"); } break; case COLOR_GREYALPHA: switch (fmt) { case Format.LUMINANCE_ALPHA: copy(buffer, curLine); break; default: throw new UnsupportedOperationException("Unsupported format for this image"); } break; case COLOR_INDEXED: switch (bitdepth) { case 8: palLine = curLine; break; case 4: expand4(curLine, palLine); break; case 2: expand2(curLine, palLine); break; case 1: expand1(curLine, palLine); break; default: throw new UnsupportedOperationException("Unsupported bitdepth for this image"); } switch (fmt) { case Format.ABGR: copyPALtoABGR(buffer, palLine); break; case Format.RGBA: copyPALtoRGBA(buffer, palLine); break; case Format.BGRA: copyPALtoBGRA(buffer, palLine); break; default: throw new UnsupportedOperationException("Unsupported format for this image"); } break; default: throw new UnsupportedOperationException("Not yet implemented"); } byte[] tmp = curLine; curLine = prevLine; prevLine = tmp; } } finally { inflater.End(); } }