Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Compress Stream to Stream #18

Open
anderbelluno opened this issue Jan 14, 2022 · 8 comments
Open

Compress Stream to Stream #18

anderbelluno opened this issue Jan 14, 2022 · 8 comments

Comments

@anderbelluno
Copy link

Hello, I would like to know if there is any example to compress stream to stream.
Ex:
I have a DataSet that I transform into a Stream, and I would like to compress the stream to another stream.
Today I use zlib to do the compression, but I'm looking for alternatives.
Thanks.

@romankassebaum
Copy link
Contributor

AbDfEnc.Deflate(ASource, ADest, nil);
AbDfDec.Inflate(ASource, ADest, nil);

@romankassebaum
Copy link
Contributor

These are functions that you can simply call without dropping a component on a form.

@anderbelluno
Copy link
Author

image

Sorry, maybe I didn't understand the idea correctly, but after deflate the Stream got bigger, as seen in the image.

@romankassebaum
Copy link
Contributor

The code looks correct. Maybe the image cannot be zipped. You could try a text file instead.

@anderbelluno
Copy link
Author

image
@romankassebaum
I tested it with a text file and with a MemoryDataSet, both worked.
But what's the point of not compressing the image?

@romankassebaum
Copy link
Contributor

It depends on the image you are trying to zip, E,g, a .gif is already compressed so that zipping cannot reduce the size any more. In technical words, zipping tries to reduce the redundancy of a stream. If there is no redundancy you cannot remove it.

@anderbelluno
Copy link
Author

Thank you so much for replying, it worked perfectly.
I just have one last question, can I use decompression classes in Delphi 7?

@romankassebaum
Copy link
Contributor

I have no idea, try it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants