10.4 Bitmaps

The fz_bitmap structure is used to represent a 2 dimensional array of monochrome pixels. They are the 1 bit per component equivalent of the fz_pixmap structure.

The core rendering engine of MuPDF does not currently make use of fz_bitmaps, but rather they are used as a step along the way for outputting rendered information.

Functions exist within MuPDF to create fz_bitmaps from fz_pixmaps by halftoning. See section 10.5 Halftones.

/* 
   fz_new_bitmap_from_pixmap: Make a bitmap from a pixmap and a halftone. 
 
   pix: The pixmap to generate from. Currently must be a single color 
   component + alpha (where the alpha is assumed to be solid). 
 
   ht: The halftone to use. NULL implies the default halftone. 
 
   Returns the resultant bitmap. Throws exceptions in the case of 
   failure to allocate. 
*/ 
fz_bitmap *fz_new_bitmap_from_pixmap(fz_context *ctx, fz_pixmap *pix, fz_halftone *ht); 
 
fz_bitmap *fz_new_bitmap_from_pixmap_band(fz_context *ctx, fz_pixmap *pix, fz_halftone *ht, int band_start, int bandheight);

Both functions work by applying a fz_halftone to the contone values to make the bitmap. The latter function is a more general version of the former, that allows for correct operation when rendering in bands - namely that the correct offset into the halftone table is used.

The data for each Bitmap is packed into bytes most significant bit first. Multiple components are packed into the same byte, so a CMYK pixmap converted to a bitmap would have 2 pixels worth of data in the first byte, CMYKCMYK, with the first pixel in the highest nibble.

The usual reference counting behaviour applies to fz_bitmaps, with fz_keep_bitmap and fz_drop_bitmap claiming and releasing references respectively.