mupdf
Loading...
Searching...
No Matches
resource.h
Go to the documentation of this file.
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
32void pdf_store_item(fz_context *ctx, pdf_obj *key, void *val, size_t itemsize);
38
40
41/*
42 * Structures used for managing resource locations and avoiding multiple
43 * occurrences when resources are added to the document. The search for existing
44 * resources will be performed when we are first trying to add an item. Object
45 * refs are stored in a fz_hash_table structure using a hash of the md5 sum of
46 * the data, enabling rapid lookup.
47 */
48
51
52/* The contents of this structure are defined publicly just so we can
53 * define this on the stack. */
54typedef struct
55{
56 unsigned char digest[16];
57 int type;
61
62typedef struct
63{
64 unsigned char digest[16];
67
68typedef struct
69{
70 int w, h;
71 int decode;
72 unsigned int bpc : 3;
73 unsigned int n : 6;
74 unsigned int imagemask : 1;
75 unsigned int use_colorkey : 1;
76 unsigned int use_decode : 1;
77 unsigned int local_xref : 1;
78 unsigned char mask[16];
79 unsigned char digest[16];
81
82pdf_obj *pdf_find_font_resource(fz_context *ctx, pdf_document *doc, int type, int encoding, fz_font *item, pdf_font_resource_key *key);
90
92
93void pdf_eval_function(fz_context *ctx, pdf_function *func, const float *in, int inlen, float *out, int outlen);
97pdf_function *pdf_load_function(fz_context *ctx, pdf_obj *ref, int in, int out);
98
102
104void pdf_sample_shade_function(fz_context *ctx, float *samples, int n, int funcs, pdf_function **func, float t0, float t1);
105
107
111typedef void (pdf_recolor_vertex)(fz_context *ctx, void *opaque, fz_colorspace *dst_cs, float *d, fz_colorspace *src_cs, const float *src);
112
119typedef pdf_recolor_vertex *(pdf_shade_recolorer)(fz_context *ctx, void *opaque, fz_colorspace *src_cs, fz_colorspace **dst_cs);
120
124pdf_obj *pdf_recolor_shade(fz_context *ctx, pdf_obj *shade, pdf_shade_recolorer *reshade, void *opaque);
125
128
130
132
134
135typedef struct
136{
139 float xstep;
140 float ystep;
146 int id; /* unique ID for caching rendered tiles */
149
153
155void pdf_update_xobject(fz_context *ctx, pdf_document *doc, pdf_obj *xobj, fz_rect bbox, fz_matrix mat, pdf_obj *res, fz_buffer *buffer);
156
164
165#endif
struct pdf_obj pdf_obj
Definition object.h:44
pdf_function * pdf_load_function(fz_context *ctx, pdf_obj *ref, int in, int out)
fz_colorspace * pdf_load_colorspace(fz_context *ctx, pdf_obj *obj)
fz_matrix pdf_xobject_matrix(fz_context *ctx, pdf_obj *xobj)
@ PDF_SIMPLE_FONT_RESOURCE
Definition resource.h:49
@ PDF_CJK_FONT_RESOURCE
Definition resource.h:49
@ PDF_CID_FONT_RESOURCE
Definition resource.h:49
void pdf_store_item(fz_context *ctx, pdf_obj *key, void *val, size_t itemsize)
fz_shade * pdf_load_shading(fz_context *ctx, pdf_document *doc, pdf_obj *obj)
int pdf_xobject_knockout(fz_context *ctx, pdf_obj *xobj)
pdf_pattern * pdf_load_pattern(fz_context *ctx, pdf_document *doc, pdf_obj *obj)
pdf_recolor_vertex * pdf_shade_recolorer(fz_context *ctx, void *opaque, fz_colorspace *src_cs, fz_colorspace **dst_cs)
Definition resource.h:119
pdf_obj * pdf_insert_image_resource(fz_context *ctx, pdf_document *doc, pdf_image_resource_key *key, pdf_obj *obj)
pdf_obj * pdf_recolor_shade(fz_context *ctx, pdf_obj *shade, pdf_shade_recolorer *reshade, void *opaque)
pdf_obj * pdf_insert_colorspace_resource(fz_context *ctx, pdf_document *doc, pdf_colorspace_resource_key *key, pdf_obj *obj)
void pdf_recolor_vertex(fz_context *ctx, void *opaque, fz_colorspace *dst_cs, float *d, fz_colorspace *src_cs, const float *src)
Definition resource.h:111
pdf_obj * pdf_new_xobject(fz_context *ctx, pdf_document *doc, fz_rect bbox, fz_matrix matrix, pdf_obj *res, fz_buffer *buffer)
void pdf_empty_store(fz_context *ctx, pdf_document *doc)
int pdf_xobject_transparency(fz_context *ctx, pdf_obj *xobj)
fz_image * pdf_load_inline_image(fz_context *ctx, pdf_document *doc, pdf_resource_stack *rdb, pdf_obj *dict, fz_stream *file)
void pdf_purge_local_resources(fz_context *ctx, pdf_document *doc)
pdf_obj * pdf_add_colorspace(fz_context *ctx, pdf_document *doc, fz_colorspace *cs)
void pdf_sample_shade_function(fz_context *ctx, float *samples, int n, int funcs, pdf_function **func, float t0, float t1)
pdf_obj * pdf_find_image_resource(fz_context *ctx, pdf_document *doc, fz_image *item, pdf_image_resource_key *key)
int pdf_xobject_isolated(fz_context *ctx, pdf_obj *xobj)
pdf_pattern * pdf_keep_pattern(fz_context *ctx, pdf_pattern *pat)
void pdf_drop_function(fz_context *ctx, pdf_function *func)
void pdf_purge_locals_from_store(fz_context *ctx, pdf_document *doc)
int pdf_pattern_uses_blending(fz_context *ctx, pdf_obj *dict, pdf_cycle_list *cycle_up)
void pdf_drop_pattern(fz_context *ctx, pdf_pattern *pat)
pdf_obj * pdf_find_font_resource(fz_context *ctx, pdf_document *doc, int type, int encoding, fz_font *item, pdf_font_resource_key *key)
int pdf_is_tint_colorspace(fz_context *ctx, fz_colorspace *cs)
int pdf_is_jpx_image(fz_context *ctx, pdf_obj *dict)
pdf_obj * pdf_insert_font_resource(fz_context *ctx, pdf_document *doc, pdf_font_resource_key *key, pdf_obj *obj)
size_t pdf_function_size(fz_context *ctx, pdf_function *func)
fz_colorspace * pdf_document_output_intent(fz_context *ctx, pdf_document *doc)
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)
void pdf_purge_object_from_store(fz_context *ctx, pdf_document *doc, int num)
pdf_obj * pdf_find_colorspace_resource(fz_context *ctx, pdf_document *doc, fz_colorspace *item, pdf_colorspace_resource_key *key)
pdf_obj * pdf_add_image(fz_context *ctx, pdf_document *doc, fz_image *image)
void * pdf_find_item(fz_context *ctx, fz_store_drop_fn *drop, pdf_obj *key)
fz_colorspace * pdf_xobject_colorspace(fz_context *ctx, pdf_obj *xobj)
void pdf_drop_resource_tables(fz_context *ctx, pdf_document *doc)
int pdf_guess_colorspace_components(fz_context *ctx, pdf_obj *obj)
struct pdf_function pdf_function
Definition resource.h:91
@ PDF_SIMPLE_ENCODING_GREEK
Definition resource.h:50
@ PDF_SIMPLE_ENCODING_CYRILLIC
Definition resource.h:50
@ PDF_SIMPLE_ENCODING_LATIN
Definition resource.h:50
fz_rect pdf_xobject_bbox(fz_context *ctx, pdf_obj *xobj)
fz_image * pdf_load_image(fz_context *ctx, pdf_document *doc, pdf_obj *obj)
void pdf_remove_item(fz_context *ctx, fz_store_drop_fn *drop, pdf_obj *key)
pdf_function * pdf_keep_function(fz_context *ctx, pdf_function *func)
void pdf_eval_function(fz_context *ctx, pdf_function *func, const float *in, int inlen, float *out, int outlen)
pdf_obj * pdf_xobject_resources(fz_context *ctx, pdf_obj *xobj)
void fz_store_drop_fn(fz_context *, fz_storable *)
Definition store.h:61
Definition buffer.h:41
Definition color.h:417
Definition context.h:886
Definition font.h:776
Definition image.h:351
Definition geometry.h:388
Definition geometry.h:231
Definition shade.h:53
Definition store.h:76
Definition stream.h:320
Definition resource.h:63
unsigned char digest[16]
Definition resource.h:64
int local_xref
Definition resource.h:65
Definition object.h:113
Definition document.h:463
Definition resource.h:55
int local_xref
Definition resource.h:59
int type
Definition resource.h:57
int encoding
Definition resource.h:58
unsigned char digest[16]
Definition resource.h:56
Definition resource.h:69
unsigned int bpc
Definition resource.h:72
int decode
Definition resource.h:71
unsigned int use_colorkey
Definition resource.h:75
unsigned int use_decode
Definition resource.h:76
int w
Definition resource.h:70
unsigned int n
Definition resource.h:73
int h
Definition resource.h:70
unsigned char mask[16]
Definition resource.h:78
unsigned char digest[16]
Definition resource.h:79
unsigned int local_xref
Definition resource.h:77
unsigned int imagemask
Definition resource.h:74
Definition resource.h:136
int id
Definition resource.h:146
fz_rect bbox
Definition resource.h:142
pdf_document * document
Definition resource.h:143
float ystep
Definition resource.h:140
pdf_obj * contents
Definition resource.h:145
fz_storable storable
Definition resource.h:137
int uses_blending
Definition resource.h:147
fz_matrix matrix
Definition resource.h:141
pdf_obj * resources
Definition resource.h:144
float xstep
Definition resource.h:139
int ismask
Definition resource.h:138
Definition interpret.h:44