Just a little modification of wilberts code: manual import of the deflate and inflate functions from a lib without making use of ImagePluginPNG.
Code:
ImportC "zlib.lib"
inflateInit(*strm.l,*version.l,stream_size.l) As "_inflateInit_@12"
inflate(*strm.l,flush.l) As "_inflate@8"
inflateEnd(*strm.l) As "_inflateEnd@4"
deflateInit(*strm.l,level.l,*version.l,stream_size.l) As "_deflateInit_@16"
deflate(*strm.l,flush.l) As "_deflate@8"
deflateEnd(*strm.l) As "_deflateEnd@4"
EndImport
Structure zstream
next_in.l
avail_in.l
total_in.l
next_out.l
avail_out.l
total_out.l
msg.l
state.l
zalloc.l
zfree.l
opaque.l
data_type.l
adler.l
reserved.l
EndStructure
#Z_OK = 0
#Z_STREAM_END = 1
#Z_NEED_DICT = 2
#Z_ERRNO = -1
#Z_STREAM_ERROR = -2
#Z_DATA_ERROR = -3
#Z_MEM_ERROR = -4
#Z_BUF_ERROR = -5
#Z_VERSION_ERROR = -6
#Z_NO_FLUSH = 0
#Z_PARTIAL_FLUSH = 1
#Z_SYNC_FLUSH = 2
#Z_FULL_FLUSH = 3
#Z_FINISH = 4
#Z_BLOCK = 5
Global version$ ="1.2.3"
Procedure.l Z_Compress(*dest.l,*destLen.l,*source.l,sourceLen.l)
Static strm.zstream
strm\next_in = *source
strm\avail_in = sourceLen
strm\next_out = *dest
strm\avail_out = *destLen
strm\zalloc = #Null
strm\zfree = #Null
strm\opaque = #Null
Static err.l
err.l = deflateInit(@strm,-1,@version$,SizeOf(zstream))
If err <> 0
ProcedureReturn err
EndIf
err = deflate(@strm,#Z_FINISH)
If err <> 1
deflateEnd(@strm)
If err = 0
ProcedureReturn #Z_BUF_ERROR
Else
ProcedureReturn err
EndIf
EndIf
PokeL(*destLen,strm\total_out)
ProcedureReturn deflateEnd(@strm)
EndProcedure
Procedure.l Z_Uncompress(*dest.l,*destLen.l,*source.l,sourceLen.l)
Static strm.zstream
strm\next_in = *source
strm\avail_in = sourceLen
strm\next_out = *dest
strm\avail_out = *destLen
strm\zalloc = #Null
strm\zfree = #Null
strm\opaque = #Null
Static err.l
err.l = inflateInit(@strm,@version$,SizeOf(zstream))
If err <> 0
ProcedureReturn err
EndIf
err = inflate(@strm,#Z_FINISH)
If err <> 1
inflateEnd(@strm)
If err = 0
ProcedureReturn #Z_BUF_ERROR
Else
ProcedureReturn err
EndIf
EndIf
PokeL(*destLen,strm\total_out)
ProcedureReturn inflateEnd(@strm)
EndProcedure
; see if it works
in = AllocateMemory(100)
out = AllocateMemory(100)
s.s = "Hello hello hello hello hello hello hello hello hello hello hello"
PokeS(in,s)
Debug "Uncompressed: " + PeekS(@s)
insize.l = Len(s)
outsize.l = MemorySize(out)
Debug Z_Compress(out,@outsize,in,insize)
Debug "Compressed: "+ PeekS(out,outsize)
Swap in, out
insize.l = outsize
outsize = MemorySize(out)
Debug Z_Uncompress(out,@outsize,in,insize)
Debug "Uncompressed: "+ PeekS(out,outsize)