Re: zlib OpennetCF question
- From: "Sven Rutten" <svenrutten@xxxxxxxxxxx>
- Date: Thu, 4 Oct 2007 12:56:39 +0200
Thanks Chris, I've found it already, sorry.
But another question to that: I want to transmit the compressed byte.
Now my inputbyte has a length of about 38'000, but I cannot know the length of the compressed byte.
You are just declaring it in your code, there as 1024. So as I dont know it, I am using 10'000, as the always produced something between 5'000 and 7'000 compressed.
But my problem is, that I now have a compressed byte with the length of 10'000, and not the "real" size of it, meaning that the last 3-5'000 entries are just empty.
How can I know how long the bytearray really is and redim it?
The same for the uncompressed bytearray after uncompressing. I could submit the length of the original bytearray with it to dim it correctly, but yeah that's not really a good solution...
Thanks a lot
Sven
"<ctacke/>" <ctacke[at]opennetcf[dot]com> schrieb im Newsbeitrag news:eqd$5LiBIHA.748@xxxxxxxxxxxxxxxxxxxxxxx
Directly from the sample that comes with the zlibce download:.
private static void TestCompressDecompress()
{
string source = "A quick brown fox jumped over lazy dogs";
byte[] src = Encoding.ASCII.GetBytes(source);
byte[] dst = new byte[1024];
ErrorCode ret = zlibCE.Compress(dst, src);
src = new byte[1024];
ret = zlibCE.Uncompress(src, dst);
}
--
Chris Tacke, Embedded MVP
OpenNETCF Consulting
Managed Code in an Embedded World
www.OpenNETCF.com
"Sven Rutten" <svenrutten@xxxxxxxxxxx> wrote in message news:E679C797-FCB0-45E7-B6BF-C7207BC290DD@xxxxxxxxxxxxxxxxHello
I'm using this code:
Dim inf As Stream = New System.IO.FileStream("\My Documents\test.txt", FileMode.Open)
Dim outf As Stream = File.Create("\My Documents\test.zip")
zlibCE.Deflate(inf, outf, 5)
inf.Close()
outf.Close()
That is working. But I have now no file, but a String which I want to compress. So I tried this:
Dim c As String = "TestingTestingTesting"
Dim tocompress() As Byte = System.Text.Encoding.Default.GetBytes(c)
Dim inf As Stream = New MemoryStream()
inf.Write(tocompress, 0, tocompress.Length)
Dim outf As Stream = File.Create("\My Documents\test.jj")
zlibCE.Deflate(inf, outf, 5)
inf.Close()
outf.Close()
So I convert to String to a Byte(), then I create a new MemoryStream, then I write the Byte to to MemoryStream.
After that I am Deflating normally...
But its not working?
What's Wrong?
Thanks
Sven
- Follow-Ups:
- Re: zlib OpennetCF question
- From: <ctacke/>
- Re: zlib OpennetCF question
- From: <ctacke/>
- Re: zlib OpennetCF question
- From: <ctacke/>
- Re: zlib OpennetCF question
- References:
- zlib OpennetCF question
- From: Sven Rutten
- Re: zlib OpennetCF question
- From: <ctacke/>
- zlib OpennetCF question
- Prev by Date: Re: Printing using CF 2.0
- Next by Date: Re: Newbie - Software requirements
- Previous by thread: Re: zlib OpennetCF question
- Next by thread: Re: zlib OpennetCF question
- Index(es):
Relevant Pages
|
Loading