mupdf
Loading...
Searching...
No Matches
image.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_FITZ_IMAGE_H
24#define MUPDF_FITZ_IMAGE_H
25
26#include "mupdf/fitz/system.h"
27#include "mupdf/fitz/context.h"
28#include "mupdf/fitz/store.h"
29#include "mupdf/fitz/pixmap.h"
30
31#include "mupdf/fitz/buffer.h"
32#include "mupdf/fitz/stream.h"
34
41typedef struct fz_image fz_image;
44
67fz_pixmap *fz_get_pixmap_from_image(fz_context *ctx, fz_image *image, const fz_irect *subarea, fz_matrix *ctm, int *w, int *h);
68
73fz_pixmap *fz_get_pixmap_mask_from_image(fz_context *ctx, fz_image *image, const fz_irect *subarea, fz_matrix *ctm, int *dw, int *dh, int in_smask);
74
79
87
96
105
114
119typedef void (fz_drop_image_fn)(fz_context *ctx, fz_image *image);
120
144typedef fz_pixmap *(fz_image_get_pixmap_fn)(fz_context *ctx, fz_image *im, fz_irect *subarea, int w, int h, int *l2factor);
145
149typedef void (fz_image_get_digest_fn)(fz_context *ctx, fz_image *im, unsigned char digest[16]);
150
154void fz_image_digest(fz_context *ctx, fz_image *img, unsigned char digest[16]);
155
163
212 int w,
213 int h,
214 int bpc,
215 fz_colorspace *colorspace,
216 int xres,
217 int yres,
218 int interpolate,
219 int imagemask,
220 const float *decode,
221 const int *colorkey,
222 fz_image *mask,
223 size_t size,
224 fz_image_get_pixmap_fn *get_pixmap,
225 fz_image_get_size_fn *get_size,
226 fz_image_get_digest_fn *get_digest,
227 fz_drop_image_fn *drop);
228
229#define fz_new_derived_image(CTX,W,H,B,CS,X,Y,I,IM,D,C,M,T,G,S,MD5,Z) \
230 ((T*)Memento_label(fz_new_image_of_size(CTX,W,H,B,CS,X,Y,I,IM,D,C,M,sizeof(T),G,S,MD5,Z),#T))
231
265fz_image *fz_new_image_from_compressed_buffer(fz_context *ctx, int w, int h, int bpc, fz_colorspace *colorspace, int xres, int yres, int interpolate, int imagemask, const float *decode, const int *colorkey, fz_compressed_buffer *buffer, fz_image *mask);
266
279
287
294
299
306
317fz_pixmap *fz_decomp_image_from_stream(fz_context *ctx, fz_stream *stm, fz_compressed_image *image, fz_irect *subarea, int indexed, int l2factor, int *l2extra);
318
325
332
337
344
345
351{
353 int w, h;
354 uint8_t n;
355 uint8_t bpc;
356 unsigned int imagemask:1;
357 unsigned int interpolate:1;
358 unsigned int use_colorkey:1;
359 unsigned int use_decode:1;
360 unsigned int decoded:1;
361 unsigned int scalable:1;
362 unsigned int intent:2;
363 unsigned int has_intent:1;
364 uint8_t orientation;
366 int xres; /* As given in the image, not necessarily as rendered */
367 int yres; /* As given in the image, not necessarily as rendered */
375};
376
385void fz_image_resolution(fz_image *image, int *xres, int *yres);
386
410
411/*
412 Return true if the image source is a lossy format such as JPEG,
413 JPEG2000, or JPEG-XR.
414*/
416
419
432
445
446/* Implementation details: subject to change. */
447
451fz_pixmap *fz_load_jpx(fz_context *ctx, const unsigned char *data, size_t size, fz_colorspace *cs);
452
458
459
463int fz_load_tiff_subimage_count(fz_context *ctx, const unsigned char *buf, size_t len);
464fz_pixmap *fz_load_tiff_subimage(fz_context *ctx, const unsigned char *buf, size_t len, int subimage);
465int fz_load_pnm_subimage_count(fz_context *ctx, const unsigned char *buf, size_t len);
466fz_pixmap *fz_load_pnm_subimage(fz_context *ctx, const unsigned char *buf, size_t len, int subimage);
467int fz_load_jbig2_subimage_count(fz_context *ctx, const unsigned char *buf, size_t len);
468fz_pixmap *fz_load_jbig2_subimage(fz_context *ctx, const unsigned char *buf, size_t len, int subimage);
469int fz_load_bmp_subimage_count(fz_context *ctx, const unsigned char *buf, size_t len);
470fz_pixmap *fz_load_bmp_subimage(fz_context *ctx, const unsigned char *buf, size_t len, int subimage);
471
472#endif
@ FZ_MAX_COLORS
Definition color.h:102
void fz_set_compressed_image_buffer(fz_context *ctx, fz_compressed_image *cimg, fz_compressed_buffer *buf)
fz_image * fz_keep_image_store_key(fz_context *ctx, fz_image *image)
int fz_compressed_image_type(fz_context *ctx, fz_image *image)
fz_image * fz_keep_image(fz_context *ctx, fz_image *image)
fz_pixmap * fz_load_tiff_subimage(fz_context *ctx, const unsigned char *buf, size_t len, int subimage)
fz_compressed_buffer * fz_compressed_image_buffer(fz_context *ctx, fz_image *image)
void fz_opj_unlock(fz_context *ctx)
fz_image * fz_new_image_from_compressed_buffer(fz_context *ctx, int w, int h, int bpc, fz_colorspace *colorspace, int xres, int yres, int interpolate, int imagemask, const float *decode, const int *colorkey, fz_compressed_buffer *buffer, fz_image *mask)
fz_pixmap * fz_convert_indexed_pixmap_to_base(fz_context *ctx, const fz_pixmap *src)
size_t fz_image_size(fz_context *ctx, fz_image *im)
struct fz_compressed_image fz_compressed_image
Definition image.h:42
fz_image * fz_new_image_from_buffer(fz_context *ctx, fz_buffer *buffer)
fz_pixmap * fz_pixmap_image_tile(fz_context *ctx, fz_pixmap_image *cimg)
fz_image * fz_new_image_of_size(fz_context *ctx, int w, int h, int bpc, fz_colorspace *colorspace, int xres, int yres, int interpolate, int imagemask, const float *decode, const int *colorkey, fz_image *mask, size_t size, fz_image_get_pixmap_fn *get_pixmap, fz_image_get_size_fn *get_size, fz_image_get_digest_fn *get_digest, fz_drop_image_fn *drop)
size_t fz_image_get_size_fn(fz_context *, fz_image *)
Definition image.h:162
void fz_image_digest(fz_context *ctx, fz_image *img, unsigned char digest[16])
void fz_drop_image_store_key(fz_context *ctx, fz_image *image)
fz_pixmap * fz_load_jpx(fz_context *ctx, const unsigned char *data, size_t size, fz_colorspace *cs)
int fz_load_pnm_subimage_count(fz_context *ctx, const unsigned char *buf, size_t len)
fz_pixmap * fz_decomp_image_from_stream(fz_context *ctx, fz_stream *stm, fz_compressed_image *image, fz_irect *subarea, int indexed, int l2factor, int *l2extra)
fz_pixmap * fz_load_jbig2_subimage(fz_context *ctx, const unsigned char *buf, size_t len, int subimage)
fz_pixmap * fz_get_pixmap_mask_from_image(fz_context *ctx, fz_image *image, const fz_irect *subarea, fz_matrix *ctm, int *dw, int *dh, int in_smask)
fz_image * fz_new_image_from_file(fz_context *ctx, const char *path)
struct fz_pixmap_image fz_pixmap_image
Definition image.h:43
fz_pixmap * fz_load_pnm_subimage(fz_context *ctx, const unsigned char *buf, size_t len, int subimage)
void fz_set_pixmap_image_tile(fz_context *ctx, fz_pixmap_image *cimg, fz_pixmap *pix)
void fz_opj_lock(fz_context *ctx)
void fz_drop_image_fn(fz_context *ctx, fz_image *image)
Definition image.h:119
void fz_drop_image_base(fz_context *ctx, fz_image *image)
int fz_is_lossy_image(fz_context *ctx, fz_image *image)
void fz_image_resolution(fz_image *image, int *xres, int *yres)
void fz_drop_image_imp(fz_context *ctx, fz_storable *image)
int fz_load_bmp_subimage_count(fz_context *ctx, const unsigned char *buf, size_t len)
fz_image * fz_new_image_from_pixmap(fz_context *ctx, fz_pixmap *pixmap, fz_image *mask)
int fz_load_jbig2_subimage_count(fz_context *ctx, const unsigned char *buf, size_t len)
fz_pixmap * fz_load_bmp_subimage(fz_context *ctx, const unsigned char *buf, size_t len, int subimage)
fz_pixmap * fz_convert_separation_pixmap_to_base(fz_context *ctx, const fz_pixmap *src)
int fz_load_tiff_subimage_count(fz_context *ctx, const unsigned char *buf, size_t len)
fz_matrix fz_image_orientation_matrix(fz_context *ctx, fz_image *image)
fz_pixmap * fz_image_get_pixmap_fn(fz_context *ctx, fz_image *im, fz_irect *subarea, int w, int h, int *l2factor)
Definition image.h:144
void fz_image_get_digest_fn(fz_context *ctx, fz_image *im, unsigned char digest[16])
Definition image.h:149
fz_image * fz_new_jpx_image_from_buffer(fz_context *ctx, fz_buffer *buffer, fz_colorspace *cs)
uint8_t fz_image_orientation(fz_context *ctx, fz_image *image)
fz_pixmap * fz_get_pixmap_from_image(fz_context *ctx, fz_image *image, const fz_irect *subarea, fz_matrix *ctm, int *w, int *h)
fz_pixmap * fz_get_unscaled_pixmap_from_image(fz_context *ctx, fz_image *image)
void fz_drop_image(fz_context *ctx, fz_image *image)
Definition buffer.h:41
Definition color.h:417
Definition compressed-buffer.h:93
Definition context.h:886
Definition image.h:351
unsigned int use_decode
Definition image.h:359
uint8_t bpc
Definition image.h:355
unsigned int imagemask
Definition image.h:356
fz_drop_image_fn * drop_image
Definition image.h:369
fz_key_storable key_storable
Definition image.h:352
fz_image_get_pixmap_fn * get_pixmap
Definition image.h:370
fz_image_get_digest_fn * get_digest
Definition image.h:371
unsigned int use_colorkey
Definition image.h:358
unsigned int decoded
Definition image.h:360
float decode[FZ_MAX_COLORS *2]
Definition image.h:374
int yres
Definition image.h:367
unsigned int has_intent
Definition image.h:363
fz_image * mask
Definition image.h:365
unsigned int interpolate
Definition image.h:357
unsigned int intent
Definition image.h:362
fz_colorspace * colorspace
Definition image.h:368
int w
Definition image.h:353
unsigned int scalable
Definition image.h:361
int h
Definition image.h:353
fz_image_get_size_fn * get_size
Definition image.h:372
uint8_t orientation
Definition image.h:364
int xres
Definition image.h:366
uint8_t n
Definition image.h:354
int colorkey[FZ_MAX_COLORS *2]
Definition image.h:373
Definition geometry.h:248
Definition store.h:88
Definition geometry.h:388
Definition pixmap.h:432
Definition store.h:76
Definition stream.h:320