From 5824f314a3ac14fb4f4c8c2db7823076fedbbee8 Mon Sep 17 00:00:00 2001
From: =?utf8?q?V=C3=A1clav=20Slav=C3=ADk?= <vslavik@fastmail.fm>
Date: Fri, 3 Mar 2000 22:52:17 +0000
Subject: [PATCH] added compression ratio argument to wxZlibOutputStream ctor

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@6427 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
---
 docs/latex/wx/strmzlib.tex | 11 +++++++++++
 include/wx/zstream.h       |  2 +-
 src/common/zstream.cpp     |  7 +++++--
 3 files changed, 17 insertions(+), 3 deletions(-)

diff --git a/docs/latex/wx/strmzlib.tex b/docs/latex/wx/strmzlib.tex
index ff8c49b720..33ba7ee708 100644
--- a/docs/latex/wx/strmzlib.tex
+++ b/docs/latex/wx/strmzlib.tex
@@ -38,3 +38,14 @@ to the "filtered" stream.
 
 \helpref{wxOutputStream}{wxoutputstream}
 
+
+\latexignore{\rtfignore{\wxheading{Members}}}
+
+\membersection{wxZlibOutputStream::wxZlibOutputStream}
+
+\func{}{wxZlibOutputStream}{\param{wxOutputStream\&}{ stream},\param{int}{ level = -1}}
+
+Creates a new write-only compressed stream. {\it level} means level of 
+compression. It is number between 0 and 9 (including these values) where
+0 means no compression and 9 best but slowest compression. -1 is default
+value (currently equivalent to 6).
diff --git a/include/wx/zstream.h b/include/wx/zstream.h
index fa65ee7f4e..3cac08f945 100644
--- a/include/wx/zstream.h
+++ b/include/wx/zstream.h
@@ -37,7 +37,7 @@ class WXDLLEXPORT wxZlibInputStream: public wxFilterInputStream {
 
 class WXDLLEXPORT wxZlibOutputStream: public wxFilterOutputStream {
  public:
-  wxZlibOutputStream(wxOutputStream& stream);
+  wxZlibOutputStream(wxOutputStream& stream, int level = -1);
   virtual ~wxZlibOutputStream();
 
   void Sync();
diff --git a/src/common/zstream.cpp b/src/common/zstream.cpp
index a50768c912..24f763bf28 100644
--- a/src/common/zstream.cpp
+++ b/src/common/zstream.cpp
@@ -104,7 +104,7 @@ size_t wxZlibInputStream::OnSysRead(void *buffer, size_t size)
 // wxZlibOutputStream
 //////////////////////
 
-wxZlibOutputStream::wxZlibOutputStream(wxOutputStream& stream)
+wxZlibOutputStream::wxZlibOutputStream(wxOutputStream& stream, int level)
  : wxFilterOutputStream(stream)
 {
   int err;
@@ -115,7 +115,10 @@ wxZlibOutputStream::wxZlibOutputStream(wxOutputStream& stream)
   m_deflate->zfree = (free_func)0;
   m_deflate->opaque = (voidpf)0;
 
-  err = deflateInit(m_deflate, Z_DEFAULT_COMPRESSION);
+  if (level == -1) level = Z_DEFAULT_COMPRESSION;
+  wxASSERT_MSG(level >= 0 && level <= 9, wxT("wxZlibOutputStream compression level must be between 0 and 9!"));
+
+  err = deflateInit(m_deflate, level);
   if (err != Z_OK) {
     deflateEnd(m_deflate);
     return;
-- 
2.50.0

