PNG

The PNG format will accept either greyscale or RGB pixmaps, with or without alpha. As a special case, alpha only pixmaps are accepted and written as greyscale.


\begin{lstlisting}
/*
fz_save_pixmap_as_png: Save a pixmap as a PNG image file....
...riter *fz_new_png_band_writer(fz_context *ctx, fz_output *out);
\end{lstlisting}

Because PNG is such a useful and widely used format, we have another couple of functions. These take either a fz_image or a fz_pixmap and produce a fz_buffer containing a PNG encoded version. This is very useful when converting between document formats as we can frequently use a PNG version of an image as a replacement for other image formats that may not be supported.


\begin{lstlisting}
/*
Create a new buffer containing the image/pixmap in PNG fo...
..._buffer_from_pixmap_as_png(fz_context *ctx, fz_pixmap *pixmap);
\end{lstlisting}