The purpose of the fz_band_writer mechanism is to allow banded rendering; rather than having to allocate a pixmap large enough to hold the entire page at once, we instead render bands across the page and feed those to the fz_band_writer which assembles them into a properly formed XXX format output stream.
Typically a band writer is created using a call such as fz_new_png_band_writer:
The page output starts by calling fz_write_header. This both configures the band writer for the type of data that is being sent, and triggers the output of the file header:
This has the effect of setting the size and format of the data for the complete image. The caller then proceeds to render the page in horizontal strips from the top to the bottom, and pass them in to fz_write_band:
The band writer keeps track of how much data has been written, and when an entire page has been sent, it writes out any image trailer required.
For formats that can accommodate multiple pages, a new call to fz_write_header will start the process again. Otherwise (or after the final image), the band writer can be neatly discarded by calling: