java zlib1.dll,在Delphi中使用ZLib的最新版本

在Delphi中使用ZLib的最新版本

ZLib(http://www.zlib.net)是现在使用最广泛的一套开源的通用无损压缩代码集了。它是LZ77 ((Lempel-Ziv 1977)的一个变种分支。它的代码是线程安全的,数据格式可以参见RFCs(Request for Comments) 1950 到1952(http://www.ietf.org/rfc/rfc1950.txt (zlib format), rfc1951.txt (deflate format) and rfc1952.txt (gzip format))。这套源码中支持了两种压缩方法,一种就是普通的deflate/inflate,一种是gzip格式。前者更精巧,后者则增加了对目录的支持及其它一些更丰富的功能。

ZLib的是用C编写的,在VC++、BC++或C++Builder中自然很容易直接使用,对于Delphi开发者,虽然Delphi自带了ZLib的移植版本(zlib.pas),但版本为1.0.4,而且必须要使用Borland自己编译生成的zlib.dcu(当然,在完整版的光盘中包含了编译好的zlib库的.obj文件和c代码,只是缺省安装下,不过安装这些文件);最新的Zlib版本为1.2.2.3。我们先看看从1.0.4到1.2.2.3都发生了些什么变化吧:

ChangeLog file for zlib

Changes in 1.2.2.3 (27 May 2005)

- Replace 1U constants in inflate.c and inftrees.c for 64-bit compile

- Typecast fread() return values in gzio.c [Vollant]

- Remove trailing space in minigzip.c outmode (VC++ can't deal with it)

- Fix crc check bug in gzread() after gzungetc() [Heiner]

- Add the deflateTune() function to adjust internal compression parameters

- Add a fast gzip decompressor, gun.c, to examples (use of inflateBack)

- Remove an incorrect assertion in examples/zpipe.c

- Add C++ wrapper in infback9.h [Donais]

- Fix bug in inflateCopy() when decoding fixed codes

- Note in zlib.h how much deflateSetDictionary() actually uses

- Remove USE_DICT_HEAD in deflate.c (would mess up inflate if used)

- Add _WIN32_WCE to define WIN32 in zconf.in.h [Spencer]

- Don't include stderr.h or errno.h for _WIN32_WCE in zutil.h [Spencer]

- Add gzdirect() function to indicate transparent reads

- Update contrib/minizip [Vollant]

- Fix compilation of deflate.c when both ASMV and FASTEST [Oberhumer]

- Add casts in crc32.c to avoid warnings [Oberhumer]

- Add contrib/masmx64 [Vollant]

- Update contrib/asm586, asm686, masmx86, testzlib, vstudio [Vollant]

Changes in 1.2.2.2 (30 December 2004)

- Replace structure assignments in deflate.c and inflate.c with zmemcpy to

avoid implicit memcpy calls (portability for no-library compilation)

- Increase sprintf() buffer size in gzdopen() to allow for large numbers

- Add INFLATE_STRICT to check distances against zlib header

- Improve WinCE errno handling and comments [Chang]

- Remove comment about no gzip header processing in FAQ

- Add Z_FIXED strategy option to deflateInit2() to force fixed trees

- Add updated make_vms.com [Coghlan], update README

- Create a new "examples" directory, move gzappend.c there, add zpipe.c,

fitblk.c, gzlog.[ch], gzjoin.c, and zlib_how.html.

- Add FAQ entry and comments in deflate.c on uninitialized memory access

- Add Solaris 9 make options in configure [Gilbert]

- Allow strerror() usage in gzio.c for STDC

- Fix DecompressBuf in contrib/delphi/ZLib.pas [ManChesTer]

- Update contrib/masmx86/inffas32.asm and gvmat32.asm [Vollant]

- Use z_off_t for adler32_combine() and crc32_combine() lengths

- Make adler32() much faster for small len

- Use OS_CODE in deflate() default gzip header

Changes in 1.2.2.1 (31 October 2004)

- Allow inflateSetDictionary() call for raw inflate

- Fix inflate header crc check bug for file names and comments

- Add deflateSetHeader() and gz_header structure for custom gzip headers

- Add inflateGetheader() to retrieve gzip headers

- Add crc32_combine() and adler32_combine() functions

- Add alloc_func, free_func, in_func, out_func to Z_PREFIX list

- Use zstreamp consistently in zlib.h (inflate_back functions)

- Remove GUNZIP condition from definition of inflate_mode in inflate.h

and in contrib/inflate86/inffast.S [Truta, Anderson]

- Add support for AMD64 in contrib/inflate86/inffas86.c [Anderson]

- Update projects/README.projects and projects/visualc6 [Truta]

- Update win32/DLL_FAQ.txt [Truta]

- Avoid warning under NO_GZCOMPRESS in gzio.c; fix typo [Truta]

- Deprecate Z_ASCII; use Z_TEXT instead [Truta]

- Use a new algorithm for setting strm->data_type in trees.c [Truta]

- Do not define an exit() prototype in zutil.c unless DEBUG defined

- Remove prototype of exit() from zutil.c, example.c, minigzip.c [Truta]

- Add comment in zlib.h for Z_NO_FLUSH parameter to deflate()

- Fix Darwin build version identification [Peterson]

Changes in 1.2.2 (3 October 2004)

- Update zlib.h comments on gzip in-memory processing

- Set adler to 1 in inflateReset() to support Java test suite [Walles]

- Add contrib/dotzlib [Ravn]

- Update win32/DLL_FAQ.txt [Truta]

- Update contrib/minizip [Vollant]

- Move contrib/visual-basic.txt to old/ [Truta]

- Fix assembler builds in projects/visualc6/ [Truta]

Changes in 1.2.1.2 (9 September 2004)

- Update INDEX file

- Fix trees.c to update strm->data_type (no one ever noticed!)

- Fix bug in error case in inflate.c, infback.c, and infback9.c [Brown]

- Add "volatile" to crc table flag declaration (for DYNAMIC_CRC_TABLE)

- Add limited multitasking protection to DYNAMIC_CRC_TABLE

- Add NO_vsnprintf for VMS in zutil.h [Mozilla]

- Don't declare strerror() under VMS [Mozilla]

- Add comment to DYNAMIC_CRC_TABLE to use get_crc_table() to initialize

- Update contrib/ada [Anisimkov]

- Update contrib/minizip [Vollant]

- Fix configure to not hardcode directories for Darwin [Peterson]

- Fix gzio.c to not return error on empty files [Brown]

- Fix indentation; update version in contrib/delphi/ZLib.pas and

contrib/pascal/zlibpas.pas [Truta]

- Update mkasm.bat in contrib/masmx86 [Truta]

- Update contrib/untgz [Truta]

- Add projects/README.projects [Truta]

- Add project for MS Visual C++ 6.0 in projects/visualc6 [Cadieux, Truta]

- Update win32/DLL_FAQ.txt [Truta]

- Update list of Z_PREFIX symbols in zconf.h [Randers-Pehrson, Truta]

- Remove an unnecessary assignment to curr in inftrees.c [Truta]

- Add OS/2 to exe builds in configure [Poltorak]

- Remove err dummy parameter in zlib.h [Kientzle]

Changes in 1.2.1.1 (9 January 2004)

- Update email address in README

- Several FAQ updates

- Fix a big fat bug in inftrees.c that prevented decoding valid

dynamic blocks with only literals and no distance codes --

Thanks to "Hot Emu" for the bug report and sample file

- Add a note to puff.c on no distance codes case.

Changes in 1.2.1 (17 November 2003)

- Remove a tab in contrib/gzappend/gzappend.c

- Update some interfaces in contrib for new zlib functions

- Update zlib version number in some contrib entries

- Add Windows CE definition for ptrdiff_t in zutil.h [Mai, Truta]

- Support shared libraries on Hurd and KFreeBSD [Brown]

- Fix error in NO_DIVIDE option of adler32.c

Changes in 1.2.0.8 (4 November 2003)

- Update version in contrib/delphi/ZLib.pas and contrib/pascal/zlibpas.pas

- Add experimental NO_DIVIDE #define in adler32.c

- Possibly faster on some processors (let me know if it is)

- Correct Z_BLOCK to not return on first inflate call if no wrap

- Fix strm->data_type on inflate() return to correctly indicate EOB

- Add deflatePrime() function for appending in the middle of a byte

- Add contrib/gzappend for an example of appending to a stream

- Update win32/DLL_FAQ.txt [Truta]

- Delete Turbo C comment in README [Truta]

- Improve some indentation in zconf.h [Truta]

- Fix infinite loop on bad input in configure script [Church]

- Fix gzeof() for concatenated gzip files [Johnson]

- Add example to contrib/visual-basic.txt [Michael B.]

- Add -p to mkdir's in Makefile.in [vda]

- Fix configure to properly detect presence or lack of printf functions

- Add AS400 support [Monnerat]

- Add a little Cygwin support [Wilson]

Changes in 1.2.0.7 (21 September 2003)

- Correct some debug formats in contrib/infback9

- Cast a type in a debug statement in trees.c

- Change search and replace delimiter in configure from % to # [Beebe]

- Update contrib/untgz to 0.2 with various fixes [Truta]

- Add build support for Amiga [Nikl]

- Remove some directories in old that have been updated to 1.2

- Add dylib building for Mac OS X in configure and Makefile.in

- Remove old distribution stuff from Makefile

- Update README to point to DLL_FAQ.txt, and add comment on Mac OS X

- Update links in README

Changes in 1.2.0.6 (13 September 2003)

- Minor FAQ updates

- Update contrib/minizip to 1.00 [Vollant]

- Remove test of gz functions in example.c when GZ_COMPRESS defined [Truta]

- Update POSTINC comment for 68060 [Nikl]

- Add contrib/infback9 with deflate64 decoding (unsupported)

- For MVS define NO_vsnprintf and undefine FAR [van Burik]

- Add pragma for fdopen on MVS [van Burik]

Changes in 1.2.0.5 (8 September 2003)

- Add OF to inflateBackEnd() declaration in zlib.h

- Remember start when using gzdopen in the middle of a file

- Use internal off_t counters in gz* functions to properly handle seeks

- Perform more rigorous check for distance-too-far in inffast.c

- Add Z_BLOCK flush option to return from inflate at block boundary

- Set strm->data_type on return from inflate

- Indicate bits unused, if at block boundary, and if in last block

- Replace size_t with ptrdiff_t in crc32.c, and check for correct size

- Add condition so old NO_DEFLATE define still works for compatibility

- FAQ update regarding the Windows DLL [Truta]

- INDEX update: add qnx entry, remove aix entry [Truta]

- Install zlib.3 into mandir [Wilson]

- Move contrib/zlib_dll_FAQ.txt to win32/DLL_FAQ.txt; update [Truta]

- Adapt the zlib interface to the new DLL convention guidelines [Truta]

- Introduce ZLIB_WINAPI macro to allow the export of functions using

the WINAPI calling convention, for Visual Basic [Vollant, Truta]

- Update msdos and win32 scripts and makefiles [Truta]

- Export symbols by name, not by ordinal, in win32/zlib.def [Truta]

- Add contrib/ada [Anisimkov]

- Move asm files from contrib/vstudio/vc70_32 to contrib/asm386 [Truta]

- Rename contrib/asm386 to contrib/masmx86 [Truta, Vollant]

- Add contrib/masm686 [Truta]

- Fix offsets in contrib/inflate86 and contrib/masmx86/inffas32.asm

[Truta, Vollant]

- Update contrib/delphi; rename to contrib/pascal; add example [Truta]

- Remove contrib/delphi2; add a new contrib/delphi [Truta]

- Avoid inclusion of the nonstandard in contrib/iostream,

and fix some method prototypes [Truta]

- Fix the ZCR_SEED2 constant to avoid warnings in contrib/minizip

[Truta]

- Avoid the use of backslash (\) in contrib/minizip [Vollant]

- Fix file time handling in contrib/untgz; update makefiles [Truta]

- Update contrib/vstudio/vc70_32 to comply with the new DLL guidelines

[Vollant]

- Remove contrib/vstudio/vc15_16 [Vollant]

- Rename contrib/vstudio/vc70_32 to contrib/vstudio/vc7 [Truta]

- Update README.contrib [Truta]

- Invert the assignment order of match_head and s->prev[...] in

INSERT_STRING [Truta]

- Compare TOO_FAR with 32767 instead of 32768, to avoid 16-bit warnings

[Truta]

- Compare function pointers with 0, not with NULL or Z_NULL [Truta]

- Fix prototype of syncsearch in inflate.c [Truta]

- Introduce ASMINF macro to be enabled when using an ASM implementation

of inflate_fast [Truta]

- Change NO_DEFLATE to NO_GZCOMPRESS [Truta]

- Modify test_gzio in example.c to take a single file name as a

parameter [Truta]

- Exit the example.c program if gzopen fails [Truta]

- Add type casts around strlen in example.c [Truta]

- Remove casting to sizeof in minigzip.c; give a proper type

to the variable compared with SUFFIX_LEN [Truta]

- Update definitions of STDC and STDC99 in zconf.h [Truta]

- Synchronize zconf.h with the new Windows DLL interface [Truta]

- Use SYS16BIT instead of __32BIT__ to distinguish between

16- and 32-bit platforms [Truta]

- Use far memory allocators in small 16-bit memory models for

Turbo C [Truta]

- Add info about the use of ASMV, ASMINF and ZLIB_WINAPI in

zlibCompileFlags [Truta]

- Cygwin has vsnprintf [Wilson]

- In Windows16, OS_CODE is 0, as in MSDOS [Truta]

- In Cygwin, OS_CODE is 3 (Unix), not 11 (Windows32) [Wilson]

Changes in 1.2.0.4 (10 August 2003)

- Minor FAQ updates

- Be more strict when checking inflateInit2's windowBits parameter

- Change NO_GUNZIP compile option to NO_GZIP to cover deflate as well

- Add gzip wrapper option to deflateInit2 using windowBits

- Add updated QNX rule in configure and qnx directory [Bonnefoy]

- Make inflate distance-too-far checks more rigorous

- Clean up FAR usage in inflate

- Add casting to sizeof() in gzio.c and minigzip.c

Changes in 1.2.0.3 (19 July 2003)

- Fix silly error in gzungetc() implementation [Vollant]

- Update contrib/minizip and contrib/vstudio [Vollant]

- Fix printf format in example.c

- Correct cdecl support in zconf.in.h [Anisimkov]

- Minor FAQ updates

Changes in 1.2.0.2 (13 July 2003)

- Add ZLIB_VERNUM in zlib.h for numerical preprocessor comparisons

- Attempt to avoid warnings in crc32.c for pointer-int conversion

- Add AIX to configure, remove aix directory [Bakker]

- Add some casts to minigzip.c

- Improve checking after insecure sprintf() or vsprintf() calls

- Remove #elif's from crc32.c

- Change leave label to inf_leave in inflate.c and infback.c to avoid

library conflicts

- Remove inflate gzip decoding by default--only enable gzip decoding by

special request for stricter backward compatibility

- Add zlibCompileFlags() function to return compilation information

- More typecasting in deflate.c to avoid warnings

- Remove leading underscore from _Capital #defines [Truta]

- Fix configure to link shared library when testing

- Add some Windows CE target adjustments [Mai]

- Remove #define ZLIB_DLL in zconf.h [Vollant]

- Add zlib.3 [Rodgers]

- Update RFC URL in deflate.c and algorithm.txt [Mai]

- Add zlib_dll_FAQ.txt to contrib [Truta]

- Add UL to some constants [Truta]

- Update minizip and vstudio [Vollant]

- Remove vestigial NEED_DUMMY_RETURN from zconf.in.h

- Expand use of NO_DUMMY_DECL to avoid all dummy structures

- Added iostream3 to contrib [Schwardt]

- Replace rewind() with fseek() for WinCE [Truta]

- Improve setting of zlib format compression level flags

- Report 0 for huffman and rle strategies and for level == 0 or 1

- Report 2 only for level == 6

- Only deal with 64K limit when necessary at compile time [Truta]

- Allow TOO_FAR check to be turned off at compile time [Truta]

- Add gzclearerr() function [Souza]

- Add gzungetc() function

Changes in 1.2.0.1 (17 March 2003)

- Add Z_RLE strategy for run-length encoding [Truta]

- When Z_RLE requested, restrict matches to distance one

- Update zlib.h, minigzip.c, gzopen(), gzdopen() for Z_RLE

- Correct FASTEST compilation to allow level == 0

- Clean up what gets compiled for FASTEST

- Incorporate changes to zconf.in.h [Vollant]

- Refine detection of Turbo C need for dummy returns

- Refine ZLIB_DLL compilation

- Include additional header file on VMS for off_t typedef

- Try to use _vsnprintf where it supplants vsprintf [Vollant]

- Add some casts in inffast.c

- Enchance comments in zlib.h on what happens if gzprintf() tries to

write more than 4095 bytes before compression

- Remove unused state from inflateBackEnd()

- Remove exit(0) from minigzip.c, example.c

- Get rid of all those darn tabs

- Add "check" target to Makefile.in that does the same thing as "test"

- Add "mostlyclean" and "maintainer-clean" targets to Makefile.in

- Update contrib/inflate86 [Anderson]

- Update contrib/testzlib, contrib/vstudio, contrib/minizip [Vollant]

- Add msdos and win32 directories with makefiles [Truta]

- More additions and improvements to the FAQ

Changes in 1.2.0 (9 March 2003)

- New and improved inflate code

- About 20% faster

- Does not allocate 32K window unless and until needed

- Automatically detects and decompresses gzip streams

- Raw inflate no longer needs an extra dummy byte at end

- Added inflateBack functions using a callback interface--even faster

than inflate, useful for file utilities (gzip, zip)

- Added inflateCopy() function to record state for random access on

externally generated deflate streams (e.g. in gzip files)

- More readable code (I hope)

- New and improved crc32()

- About 50% faster, thanks to suggestions from Rodney Brown

- Add deflateBound() and compressBound() functions

- Fix memory leak in deflateInit2()

- Permit setting dictionary for raw deflate (for parallel deflate)

- Fix const declaration for gzwrite()

- Check for some malloc() failures in gzio.c

- Fix bug in gzopen() on single-byte file 0x1f

- Fix bug in gzread() on concatenated file with 0x1f at end of buffer

and next buffer doesn't start with 0x8b

- Fix uncompress() to return Z_DATA_ERROR on truncated input

- Free memory at end of example.c

- Remove MAX #define in trees.c (conflicted with some libraries)

- Fix static const's in deflate.c, gzio.c, and zutil.[ch]

- Declare malloc() and free() in gzio.c if STDC not defined

- Use malloc() instead of calloc() in zutil.c if int big enough

- Define STDC for AIX

- Add aix/ with approach for compiling shared library on AIX

- Add HP-UX support for shared libraries in configure

- Add OpenUNIX support for shared libraries in configure

- Use $cc instead of gcc to build shared library

- Make prefix directory if needed when installing

- Correct Macintosh avoidance of typedef Byte in zconf.h

- Correct Turbo C memory allocation when under Linux

- Use libz.a instead of -lz in Makefile (assure use of compiled library)

- Update configure to check for snprintf or vsnprintf functions and their

return value, warn during make if using an insecure function

- Fix configure problem with compile-time knowledge of HAVE_UNISTD_H that

is lost when library is used--resolution is to build new zconf.h

- Documentation improvements (in zlib.h):

- Document raw deflate and inflate

- Update RFCs URL

- Point out that zlib and gzip formats are different

- Note that Z_BUF_ERROR is not fatal

- Document string limit for gzprintf() and possible buffer overflow

- Note requirement on avail_out when flushing

- Note permitted values of flush parameter of inflate()

- Add some FAQs (and even answers) to the FAQ

- Add contrib/inflate86/ for x86 faster inflate

- Add contrib/blast/ for PKWare Data Compression Library decompression

- Add contrib/puff/ simple inflate for deflate format description

Changes in 1.1.4 (11 March 2002)

- ZFREE was repeated on same allocation on some error conditions.

This creates a security problem described in

http://www.zlib.org/advisory-2002-03-11.txt

- Returned incorrect error (Z_MEM_ERROR) on some invalid data

- Avoid accesses before window for invalid distances with inflate window

less than 32K.

- force windowBits > 8 to avoid a bug in the encoder for a window size

of 256 bytes. (A complete fix will be available in 1.1.5).

Changes in 1.1.3 (9 July 1998)

- fix "an inflate input buffer bug that shows up on rare but persistent

occasions" (Mark)

- fix gzread and gztell for concatenated .gz files (Didier Le Botlan)

- fix gzseek(..., SEEK_SET) in write mode

- fix crc check after a gzeek (Frank Faubert)

- fix miniunzip when the last entry in a zip file is itself a zip file

(J Lillge)

- add contrib/asm586 and contrib/asm686 (Brian Raiter)

See http://www.muppetlabs.com/~breadbox/software/assembly.html

- add support for Delphi 3 in contrib/delphi (Bob Dellaca)

- add support for C++Builder 3 and Delphi 3 in contrib/delphi2 (Davide Moretti)

- do not exit prematurely in untgz if 0 at start of block (Magnus Holmgren)

- use macro EXTERN instead of extern to support DLL for BeOS (Sander Stoks)

- added a FAQ file

- Support gzdopen on Mac with Metrowerks (Jason Linhart)

- Do not redefine Byte on Mac (Brad Pettit & Jason Linhart)

- define SEEK_END too if SEEK_SET is not defined (Albert Chin-A-Young)

- avoid some warnings with Borland C (Tom Tanner)

- fix a problem in contrib/minizip/zip.c for 16-bit MSDOS (Gilles Vollant)

- emulate utime() for WIN32 in contrib/untgz (Gilles Vollant)

- allow several arguments to configure (Tim Mooney, Frodo Looijaard)

- use libdir and includedir in Makefile.in (Tim Mooney)

- support shared libraries on OSF1 V4 (Tim Mooney)

- remove so_locations in "make clean" (Tim Mooney)

- fix maketree.c compilation error (Glenn, Mark)

- Python interface to zlib now in Python 1.5 (Jeremy Hylton)

- new Makefile.riscos (Rich Walker)

- initialize static descriptors in trees.c for embedded targets (Nick Smith)

- use "foo-gz" in example.c for RISCOS and VMS (Nick Smith)

- add the OS/2 files in Makefile.in too (Andrew Zabolotny)

- fix fdopen and halloc macros for Microsoft C 6.0 (Tom Lane)

- fix maketree.c to allow clean compilation of inffixed.h (Mark)

- fix parameter check in deflateCopy (Gunther Nikl)

- cleanup trees.c, use compressed_len only in debug mode (Christian Spieler)

- Many portability patches by Christian Spieler:

. zutil.c, zutil.h: added "const" for zmem*

. Make_vms.com: fixed some typos

. Make_vms.com: msdos/Makefile.*: removed zutil.h from some dependency lists

. msdos/Makefile.msc: remove "default rtl link library" info from obj files

. msdos/Makefile.*: use model-dependent name for the built zlib library

. msdos/Makefile.emx, nt/Makefile.emx, nt/Makefile.gcc:

new makefiles, for emx (DOS/OS2), emx&rsxnt and mingw32 (Windows 9x / NT)

- use define instead of typedef for Bytef also for MSC small/medium (Tom Lane)

- replace __far with _far for better portability (Christian Spieler, Tom Lane)

- fix test for errno.h in configure (Tim Newsham)

Changes in 1.1.2 (19 March 98)

- added contrib/minzip, mini zip and unzip based on zlib (Gilles Vollant)

See http://www.winimage.com/zLibDll/unzip.html

- preinitialize the inflate tables for fixed codes, to make the code

completely thread safe (Mark)

- some simplifications and slight speed-up to the inflate code (Mark)

- fix gzeof on non-compressed files (Allan Schrum)

- add -std1 option in configure for OSF1 to fix gzprintf (Martin Mokrejs)

- use default value of 4K for Z_BUFSIZE for 16-bit MSDOS (Tim Wegner + Glenn)

- added os2/Makefile.def and os2/zlib.def (Andrew Zabolotny)

- add shared lib support for UNIX_SV4.2MP (MATSUURA Takanori)

- do not wrap extern "C" around system includes (Tom Lane)

- mention zlib binding for TCL in README (Andreas Kupries)

- added amiga/Makefile.pup for Amiga powerUP SAS/C PPC (Andreas Kleinert)

- allow "make install prefix=..." even after configure (Glenn Randers-Pehrson)

- allow "configure --prefix $HOME" (Tim Mooney)

- remove warnings in example.c and gzio.c (Glenn Randers-Pehrson)

- move Makefile.sas to amiga/Makefile.sas

Changes in 1.1.1 (27 Feb 98)

- fix macros _tr_tally_* in deflate.h for debug mode (Glenn Randers-Pehrson)

- remove block truncation heuristic which had very marginal effect for zlib

(smaller lit_bufsize than in gzip 1.2.4) and degraded a little the

compression ratio on some files. This also allows inlining _tr_tally for

matches in deflate_slow.

- added msdos/Makefile.w32 for WIN32 Microsoft Visual C++ (Bob Frazier)

Changes in 1.1.0 (24 Feb 98)

- do not return STREAM_END prematurely in inflate (John Bowler)

- revert to the zlib 1.0.8 inflate to avoid the gcc 2.8.0 bug (Jeremy Buhler)

- compile with -DFASTEST to get compression code optimized for speed only

- in minigzip, try mmap'ing the input file first (Miguel Albrecht)

- increase size of I/O buffers in minigzip.c and gzio.c (not a big gain

on Sun but significant on HP)

- add a pointer to experimental unzip library in README (Gilles Vollant)

- initialize variable gcc in configure (Chris Herborth)

Changes in 1.0.9 (17 Feb 1998)

- added gzputs and gzgets functions

- do not clear eof flag in gzseek (Mark Diekhans)

- fix gzseek for files in transparent mode (Mark Diekhans)

- do not assume that vsprintf returns the number of bytes written (Jens Krinke)

- replace EXPORT with ZEXPORT to avoid conflict with other programs

- added compress2 in zconf.h, zlib.def, zlib.dnt

- new asm code from Gilles Vollant in contrib/asm386

- simplify the inflate code (Mark):

. Replace ZALLOC's in huft_build() with single ZALLOC in inflate_blocks_new()

. ZALLOC the length list in inflate_trees_fixed() instead of using stack

. ZALLOC the value area for huft_build() instead of using stack

. Simplify Z_FINISH check in inflate()

- Avoid gcc 2.8.0 comparison bug a little differently than zlib 1.0.8

- in inftrees.c, avoid cc -O bug on HP (Farshid Elahi)

- in zconf.h move the ZLIB_DLL stuff earlier to avoid problems with

the declaration of FAR (Gilles VOllant)

- install libz.so* with mode 755 (executable) instead of 644 (Marc Lehmann)

- read_buf buf parameter of type Bytef* instead of charf*

- zmemcpy parameters are of type Bytef*, not charf* (Joseph Strout)

- do not redeclare unlink in minigzip.c for WIN32 (John Bowler)

- fix check for presence of directories in "make install" (Ian Willis)

Changes in 1.0.8 (27 Jan 1998)

- fixed offsets in contrib/asm386/gvmat32.asm (Gilles Vollant)

- fix gzgetc and gzputc for big endian systems (Markus Oberhumer)

- added compress2() to allow setting the compression level

- include sys/types.h to get off_t on some systems (Marc Lehmann & QingLong)

- use constant arrays for the static trees in trees.c instead of computing

them at run time (thanks to Ken Raeburn for this suggestion). To create

trees.h, compile with GEN_TREES_H and run "make test".

- check return code of example in "make test" and display result

- pass minigzip command line options to file_compress

- simplifying code of inflateSync to avoid gcc 2.8 bug

- support CC="gcc -Wall" in configure -s (QingLong)

- avoid a flush caused by ftell in gzopen for write mode (Ken Raeburn)

- fix test for shared library support to avoid compiler warnings

- zlib.lib -> zlib.dll in msdos/zlib.rc (Gilles Vollant)

- check for TARGET_OS_MAC in addition to MACOS (Brad Pettit)

- do not use fdopen for Metrowerks on Mac (Brad Pettit))

- add checks for gzputc and gzputc in example.c

- avoid warnings in gzio.c and deflate.c (Andreas Kleinert)

- use const for the CRC table (Ken Raeburn)

- fixed "make uninstall" for shared libraries

- use Tracev instead of Trace in infblock.c

- in example.c use correct compressed length for test_sync

- suppress +vnocompatwarnings in configure for HPUX (not always supported)

Changes in 1.0.7 (20 Jan 1998)

- fix gzseek which was broken in write mode

- return error for gzseek to negative absolute position

- fix configure for Linux (Chun-Chung Chen)

- increase stack space for MSC (Tim Wegner)

- get_crc_table and inflateSyncPoint are EXPORTed (Gilles Vollant)

- define EXPORTVA for gzprintf (Gilles Vollant)

- added man page zlib.3 (Rick Rodgers)

- for contrib/untgz, fix makedir() and improve Makefile

- check gzseek in write mode in example.c

- allocate extra buffer for seeks only if gzseek is actually called

- avoid signed/unsigned comparisons (Tim Wegner, Gilles Vollant)

- add inflateSyncPoint in zconf.h

- fix list of exported functions in nt/zlib.dnt and mdsos/zlib.def

Changes in 1.0.6 (19 Jan 1998)

- add functions gzprintf, gzputc, gzgetc, gztell, gzeof, gzseek, gzrewind and

gzsetparams (thanks to Roland Giersig and Kevin Ruland for some of this code)

- Fix a deflate bug occuring only with compression level 0 (thanks to

Andy Buckler for finding this one).

- In minigzip, pass transparently also the first byte for .Z files.

- return Z_BUF_ERROR instead of Z_OK if output buffer full in uncompress()

- check Z_FINISH in inflate (thanks to Marc Schluper)

- Implement deflateCopy (thanks to Adam Costello)

- make static libraries by default in configure, add --shared option.

- move MSDOS or Windows specific files to directory msdos

- suppress the notion of partial flush to simplify the interface

(but the symbol Z_PARTIAL_FLUSH is kept for compatibility with 1.0.4)

- suppress history buffer provided by application to simplify the interface

(this feature was not implemented anyway in 1.0.4)

- next_in and avail_in must be initialized before calling inflateInit or

inflateInit2

- add EXPORT in all exported functions (for Windows DLL)

- added Makefile.nt (thanks to Stephen Williams)

- added the unsupported "contrib" directory:

contrib/asm386/ by Gilles Vollant

386 asm code replacing longest_match().

contrib/iostream/ by Kevin Ruland

A C++ I/O streams interface to the zlib gz* functions

contrib/iostream2/ by Tyge L鴙set

Another C++ I/O streams interface

contrib/untgz/ by "Pedro A. Aranda Guti\irrez"

A very simple tar.gz file extractor using zlib

contrib/visual-basic.txt by Carlos Rios

How to use compress(), uncompress() and the gz* functions from VB.

- pass params -f (filtered data), -h (huffman only), -1 to -9 (compression

level) in minigzip (thanks to Tom Lane)

- use const for rommable constants in deflate

- added test for gzseek and gztell in example.c

- add undocumented function inflateSyncPoint() (hack for Paul Mackerras)

- add undocumented function zError to convert error code to string

(for Tim Smithers)

- Allow compilation of gzio with -DNO_DEFLATE to avoid the compression code.

- Use default memcpy for Symantec MSDOS compiler.

- Add EXPORT keyword for check_func (needed for Windows DLL)

- add current directory to LD_LIBRARY_PATH for "make test"

- create also a link for libz.so.1

- added support for FUJITSU UXP/DS (thanks to Toshiaki Nomura)

- use $(SHAREDLIB) instead of libz.so in Makefile.in (for HPUX)

- added -soname for Linux in configure (Chun-Chung Chen,

- assign numbers to the exported functions in zlib.def (for Windows DLL)

- add advice in zlib.h for best usage of deflateSetDictionary

- work around compiler bug on Atari (cast Z_NULL in call of s->checkfn)

- allow compilation with ANSI keywords only enabled for TurboC in large model

- avoid "versionString"[0] (Borland bug)

- add NEED_DUMMY_RETURN for Borland

- use variable z_verbose for tracing in debug mode (L. Peter Deutsch).

- allow compilation with CC

- defined STDC for OS/2 (David Charlap)

- limit external names to 8 chars for MVS (Thomas Lund)

- in minigzip.c, use static buffers only for 16-bit systems

- fix suffix check for "minigzip -d foo.gz"

- do not return an error for the 2nd of two consecutive gzflush() (Felix Lee)

- use _fdopen instead of fdopen for MSC >= 6.0 (Thomas Fanslau)

- added makelcc.bat for lcc-win32 (Tom St Denis)

- in Makefile.dj2, use copy and del instead of install and rm (Frank Donahoe)

- Avoid expanded $Id$. Use "rcs -kb" or "cvs admin -kb" to avoid Id expansion.

- check for unistd.h in configure (for off_t)

- remove useless check parameter in inflate_blocks_free

- avoid useless assignment of s->check to itself in inflate_blocks_new

- do not flush twice in gzclose (thanks to Ken Raeburn)

- rename FOPEN as F_OPEN to avoid clash with /usr/include/sys/file.h

- use NO_ERRNO_H instead of enumeration of operating systems with errno.h

- work around buggy fclose on pipes for HP/UX

- support zlib DLL with BORLAND C++ 5.0 (thanks to Glenn Randers-Pehrson)

- fix configure if CC is already equal to gcc

Changes in 1.0.5 (3 Jan 98)

- Fix inflate to terminate gracefully when fed corrupted or invalid data

- Use const for rommable constants in inflate

- Eliminate memory leaks on error conditions in inflate

- Removed some vestigial code in inflate

- Update web address in README

呵呵,显然,后继版本修改了大量的bug,并较大幅度地提升了性能。那么我们如何在Delphi使用最新的版本呢?一个就是从一个志愿者的网站(http://www.base2ti.com/zlib.htm)上得到他编译的较新版本及封装zlibex.pas;另一个方式就是在前者的基础上自己动手,丰衣足食。

Zlib主页上公布的最新版是1.2.2,如果你只需要这个版本的话,在上面的网站就可以直接得到了;其实在zlib的邮件列表中会不定期的放出修正中的最新版本,现在最新版本就是1.2.2.3(http://alumnus.caltech.edu/~madler/zlib-1.2.2.3.tar.gz)。

其实自己动手也很简单,把源码解开后,用C++Builder的编译器编译一次,如把

adler32.obj

compress.obj

crc32.obj

deflate.obj

infback.obj

inffast.obj

inflate.obj

inftrees.obj

trees.obj

uncompr.obj

zutil.obj

这11个obj文件覆盖上面那个志愿者编译的zlibex中带的这11个obj文件即可。

编译命令行如下:

bcc32 -O2 -Ve -X- -pr -a8 -b -d -k- -vi -tWM *.c

好了,自己去编个测试程序比较一下与Delphi自带的zlib的性能差异吧,不要太开心落。

使用时,需要Zlib.pas和 Zlibconst.pas两个单元文件,这两个文件保存在 Delphi 5.0安装光盘上 InfoExtrasZlib目录下,此外,在 InfoExtrasZlibObj目录中还保存了 Zlib.pas单元引用的 Obj文件,把这个目录拷贝到delphi的lib下,即可。可以适当的改动比如增加目录压缩和分文件压缩,其实就是在文件流前面增加一部分描述结构就是,不多说。使用 时,还要use zlib单元。 两个函数如下:

procedure CompressIt(var CompressedStream: TMemoryStream; const CompressionLevel: TCompressionLevel);

// 参数是传递的流和压缩方式

var

SourceStream: TCompressionStream;

DestStream: TMemoryStream;

Count: int64; //注意,此处修改了,原来是int

begin

//获得流的原始尺寸

Count := CompressedStream.Size;

DestStream := TMemoryStream.Create;

SourceStream := TCompressionStream.Create(CompressionLevel, DestStream);

try

//SourceStream中保存着原始的流

CompressedStream.SaveToStream(SourceStream);

//将原始流进行压缩, DestStream中保存着压缩后的流

SourceStream.Free;

CompressedStream.Clear;

//写入原始图像的尺寸

CompressedStream.WriteBuffer(Count, SizeOf(Count));

//写入经过压缩的流

CompressedStream.CopyFrom(DestStream, 0);

finally

DestStream.Free;

end;

end;

procedure UnCompressit(const CompressedStream: TMemoryStream; var UnCompressedStream: TMemoryStream);

//参数 压缩过的流,解压后的流

var

SourceStream: TDecompressionStream;

DestStream: TMemoryStream;

Buffer: PChar;

Count: int64;

begin

//从被压缩的图像流中读出原始的尺寸

CompressedStream.ReadBuffer(Count, SizeOf(Count));

//根据尺寸大小为将要读入的原始流分配内存块

GetMem(Buffer, Count);

DestStream := TMemoryStream.Create;

SourceStream := TDecompressionStream.Create(CompressedStream);

try

//将被压缩的流解压缩,然后存入 Buffer内存块中

SourceStream.ReadBuffer(Buffer^, Count);

//将原始流保存至 DestStream流中

DestStream.WriteBuffer(Buffer^, Count);

DestStream.Position := 0; //复位流指针

DestStream.Position := length(VER_INFO);

//从DestStream流中载入图像流

UnCompressedStream.LoadFromStream(DestStream);

finally

FreeMem(Buffer);

DestStream.Free;

end;

end;

使用的例子如下:

procedure TForm1.Button5Click(Sender: TObject);

//把指定文件压缩然后保存为另外一个压缩包,

//呵呵,我使用的时候是把后缀改成cab,可以唬一些人吧?

var

SM: TMemoryStream;

begin

if OpenDialog1.Execute then

begin

if SaveDialog1.Execute then

begin

SM := TMemoryStream.Create;

try

Sm.LoadFromFile(OpenDialog1.FileName);

SM.Position := 0;

Compressit(sm, clDefault);

sm.SaveToFile(SaveDialog1.FileName);

finally

SM.Free;

end;

end;

end;

end;

procedure TForm1.BitBtn2Click(Sender: TObject);

//把指定的压缩包解成原来的文件。

var

SM, DM: TMemoryStream;

begin

if OpenDialog1.Execute then

begin

if SaveDialog1.Execute then

begin

SM := TMemoryStream.Create;

DM := TMemoryStream.Create;

try

Sm.LoadFromFile(OpenDialog1.FileName);

SM.Position := 0;

UnCompressit(sm, dm);

dm.Position := 0;

dm.SaveToFile(SaveDialog1.FileName);

finally

SM.Free;

DM.Free;

end;

end;

end;

end;

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值