From: "Mike Orriss (TeamB)" Subject: Re: Help with ZLib....Desperate, as usual. :-) Date: 07 Jan 2000 00:00:00 GMT Message-ID: Content-Transfer-Encoding: 8bit References: <8532ta$qmo2@bornews.borland.com> Content-Type: text/plain; charset=iso-8859-1 Organization: 3K Computer Consultancy Mime-Version: 1.0 Reply-To: mjo@3kcc.co.uk Newsgroups: borland.public.delphi.graphics,borland.public.delphi.objectpascal,borland.public.teamsource In article <8532ta$qmo2@bornews.borland.com>, Travis Elkins wrote: > Thanks in advance for any help you might be able to offer. > It is too late (after midnight) for me to follow the code that you have posted, but the following two routines may help you. They are generic and assume that the input & output streams have already been created: procedure CompressStream(inpStream,outStream: TStream); var InpBuf,OutBuf: Pointer; var InpBytes,OutBytes: integer; begin InpBuf := nil; OutBuf := nil; try GetMem(InpBuf,inpStream.size); inpStream.Position := 0; InpBytes := inpStream.Read(InpBuf^,inpStream.size); CompressBuf(InpBuf,InpBytes,OutBuf,OutBytes); outStream.Write(OutBuf^,OutBytes); finally if InpBuf <> nil then FreeMem(InpBuf); if OutBuf <> nil then FreeMem(OutBuf); end; end; procedure ExpandStream(inpStream,outStream: TStream); var InpBuf,OutBuf: Pointer; var OutBytes,sz: integer; begin InpBuf := nil; OutBuf := nil; sz := inpStream.size-inpStream.Position; if sz > 0 then try GetMem(InpBuf,sz); inpStream.Read(InpBuf^,sz); DecompressBuf(InpBuf,sz,0,OutBuf,OutBytes); outStream.Write(OutBuf^,OutBytes); finally if InpBuf <> nil then FreeMem(InpBuf); if OutBuf <> nil then FreeMem(OutBuf); end; outStream.Position := 0; end; Just add zlib to your uses statement in order to gain access to CompressBuf & DecompressBuf. A point to note: CompressStream acts upon the whole stream while ExpandStream acts from the current position. That suits me but obviously it is simple to change as you wish. Mike Orriss (TeamB) (Unless stated otherwise, my replies relate to Delphi 4.03/5.00) (Unsolicited e-mail replies will most likely be ignored)