digitalmars.D.learn - std.zlib odd behavior
- solidstate1991 (3/3) Mar 04 2019 https://github.com/ZILtoid1991/dimage/blob/master/source/dimage/png.d
- Adam D. Ruppe (9/12) Mar 04 2019 I haven't found the bug in your code yet, but one thing I suspect
- solidstate1991 (5/13) Mar 05 2019 Thanks, it seems I'll have to write my own solution for this, and
- solidstate1991 (5/10) May 20 2019 I was finally able to tame the beast, now I can load and save PNG
- Kagamin (5/8) Mar 05 2019 What do you mean by "doesn't add"?
https://github.com/ZILtoid1991/dimage/blob/master/source/dimage/png.d It seems that after a certain point, it doesn't add more data to the compression stream, flushing doesn't help.
Mar 04 2019
On Tuesday, 5 March 2019 at 01:43:42 UTC, solidstate1991 wrote:https://github.com/ZILtoid1991/dimage/blob/master/source/dimage/png.d It seems that after a certain point, it doesn't add more data to the compression stream, flushing doesn't help.I haven't found the bug in your code yet, but one thing I suspect from my experience is you might be reusing a buffer. std.zlib actually stores pointers internally across function calls, so if you are trying to compress a stream, you are liable to get corruption. (std.zlib is very bad code, frankly.) I don't know for sure though, my brain is in the compiler tonight...
Mar 04 2019
On Tuesday, 5 March 2019 at 02:19:26 UTC, Adam D. Ruppe wrote:I haven't found the bug in your code yet, but one thing I suspect from my experience is you might be reusing a buffer. std.zlib actually stores pointers internally across function calls, so if you are trying to compress a stream, you are liable to get corruption. (std.zlib is very bad code, frankly.) I don't know for sure though, my brain is in the compiler tonight...Thanks, it seems I'll have to write my own solution for this, and I really dislike the way streaming compression works in C. I've spotted some other bugs regarding my PNG implementation, but those were unrelated and didn't improve the compression issues.
Mar 05 2019
On Wednesday, 6 March 2019 at 01:50:16 UTC, solidstate1991 wrote:Thanks, it seems I'll have to write my own solution for this, and I really dislike the way streaming compression works in C. I've spotted some other bugs regarding my PNG implementation, but those were unrelated and didn't improve the compression issues.I was finally able to tame the beast, now I can load and save PNG files. Now I probably have issues with standardization, which will require me to read up on the topic, since my output isn't liked by IrfanView, and many other applications.
May 20 2019
On Tuesday, 5 March 2019 at 01:43:42 UTC, solidstate1991 wrote:https://github.com/ZILtoid1991/dimage/blob/master/source/dimage/png.d It seems that after a certain point, it doesn't add more data to the compression stream, flushing doesn't help.What do you mean by "doesn't add"? ubyte[] slice = pos < imageData.length ? imageData[pos..(pos + pitch)] : imageData[pos..$]; This can't possibly work. You slice past the end of array.
Mar 05 2019