X-Git-Url: https://deadsoftware.ru/gitweb?a=blobdiff_plain;f=src%2Flib%2Fvampimg%2FZLib%2Fdzlib.pas;h=337f310ecbb107946d9c2710c62f465a279b13da;hb=b55db3de3f8db2e7d30aec8bd2e54e812ccbd06e;hp=72031aa9d1a87141b3f94086549d096e7afaae1e;hpb=8f815647c61a98e32b85066bf245b262694ac634;p=d2df-sdl.git diff --git a/src/lib/vampimg/ZLib/dzlib.pas b/src/lib/vampimg/ZLib/dzlib.pas index 72031aa..337f310 100644 --- a/src/lib/vampimg/ZLib/dzlib.pas +++ b/src/lib/vampimg/ZLib/dzlib.pas @@ -41,47 +41,47 @@ unit dzlib; -{$I ImagingOptions.inc} +{$I ../ImagingOptions.inc} interface -{ $DEFINE ZLIBEX} -{ $DEFINE DELPHIZLIB} -{ $DEFINE ZLIBPAS} {$DEFINE IMPASZLIB} +{ $DEFINE ZLIBPAS} { $DEFINE FPCPASZLIB} +{ $DEFINE ZLIBEX} +{ $DEFINE DELPHIZLIB} -{ Automatically use FPC's PasZLib when compiling with Lazarus.} +{ Automatically use FPC's PasZLib when compiling with FPC.} -{$IFDEF LCL} +{$IFDEF FPC} {$UNDEF IMPASZLIB} {$DEFINE FPCPASZLIB} {$ENDIF} uses -{$IF Defined(ZLIBEX)} - { Use ZlibEx unit.} - ZLibEx, -{$ELSEIF Defined(DELPHIZLIB)} - { Use ZLib unit shipped with Delphi.} - ZLib, -{$ELSEIF Defined(ZLIBPAS)} - { Pascal interface to ZLib shipped with ZLib C source.} - zlibpas, -{$ELSEIF Defined(IMPASZLIB)} - { Use paszlib modified by me for Delphi and FPC.} +{$IF Defined(IMPASZLIB)} + { Use paszlib modified by me for Delphi and FPC } imzdeflate, imzinflate, impaszlib, {$ELSEIF Defined(FPCPASZLIB)} - { Use FPC's paszlib.} + { Use FPC's paszlib } zbase, paszlib, +{$ELSEIF Defined(ZLIBPAS)} + { Pascal interface to ZLib shipped with ZLib C source } + zlibpas, +{$ELSEIF Defined(ZLIBEX)} + { Use ZlibEx unit } + ZLibEx, +{$ELSEIF Defined(DELPHIZLIB)} + { Use ZLib unit shipped with Delphi } + ZLib, {$IFEND} - SysUtils, Classes; + ImagingTypes, SysUtils, Classes; {$IF Defined(IMPASZLIB) or Defined(FPCPASZLIB) or Defined(ZLIBPAS)} type TZStreamRec = z_stream; {$IFEND} -{$IFDEF ZLIBEX} + const Z_NO_FLUSH = 0; Z_PARTIAL_FLUSH = 1; @@ -114,7 +114,6 @@ const Z_UNKNOWN = 2; Z_DEFLATED = 8; -{$ENDIF} type { Abstract ancestor class } @@ -207,8 +206,9 @@ type Out: OutBuf = ptr to newly allocated buffer containing decompressed data OutBytes = number of bytes in OutBuf } procedure CompressBuf(const InBuf: Pointer; InBytes: Integer; - var OutBuf: Pointer; var OutBytes: Integer; - CompressLevel: Integer = Z_DEFAULT_COMPRESSION); + var OutBuf: Pointer; var OutBytes: Integer; + CompressLevel: Integer = Z_DEFAULT_COMPRESSION; + CompressStrategy: Integer = Z_DEFAULT_STRATEGY); { DecompressBuf decompresses data, buffer to buffer, in one call. In: InBuf = ptr to compressed data @@ -265,8 +265,8 @@ begin end; procedure CompressBuf(const InBuf: Pointer; InBytes: Integer; - var OutBuf: Pointer; var OutBytes: Integer; - CompressLevel: Integer); + var OutBuf: Pointer; var OutBytes: Integer; + CompressLevel, CompressStrategy: Integer); var strm: TZStreamRec; P: Pointer; @@ -283,14 +283,17 @@ begin strm.avail_in := InBytes; strm.next_out := OutBuf; strm.avail_out := OutBytes; - CCheck(deflateInit_(strm, CompressLevel, zlib_version, sizeof(strm))); + + CCheck(deflateInit2(strm, CompressLevel, Z_DEFLATED, MAX_WBITS, + DEF_MEM_LEVEL, CompressStrategy)); + try while CCheck(deflate(strm, Z_FINISH)) <> Z_STREAM_END do begin P := OutBuf; Inc(OutBytes, 256); ReallocMem(OutBuf, OutBytes); - strm.next_out := Pointer(Integer(OutBuf) + (Integer(strm.next_out) - Integer(P))); + strm.next_out := Pointer(PtrUInt(OutBuf) + (PtrUInt(strm.next_out) - PtrUInt(P))); strm.avail_out := 256; end; finally @@ -334,7 +337,7 @@ begin P := OutBuf; Inc(OutBytes, BufInc); ReallocMem(OutBuf, OutBytes); - strm.next_out := Pointer(Integer(OutBuf) + (Integer(strm.next_out) - Integer(P))); + strm.next_out := Pointer(PtrUInt(OutBuf) + (PtrUInt(strm.next_out) - PtrUInt(P))); strm.avail_out := BufInc; end; finally