OpenImageIO/oiio — pull request #800 by lgritz (2014-02-07 06:41:42+00:00)
Title: Make all the non-tiled formats emulate tiled files by buffering the image.

Some apps may only know how to output tiles, but some formats only support
scanline oriented data. This patch makes this situation work (albeit not
especially efficiently) by:

1. Upon open() with a tiled spec and a non-tile-supporting format, will
allocate a buffer large enough to hold the full image (I told you it
wouldn't be efficient).

2. write_tile() marshalls the tile of data into the right spots in the
image buffer.

3. close() calls write_scanlines(), thereby outputting all those scanlines
now that it has the full buffer ready. And frees the buffer.

I don't recommend using this as a first choice. Best is for the app to
send scanlines to files for formats that don't support("tiles"). But if
you had an app that naturally generated data in tiles, and almost always
used the tiled formats, but every once in a while might want to save in
one of those scanline-only formats (but this is not the important case
for high performance), at least this lets the app knowingly make the
memory-for-flexibility trade-off, without needing to handle the
buffering logic on the app side or have a secondary scanline-oriented
code path.