Delphi Database, Delphi Components from ComponentAce
Products Download Order Contact us
/img/help/home.gif

 

Compressing any data stream on the fly: Example

 


 

The following example compresses the data from the Notes field of Table1 to the Remarks field of Table2 and then decompresses it back.

 

procedure TForm1.Button1Click(Sender: TObject);

var

Stream1, Stream2 : TBlobStream;

ECLStream: TECLStream;

begin

Stream1 := TBlobStream.Create(Table1Notes, bmRead);

try

Table2.Edit;

Stream2 := Table2.CreateBlobStream(Table2.FieldByName('Remarks'), bmReadWrite);

{ create ECL stream providing transparent compression to Stream2 }

ECLStream := TECLStream.Create(Stream2, true, '', bzipFastest);

try

{ copy with transparent compression }

ECLStream.LoadFromStream(Stream1);

Table2.Post;

finally

ECLStream.Free;

Stream2.Free;

end;

finally

Stream1.Free;

end;

 

Stream1 := TBlobStream.Create(Table2.FieldByName('Remarks'), bmRead);

{ create ECL stream providing transparent decompression from Stream1 }

ECLStream := TECLStream.Create(Stream1);

try

Table1.Edit;

Stream2 := Table1.CreateBlobStream(Table1Notes, bmReadWrite);

try

{ copy with transparent decompression }

Stream2.CopyFrom(ECLStream, ECLStream.Size);

Table1.Post;

finally

Stream2.Free;

end;

finally

ECLStream.Free;

Stream1.Free;

end;

end;

        © 2003 - 2017 ComponentAce  | .net zip component | barcode for .net | delphi zip component | delphi database Nov 25, 2017