deflateParams — Alters the compression parameters for the compression stream object stream..
Libz.lib
#include <zlib.h>
int deflateParams(z_streamp stream, int level, int strategy);
On success, the
deflateParams() function
shall return Z_OK
. Otherwise,
deflateParams() shall return
a value as described below to indicate the error.
The deflateParams() function shall dynamically alter the compression parameters for the compression stream object stream. On entry, stream shall refer to a user supplied z_stream object (a z_stream_s structure), already initialized via a call to deflateInit_() or deflateInit2_().
The level
supplied shall be a
value between
0
and 9
,
or the value
Z_DEFAULT_COMPRESSION
. A level
of 1
requests the highest speed, while a
level
of 9
requests the highest compression.
A level of 0
indicates that no
compression should be used, and the output shall be the same as the
input.
If the compression level is altered by deflateParams(),
and some data has already been compressed with this stream
(i.e. total_in
is not zero),
and the new level requires a
different
underlying compression method, then stream
shall be flushed by a call to deflate().
To alter the compression parameters for the compression stream
object stream to level=Z_NO_COMPRESSION and strategy =
Z_DEFAULT_STRATEGY:
#include <stdio.h> |
Z_STREAM_ERROR |
Invalid parameter. |
|
Z_MEM_ERROR |
Insufficient memory available. |
|
Z_BUF_ERROR |
Insufficient space in stream to flush the current output. |
In addition, the
msg
field of
the strm
may be set to an error message.
next_out
(as
identified by
avail_out
) to ensure that all pending
output and
all uncompressed input can be flushed in a single call to
deflate().
Rationale: Although the deflateParams() function should flush pending output and compress all pending input, the result is unspecified if there is insufficient space in the output buffer. Applications should only call deflateParams() when the stream is effectively empty (flushed).
The deflateParams() can be used to switch between compression and straight copy of the input data, or to switch to a different kind of input data requiring a different strategy.
© 2007-2009 Nokia Corporation. All rights reserved. This documentation can be used in the connection with this Product to help and support the user. |
|