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

failed create valid png file with the example data. #6

Open
bodong1987 opened this issue Oct 15, 2016 · 4 comments
Open

failed create valid png file with the example data. #6

bodong1987 opened this issue Oct 15, 2016 · 4 comments

Comments

@bodong1987
Copy link

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.

@lucasb-eyer
Copy link
Owner

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:

heatmap

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.

@teg-git
Copy link

teg-git commented Jan 2, 2019

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,

@lucasb-eyer
Copy link
Owner

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)?

@tanzhuoning
Copy link

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)?

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..."?

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

No branches or pull requests

4 participants