Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
Download
7858 views
1
#ifndef MUPDF_FITZ_BITMAP_H
2
#define MUPDF_FITZ_BITMAP_H
3
4
#include "mupdf/fitz/system.h"
5
#include "mupdf/fitz/context.h"
6
#include "mupdf/fitz/pixmap.h"
7
8
/*
9
Bitmaps have 1 bit per component. Only used for creating halftoned
10
versions of contone buffers, and saving out. Samples are stored msb
11
first, akin to pbms.
12
*/
13
typedef struct fz_bitmap_s fz_bitmap;
14
15
/*
16
fz_keep_bitmap: Take a reference to a bitmap.
17
18
bit: The bitmap to increment the reference for.
19
20
Returns bit. Does not throw exceptions.
21
*/
22
fz_bitmap *fz_keep_bitmap(fz_context *ctx, fz_bitmap *bit);
23
24
/*
25
fz_drop_bitmap: Drop a reference and free a bitmap.
26
27
Decrement the reference count for the bitmap. When no
28
references remain the pixmap will be freed.
29
30
Does not throw exceptions.
31
*/
32
void fz_drop_bitmap(fz_context *ctx, fz_bitmap *bit);
33
34
/*
35
A halftone is a set of threshold tiles, one per component. Each
36
threshold tile is a pixmap, possibly of varying sizes and phases.
37
Currently, we only provide one 'default' halftone tile for operating
38
on 1 component plus alpha pixmaps (where the alpha is ignored). This
39
is signified by an fz_halftone pointer to NULL.
40
*/
41
typedef struct fz_halftone_s fz_halftone;
42
43
/*
44
fz_halftone_pixmap: Make a bitmap from a pixmap and a halftone.
45
46
pix: The pixmap to generate from. Currently must be a single color
47
component + alpha (where the alpha is assumed to be solid).
48
49
ht: The halftone to use. NULL implies the default halftone.
50
51
Returns the resultant bitmap. Throws exceptions in the case of
52
failure to allocate.
53
*/
54
fz_bitmap *fz_halftone_pixmap(fz_context *ctx, fz_pixmap *pix, fz_halftone *ht);
55
56
struct fz_bitmap_s
57
{
58
int refs;
59
int w, h, stride, n;
60
int xres, yres;
61
unsigned char *samples;
62
};
63
64
fz_bitmap *fz_new_bitmap(fz_context *ctx, int w, int h, int n, int xres, int yres);
65
66
void fz_bitmap_details(fz_bitmap *bitmap, int *w, int *h, int *n, int *stride);
67
68
void fz_clear_bitmap(fz_context *ctx, fz_bitmap *bit);
69
70
struct fz_halftone_s
71
{
72
int refs;
73
int n;
74
fz_pixmap *comp[1];
75
};
76
77
fz_halftone *fz_new_halftone(fz_context *ctx, int num_comps);
78
fz_halftone *fz_default_halftone(fz_context *ctx, int num_comps);
79
void fz_drop_halftone(fz_context *ctx, fz_halftone *half);
80
fz_halftone *fz_keep_halftone(fz_context *ctx, fz_halftone *half);
81
82
#endif
83
84