Code: Select all
/*
Compresses according to the zlib specification and append the compressed
result to the output.
options: global program options
out: pointer to the dynamic output array to which the result is appended. Must
be freed after use.
outsize: pointer to the dynamic output array size.
*/
void ZopfliZlibCompress(const ZopfliOptions* options,
const unsigned char* in, size_t insize,
unsigned char** out, size_t* outsize);
My code looks like:
Code: Select all
VarSetCapacity(options,24,0)
NumPut(0,&options,0,"Int") ; verbose
NumPut(0,&options,4,"Int") ; verbose_more
NumPut(Settings.zopfliIterations,&options,8,"Int") ; numiterations
NumPut(1,&options,12,"Int") ; blocksplitting
NumPut(0,&options,16,"Int") ; blocksplittinglast
NumPut(15,&options,20,"Int") ; blocksplittingmax
insize:=this.Stats.FileSize
VarSetCapacity(out,DllCall(PS_DirArch "\zlib1.dll\compressBound","UInt",insize,"Cdecl"))
out:=0
outsize:=0
VarSetCapacity(outptr,A_PtrSize) ; ZopfliZlibCompress function wants a pointer to a pointer to the first byte of the "out" variable.
NumPut(&out,outptr,0,"ptr")
DllCall(PS_DirArch "\libzopfli.dll\ZopfliZlibCompress","ptr",&options,"ptr",this.GetAddress("Raw"),"UInt",insize,"ptr",&outptr,"UIntP",outsize,"Cdecl")
OffsetToOut:=NumGet(outptr,0,"ptr")
;Then I read the data at 'OffsetToOut' of size 'outsize' using a wrapper around NumGet()
TIA,
Sam.