Hacker News new | past | comments | ask | show | jobs | submit login

Except in that case you're converting to and from an uncompressed buffer... that could be in ram and not use a file format at all?



It's much more useful to have a real file format.

For example, you can generate images from your own code by doing this (with a bit more shell quoting and error checking in the real code):

  fp = popen ("ppmtojpeg > output.jpg", "w");
  fprintf (fp, "P3 1024 1024 255\n");
  for (y = 0; y < 1024; ++y)
    for (x = 0; x < 1024; ++x)
      fprintf (fp, "%d %d %d\n", 255*r[y][x], 255*g[y][x], 255*b[y][x]);
  fclose (fp);


This is the first time I have seen anyone popen’ing a pipeline like that, and writing to its stdin.

Bravo.




Consider applying for YC's Spring batch! Applications are open till Feb 11.

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: