comparison mupdf-source/include/mupdf/pdf/resource.h @ 2:b50eed0cc0ef upstream

ADD: MuPDF v1.26.7: the MuPDF source as downloaded by a default build of PyMuPDF 1.26.4. The directory name has changed: no version number in the expanded directory now.
author Franz Glasner <fzglas.hg@dom66.de>
date Mon, 15 Sep 2025 11:43:07 +0200
parents
children
comparison
equal deleted inserted replaced
1:1d09e1dec1d9 2:b50eed0cc0ef
1 // Copyright (C) 2004-2025 Artifex Software, Inc.
2 //
3 // This file is part of MuPDF.
4 //
5 // MuPDF is free software: you can redistribute it and/or modify it under the
6 // terms of the GNU Affero General Public License as published by the Free
7 // Software Foundation, either version 3 of the License, or (at your option)
8 // any later version.
9 //
10 // MuPDF is distributed in the hope that it will be useful, but WITHOUT ANY
11 // WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
12 // FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
13 // details.
14 //
15 // You should have received a copy of the GNU Affero General Public License
16 // along with MuPDF. If not, see <https://www.gnu.org/licenses/agpl-3.0.en.html>
17 //
18 // Alternative licensing terms are available from the licensor.
19 // For commercial licensing, see <https://www.artifex.com/> or contact
20 // Artifex Software, Inc., 39 Mesa Street, Suite 108A, San Francisco,
21 // CA 94129, USA, for further information.
22
23 #ifndef MUPDF_PDF_RESOURCE_H
24 #define MUPDF_PDF_RESOURCE_H
25
26 #include "mupdf/fitz/font.h"
27 #include "mupdf/fitz/image.h"
28 #include "mupdf/fitz/shade.h"
29 #include "mupdf/fitz/store.h"
30 #include "mupdf/pdf/object.h"
31
32 void pdf_store_item(fz_context *ctx, pdf_obj *key, void *val, size_t itemsize);
33 void *pdf_find_item(fz_context *ctx, fz_store_drop_fn *drop, pdf_obj *key);
34 void pdf_remove_item(fz_context *ctx, fz_store_drop_fn *drop, pdf_obj *key);
35 void pdf_empty_store(fz_context *ctx, pdf_document *doc);
36 void pdf_purge_locals_from_store(fz_context *ctx, pdf_document *doc);
37 void pdf_purge_object_from_store(fz_context *ctx, pdf_document *doc, int num);
38
39 /*
40 * Structures used for managing resource locations and avoiding multiple
41 * occurrences when resources are added to the document. The search for existing
42 * resources will be performed when we are first trying to add an item. Object
43 * refs are stored in a fz_hash_table structure using a hash of the md5 sum of
44 * the data, enabling rapid lookup.
45 */
46
47 enum { PDF_SIMPLE_FONT_RESOURCE=1, PDF_CID_FONT_RESOURCE=2, PDF_CJK_FONT_RESOURCE=3 };
48 enum { PDF_SIMPLE_ENCODING_LATIN, PDF_SIMPLE_ENCODING_GREEK, PDF_SIMPLE_ENCODING_CYRILLIC };
49
50 /* The contents of this structure are defined publicly just so we can
51 * define this on the stack. */
52 typedef struct
53 {
54 unsigned char digest[16];
55 int type;
56 int encoding;
57 int local_xref;
58 } pdf_font_resource_key;
59
60 typedef struct
61 {
62 unsigned char digest[16];
63 int local_xref;
64 } pdf_colorspace_resource_key;
65
66 pdf_obj *pdf_find_font_resource(fz_context *ctx, pdf_document *doc, int type, int encoding, fz_font *item, pdf_font_resource_key *key);
67 pdf_obj *pdf_insert_font_resource(fz_context *ctx, pdf_document *doc, pdf_font_resource_key *key, pdf_obj *obj);
68 pdf_obj *pdf_find_colorspace_resource(fz_context *ctx, pdf_document *doc, fz_colorspace *item, pdf_colorspace_resource_key *key);
69 pdf_obj *pdf_insert_colorspace_resource(fz_context *ctx, pdf_document *doc, pdf_colorspace_resource_key *key, pdf_obj *obj);
70 void pdf_drop_resource_tables(fz_context *ctx, pdf_document *doc);
71 void pdf_purge_local_resources(fz_context *ctx, pdf_document *doc);
72
73 typedef struct pdf_function pdf_function;
74
75 void pdf_eval_function(fz_context *ctx, pdf_function *func, const float *in, int inlen, float *out, int outlen);
76 pdf_function *pdf_keep_function(fz_context *ctx, pdf_function *func);
77 void pdf_drop_function(fz_context *ctx, pdf_function *func);
78 size_t pdf_function_size(fz_context *ctx, pdf_function *func);
79 pdf_function *pdf_load_function(fz_context *ctx, pdf_obj *ref, int in, int out);
80
81 fz_colorspace *pdf_document_output_intent(fz_context *ctx, pdf_document *doc);
82 fz_colorspace *pdf_load_colorspace(fz_context *ctx, pdf_obj *obj);
83 int pdf_is_tint_colorspace(fz_context *ctx, fz_colorspace *cs);
84
85 fz_shade *pdf_load_shading(fz_context *ctx, pdf_document *doc, pdf_obj *obj);
86 void pdf_sample_shade_function(fz_context *ctx, float *samples, int n, int funcs, pdf_function **func, float t0, float t1);
87
88 /**
89 Function to recolor a single color from a shade.
90 */
91 typedef void (pdf_recolor_vertex)(fz_context *ctx, void *opaque, fz_colorspace *dst_cs, float *d, fz_colorspace *src_cs, const float *src);
92
93 /**
94 Function to handle recoloring a shade.
95
96 Called with src_cs from the shade. If no recoloring is required, return NULL. Otherwise
97 fill in *dst_cs, and return a vertex recolorer.
98 */
99 typedef pdf_recolor_vertex *(pdf_shade_recolorer)(fz_context *ctx, void *opaque, fz_colorspace *src_cs, fz_colorspace **dst_cs);
100
101 /**
102 Recolor a shade.
103 */
104 pdf_obj *pdf_recolor_shade(fz_context *ctx, pdf_obj *shade, pdf_shade_recolorer *reshade, void *opaque);
105
106 fz_image *pdf_load_inline_image(fz_context *ctx, pdf_document *doc, pdf_obj *rdb, pdf_obj *dict, fz_stream *file);
107 int pdf_is_jpx_image(fz_context *ctx, pdf_obj *dict);
108
109 fz_image *pdf_load_image(fz_context *ctx, pdf_document *doc, pdf_obj *obj);
110
111 pdf_obj *pdf_add_image(fz_context *ctx, pdf_document *doc, fz_image *image);
112
113 pdf_obj *pdf_add_colorspace(fz_context *ctx, pdf_document *doc, fz_colorspace *cs);
114
115 typedef struct
116 {
117 fz_storable storable;
118 int ismask;
119 float xstep;
120 float ystep;
121 fz_matrix matrix;
122 fz_rect bbox;
123 pdf_document *document;
124 pdf_obj *resources;
125 pdf_obj *contents;
126 int id; /* unique ID for caching rendered tiles */
127 } pdf_pattern;
128
129 pdf_pattern *pdf_load_pattern(fz_context *ctx, pdf_document *doc, pdf_obj *obj);
130 pdf_pattern *pdf_keep_pattern(fz_context *ctx, pdf_pattern *pat);
131 void pdf_drop_pattern(fz_context *ctx, pdf_pattern *pat);
132
133 pdf_obj *pdf_new_xobject(fz_context *ctx, pdf_document *doc, fz_rect bbox, fz_matrix matrix, pdf_obj *res, fz_buffer *buffer);
134 void pdf_update_xobject(fz_context *ctx, pdf_document *doc, pdf_obj *xobj, fz_rect bbox, fz_matrix mat, pdf_obj *res, fz_buffer *buffer);
135
136 pdf_obj *pdf_xobject_resources(fz_context *ctx, pdf_obj *xobj);
137 fz_rect pdf_xobject_bbox(fz_context *ctx, pdf_obj *xobj);
138 fz_matrix pdf_xobject_matrix(fz_context *ctx, pdf_obj *xobj);
139 int pdf_xobject_isolated(fz_context *ctx, pdf_obj *xobj);
140 int pdf_xobject_knockout(fz_context *ctx, pdf_obj *xobj);
141 int pdf_xobject_transparency(fz_context *ctx, pdf_obj *xobj);
142 fz_colorspace *pdf_xobject_colorspace(fz_context *ctx, pdf_obj *xobj);
143
144 #endif