Home > Back-end >  Want to use TZCompressionStream to compress the floating-point array, how to do?
Want to use TZCompressionStream to compress the floating-point array, how to do?

Time:11-02

Want to use TZCompressionStream to compress the floating-point array, how should do?? I will read in TMemoryStream floating point array, reuse TZCompressionStream compression, but it is wrong to extract out, the following code
//compression
TMemoryStream * fs=new TMemoryStream ();//to compress the original memory flow
Fs - & gt; Write (f, 4000);//f is a 1000 digital array
Int fsize=0;
Fsize=fs - & gt; The Size;//file size

TMemoryStream * ms=new TMemoryStream ();//to compress the original memory flow
Ms - & gt; Write (& amp; Fsize, sizeof (fsize));//set up receiving flow and write to the original file size

Cs=new TZCompressionStream * TZCompressionStream (ms, zcDefault);
Fs - & gt; SaveToStream (cs);//to compress the data

Ms - & gt; SaveToFile (" F: \ \ 1. Zip ");//save

ShowMessage (" finished ");
The delete cs;
Delete the fs.
The delete ms;

//
TMemoryStream * fs=new TMemoryStream ();//ready to extract the flow
TMemoryStream * ms=new TMemoryStream ();//receive extract data flow
Fs - & gt; LoadFromFile (" F: \ \ 1. Zip ");//must be a compression method generated file
Fs - & gt; The Position=0;
Int fsize=0;
Fs - & gt; ReadBuffer (& amp; Fsize, sizeof (fsize)); The size of the//decompress after
Ms - & gt; SetSize (4000);//set to receive the unpack data flow size

TZDecompressionStream * ds=new TZDecompressionStream (fs);//uncompress flow
Ds - & gt; Read (ms - & gt; The Memory, fsize);//the data store read until after decompression is ready to receive the flow

Float * ff=new float [1000].
Ms - & gt; Read (ff, ms - & gt; The Size);
for(int i=0; i<1000; I++)
{
StringGrid1 - & gt; Cells [2] [I + 1)=ff [I];
Chart1 - & gt; The Series [1] - & gt; AddXY (0.001 * I, ff [I]);
}
Delete the fs.
The delete ms;
Delete the ds;

CodePudding user response:

Have a great god can help you with Chou Chou
  • Related