|
|
|
|
|
by st_goliath
1252 days ago
|
|
The Netbpm format is amazing if you quickly want to try something out and need to generate an image of some sorts. The P6 binary format is even simpler, you write the header followed by a raw pixel data blob, e.g.: fprintf(stdout, "P6\n%d %d\n255\n", WIDTH, HEIGHT);
fwrite(image, 1, WIDTH * HEIGHT * 3, stdout);
Yes, I know, this obviously misses error handling, etc... The snippet is from a simple Mandelbrot renderer I cobbled together for a school exam exercise many moons ago: https://gist.github.com/AgentD/86445daed5fb21def3699b8122ea2...The simplicity of the format nicely limits the image output to the last 2 lines here. |
|