libheatmap
libheatmap copied to clipboard
failed create valid png file with the example data.
points: 12 123 52 12 321 94 87 483 60 10 90 470
use command command: 500 500 10 < points.txt > heatmap.png it create an empty png file. i open this file in photoshop, it report an error: file parse mode can not parse this file.
I failed to reproduce this issue: I ran your exact command with your exact points, and it created the following image, which I can open in an image viewer:

Can you reproduce this issue if you recompile (make clean and make again) and run your command again? Is the generated file completely empty (0 bytes) or somehow corrupt? If you are using a unix-y system (linux or OSX) you can type file heatmap.png to see if it's a valid file.
Hi, I've noticed this issue too, only on windows. Identical commands on Mac seem to run fine, when run on windows the outputted png does seem corrupted,
Aha, that is great information (that I completely missed, sorry).
This makes me guess it's because windows treats cout as text file and so writes \r\n whenever it sees \n, which is stupid.
This probably happens in this line here and can probably be fixed by a call to _setmode prior, as mentioned here. Could anyone who encounters this issue try that out and, if it works, create a PR that adds these lines if windows is detected (via #ifdef)?
Aha, that is great information (that I completely missed, sorry). This makes me guess it's because windows treats
coutas text file and so writes\r\nwhenever it sees\n, which is stupid. This probably happens in this line here and can probably be fixed by a call to_setmodeprior, as mentioned here. Could anyone who encounters this issue try that out and, if it works, create a PR that adds these lines if windows is detected (via#ifdef)?
Great! It's working as you tell. But I am a beginner I don't know how to create a PR. By the way, why here we can't simply use "lodepng::save_file(png, "heatmap.png");" instead of "std::cout.write..."?