4 ms·
Maybe you should use PPM P6 format instead of JPEG, TIFF, RAW, or analog. Here's the implementation I used in My Very First Ray Tracer: /* PPM P6 file for
by kragen 11y ago
Maybe you should use PPM P6 format instead of JPEG, TIFF, RAW, or analog. Here's the implementation I used in My Very First Ray Tracer:
/* PPM P6 file format; see <http://netpbm.sourceforge.net/doc/ppm.html> */
static void
output_header(int ww, int hh)
{ printf("P6\n%d %d\n255\n", ww, hh); }
static unsigned char
byte(double dd) { return dd > 1 ? 255 : dd < 0 ? 0 : dd * 255 + 0.5; }
static void
encode_color(color co)
{ putchar(byte(co.x)); putchar(byte(co.y)); putchar(byte(co.z)); }
(I was using x, y, and z to hold the r, g, and b components of the color, respectively.)