Creating Images

To create an image from a standard type, simply call the appropriate function. For example, if you have a fz_buffer with the source data:


\begin{lstlisting}
/*
fz_new_image_from_buffer: Create a new image from a
buff...
... *fz_new_image_from_buffer(fz_context *ctx, fz_buffer *buffer);
\end{lstlisting}

If the data is in a file, use:


\begin{lstlisting}
/*
fz_image_from_file: Create a new image from the contents
...
...age *fz_new_image_from_file(fz_context *ctx, const char *path);
\end{lstlisting}

This loads the data into memory, and calls fz_new_image_from_buffer internally.

If the data cannot be recognised from its header, and more information is required, then the data can be formed in a fz_compressed_buffer, and an image created with:


\begin{lstlisting}
/*
fz_new_image_from_compressed_buffer: Create an image base...
..., int *colorkey, fz_compressed_buffer *buffer, fz_image *mask);
\end{lstlisting}

Finally, if we have a decoded fz_pixmap, we can form a new image from it:


\begin{lstlisting}
/*
fz_new_image_from_pixmap: Create an image from the given
...
...rom_pixmap(fz_context *ctx, fz_pixmap *pixmap, fz_image *mask);
\end{lstlisting}