Re: zlib OpennetCF question



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@xxxxxxxxxxxxxxxx
Hello

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


.



Relevant Pages

  • Re: GZip Compression :(
    ... Dim TempDataAs Byte ... TempData, which is the length of the original file. ... compress option prior to base64 encoding the data. ... Dim Base64 As String = Convert.ToBase64String ...
    (microsoft.public.dotnet.framework)
  • Re: zlib OpennetCF question
    ... Chris Tacke, Embedded MVP ... Managed Code in an Embedded World ... I could submit the length of the original bytearray with it to dim it correctly, but yeah that's not really a good solution... ... But I have now no file, but a String which I want to compress. ...
    (microsoft.public.pocketpc.developer)
  • Re: Powerpoint graphics filters
    ... For your question about how to automate to compress a image in ppt, ... Dim osl As Slide ... Dim osh As Shape ...
    (microsoft.public.office.developer.automation)
  • Re: zlib OpennetCF question
    ... source, out int uncompressedSize) ... submit the length of the original bytearray with it to dim it correctly, ... Dim outf As Stream = File.Create ... compress. ...
    (microsoft.public.pocketpc.developer)
  • Re: Powerpoint graphics filters
    ... For your question about how to automate to compress a image in ppt, ... Dim osl As Slide ... Dim osh As Shape ...
    (microsoft.public.office.developer.automation)

Loading