Saving a Canvas
The canvas, by itself, is just an intermediate step. It might represent an image of your scene, but you can’t look at it directly. You can’t show it to anyone. You can’t use it to brag about how awesome your 3D-rendered scene looks, or how amazing your ray tracer is. To do that, you need to be able to take the information in your canvas and write it out to a file, which could then be viewed, emailed, tweeted, Instagrammed, or whatever.
Let’s make that happen.
You could choose from a lot of different image formats, but you’re only going to implement one of them: the Portable Pixmap (PPM) format from the Netpbm project.[9] There are several flavors of the PPM format, but the version you’ll implement (called “plain” PPM) is straight ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access