SaveImage is a library which I shared ages ago for people to make use of with QB64 which gives us the ability to export and save images from our programs.
AND, for the longest time, PNG files have generated a glitch when one attempted to use them in various external applications...
BUT... I think I have that corrected finally!
Issue was so simple that it almost makes me cry to say, "WTH didn't I notice this glitch before?!!" My only real consultation is just the fact of, "WTH didn't anyone else, either??"
If you take a moment to look down inside SaveImage.BM, you'll find two glitches:
First, in the SUB PNGExport, we see the following typo:
l = ConvertUL(l = ConvertUL(PNGCRCStringCheck("IEND", "")))
If you look at any of the other calls to the CRC check routines, you'll see that the above is just a complete glitch which should look like:
l = ConvertUL(PNGCRCStringCheck("IEND", ""))
BUT.... It's a glitch that doesn't matter, honestly, because of our second glitch:
PNGCRC = -1
PNGCRCcheck~&
= NOT PNGCRC
If you look at our actual function which generates our CRC values, you'll notice something glaringly obvious once I ask one rather pungent question:
Where do we calculate a return value in this function?? Exactly what does this function do??
The answers are: We don't, and this function does absolutely nothing. CHEERS TO USELESS CODING!!
Change
PNGCRCcheck~& = NOT PNGCRC to
PNGCRCStringCheck~& = NOT PNGCRC and PRESTO!! You now have a return value coming back from the end of that FUNCTION call!
And those two glitches should now have PNG exports corrected and glitch free, so you can now use and test them in any other program that you desire without issue.
I've made the corrections to the code, and am sharing it here for folks to test out and kick around a bit, before I go for an official v2.2 release, which I want to alt to use the new _DEFLATE routines with, so the routines will start to work for folks on Linux (and possibly not need any DLL files included with it, for future versions).
Test it out, make certain I packaged up the code with the proper changes into the archive, and let me know if it works as it should without tossing CRC errors as it was doing before for you guys. (Bplus and _vince did a lot of testing before and helped point me to the issue being in the IEND data chunk CRC value, so everyone take a moment to say, "Thanks guys," to them. Without their help in narrowing down the issue, I probably would've never micro-focused on those typos and found them!)
If all looks and works well, I'll swap in _DEFLATE, swap out the zlib.dll files, and repackage a smaller, friendlier version for everyone to enjoy and make use of sometime later next week. ;)