Compressed

The most common type of fz_image is fz_compressed_image - that is, an image based upon a fz_buffer of data in a standard compressed format, such as JPEG, PNG, TIFF, and others.

With such images, the data is held in a fz_compressed_buffer:


\begin{lstlisting}
typedef struct fz_compressed_buffer_s
{
fz_compression_params params;
fz_buffer *buffer;
} fz_compressed_buffer;
\end{lstlisting}

The data is held in the buffer field, and the details of the compression used are given in the params field, of type fz_compression_params:


\begin{lstlisting}
struct fz_compression_params_s
{
int type;
union {
struct ...
...;
int predictor;
int bpc;
int early_change;
} lzw;
} u;
};
\end{lstlisting}

The choice of which of the union clauses is used is made by the type field:


\begin{lstlisting}
enum
{
FZ_IMAGE_UNKNOWN = 0,
\par
/* Uncompressed samples */...
... FZ_IMAGE_JXR,
FZ_IMAGE_PNG,
FZ_IMAGE_PNM,
FZ_IMAGE_TIFF,
};
\end{lstlisting}

To determine if a fz_image is a compressed image, call:


\begin{lstlisting}
/*
fz_compressed_image_buffer: Retrieve the underlying compr...
... *fz_compressed_image_buffer(fz_context *ctx, fz_image *image);
\end{lstlisting}

The easiest way to tell if an image is a compressed image is to request its underlying buffer. If it returns NULL, you know it is not this sort of image.