]> rtime.felk.cvut.cz Git - hornmich/skoda-qr-demo.git/blob - QRScanner/mobile/jni/include/mupdf/fitz/glyph.h
Add MuPDF native source codes
[hornmich/skoda-qr-demo.git] / QRScanner / mobile / jni / include / mupdf / fitz / glyph.h
1 #ifndef MUPDF_FITZ_GLYPH_H
2 #define MUPDF_FITZ_GLYPH_H
3
4 #include "mupdf/fitz/system.h"
5 #include "mupdf/fitz/context.h"
6 #include "mupdf/fitz/math.h"
7 #include "mupdf/fitz/store.h"
8 #include "mupdf/fitz/colorspace.h"
9
10 /*
11         Glyphs represent a run length encoded set of pixels for a 2
12         dimensional region of a plane.
13 */
14 typedef struct fz_glyph_s fz_glyph;
15
16 /*
17         fz_glyph_bbox: Return the bounding box for a glyph.
18 */
19 fz_irect *fz_glyph_bbox(fz_context *ctx, fz_glyph *glyph, fz_irect *bbox);
20
21 /*
22         fz_glyph_width: Return the width of the glyph in pixels.
23 */
24 int fz_glyph_width(fz_context *ctx, fz_glyph *glyph);
25
26 /*
27         fz_glyph_height: Return the height of the glyph in pixels.
28 */
29 int fz_glyph_height(fz_context *ctx, fz_glyph *glyph);
30
31 /*
32         fz_new_glyph_from_pixmap: Create a new glyph from a pixmap
33
34         Returns a pointer to the new glyph. Throws exception on failure to
35         allocate.
36 */
37 fz_glyph *fz_new_glyph_from_pixmap(fz_context *ctx, fz_pixmap *pix);
38
39 /*
40         fz_new_glyph_from_8bpp_data: Create a new glyph from 8bpp data
41
42         x, y: X and Y position for the glyph
43
44         w, h: Width and Height for the glyph
45
46         sp: Source Pointer to data
47
48         span: Increment from line to line of data
49
50         Returns a pointer to the new glyph. Throws exception on failure to
51         allocate.
52 */
53 fz_glyph *fz_new_glyph_from_8bpp_data(fz_context *ctx, int x, int y, int w, int h, unsigned char *sp, int span);
54
55 /*
56         fz_new_glyph_from_1bpp_data: Create a new glyph from 1bpp data
57
58         x, y: X and Y position for the glyph
59
60         w, h: Width and Height for the glyph
61
62         sp: Source Pointer to data
63
64         span: Increment from line to line of data
65
66         Returns a pointer to the new glyph. Throws exception on failure to
67         allocate.
68 */fz_glyph *fz_new_glyph_from_1bpp_data(fz_context *ctx, int x, int y, int w, int h, unsigned char *sp, int span);
69
70
71 /*
72         fz_keep_glyph: Take a reference to a glyph.
73
74         pix: The glyph to increment the reference for.
75
76         Returns pix. Does not throw exceptions.
77 */
78 fz_glyph *fz_keep_glyph(fz_context *ctx, fz_glyph *pix);
79
80 /*
81         fz_drop_glyph: Drop a reference and free a glyph.
82
83         Decrement the reference count for the glyph. When no
84         references remain the glyph will be freed.
85
86         Does not throw exceptions.
87 */
88 void fz_drop_glyph(fz_context *ctx, fz_glyph *pix);
89
90 /*
91         Glyphs represent a set of pixels for a 2 dimensional region of a
92         plane.
93
94         x, y: The minimum x and y coord of the region in pixels.
95
96         w, h: The width and height of the region in pixels.
97
98         samples: The sample data. The sample data is in a compressed format
99         designed to give reasonable compression, and to be fast to plot from.
100
101         The first sizeof(int) * h bytes of the table, when interpreted as
102         ints gives the offset within the data block of that lines data. An
103         offset of 0 indicates that that line is completely blank.
104
105         The data for individual lines is a sequence of bytes:
106          00000000 = end of lines data
107          LLLLLL00 = extend the length given in the next run by the 6 L bits
108                 given here.
109          LLLLLL01 = A run of length L+1 transparent pixels.
110          LLLLLE10 = A run of length L+1 solid pixels. If E then this is the
111                 last run on this line.
112          LLLLLE11 = A run of length L+1 intermediate pixels followed by L+1
113                 bytes of literal pixel data. If E then this is the last run
114                 on this line.
115 */
116 struct fz_glyph_s
117 {
118         fz_storable storable;
119         int x, y, w, h;
120         fz_pixmap *pixmap;
121         int size;
122         unsigned char data[1];
123 };
124
125 static unsigned int fz_glyph_size(fz_context *ctx, fz_glyph *glyph);
126
127 fz_irect *fz_glyph_bbox_no_ctx(fz_glyph *src, fz_irect *bbox);
128
129 static inline unsigned int
130 fz_glyph_size(fz_context *ctx, fz_glyph *glyph)
131 {
132         if (glyph == NULL)
133                 return 0;
134         return sizeof(fz_glyph) + glyph->size + fz_pixmap_size(ctx, glyph->pixmap);
135 }
136
137 #endif