Tuesday, June 23, 2015

A small image IO library: stb_image.h

I did my first test of one of the several libraries y'all suggested (thanks again!): stb_image

That is one of the "all in one file" kinds of libraries with all documentation in that header.   As a KISS kind of person that still thinks terminals are cool, I have to admit the simplicity of the thing almost brought tears to my eyes.   It's mainly by Sean Barrett and it is very nicely documented (in comments!).  I decided to try it first because Christopher Kulla said pbrt uses it and I like the taste shown in pbrt.

For input you use stb_image.h but output is the compatible stb_image_write.h.   The take the image and shove it into a 3 bytes per pixel array (for 24 bit images).   I haven't tested hdr (Ward's rgbe for this library) yet but so far I am very very pleased with this code.

Here's my test of just the io (in another program I verified their simple internal representation).  Included as an image so it doesn't mess up formatting and I am too lazy for HTML.   Sean Barrett, whomever you are, the beer is definitely on me if we ever cross paths!  (edit-- Sean is a real person and has a twitter @nothings).

No comments: