Re: I can't figure out how to interface with the zlib.lib that libpng builds - is it incompatible? [VS 2019, Windows]

Ben Bullock <[email protected]> Sat, 9 Jan 2021 11:08:35 +0900
Newsgroups gmane.comp.graphics.png.devel
Message-ID <CAN5Y6m_vY4mxgN1BVHa8k9CEW8ZcnQhRb90sJaXABpw0FkPNrw@mail.gmail.com>
On Sat, 9 Jan 2021 at 10:44, David Horman <[email protected]> wrote:

>
> Now I want to directly use zlib in my project to compress some data -
> nothing to do with PNGs - but I'm having trouble. I'm following the zlib
> 1.2.11 manual, but whenever I try to deflateInit(...) or compress(...) I
> get a return value of Z_STREAM_ERROR - this despite the fact that I'm
> copy and pasting code directly from examples and tutorials. I found a
> zlib example VS project online which directly compiles some zlib source
> code into itself, and the code in question works fine in that project.
>

The most likely culprit if you are copying and pasting code from examples
(it may not be the actual problem but the most likely culprit) is that when
you opened the file with fopen or whatever, you didn't open it in binary
mode, and Windows is translating the \n to \r\n or what have you.

When you use fopen on Windows you need to add a "b" at the end of the
"mode" argument to make sure that Windows opens it in binary mode.

However, this is a well-known problem so if that is not what you found on
stackoverflow or what have you, it may not be that.

_______________________________________________
png-mng-implement mailing list
png-mng-implement-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org
https://lists.sourceforge.net/lists/listinfo/png-mng-implement