mupdf
Loading...
Searching...
No Matches
pixmap.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_PIXMAP_H
24#define MUPDF_FITZ_PIXMAP_H
25
26#include "mupdf/fitz/system.h"
27#include "mupdf/fitz/context.h"
28#include "mupdf/fitz/geometry.h"
29#include "mupdf/fitz/store.h"
31
40
42
47
51int fz_pixmap_width(fz_context *ctx, const fz_pixmap *pix);
52
57
61int fz_pixmap_x(fz_context *ctx, const fz_pixmap *pix);
62
66int fz_pixmap_y(fz_context *ctx, const fz_pixmap *pix);
67
72
90fz_pixmap *fz_new_pixmap(fz_context *ctx, fz_colorspace *cs, int w, int h, fz_separations *seps, int alpha);
91
113
137fz_pixmap *fz_new_pixmap_with_data(fz_context *ctx, fz_colorspace *colorspace, int w, int h, fz_separations *seps, int alpha, int stride, unsigned char *samples);
138
162fz_pixmap *fz_new_pixmap_with_bbox_and_data(fz_context *ctx, fz_colorspace *colorspace, fz_irect rect, fz_separations *seps, int alpha, unsigned char *samples);
163
176
184
192
200
207
214
222
230
237
243unsigned char *fz_pixmap_samples(fz_context *ctx, const fz_pixmap *pix);
244
249
253void fz_set_pixmap_resolution(fz_context *ctx, fz_pixmap *pix, int xres, int yres);
254
268
272void fz_fill_pixmap_with_color(fz_context *ctx, fz_pixmap *pix, fz_colorspace *colorspace, float *color, fz_color_params color_params);
273
286
294
301
306
316
324void fz_tint_pixmap(fz_context *ctx, fz_pixmap *pix, int black, int white);
325
332
338
345void fz_gamma_pixmap(fz_context *ctx, fz_pixmap *pix, float gamma);
346
368fz_pixmap *fz_convert_pixmap(fz_context *ctx, const fz_pixmap *pix, fz_colorspace *cs_des, fz_colorspace *prf, fz_default_colorspaces *default_cs, fz_color_params color_params, int keep_alpha);
369
375
376/* Implementation details: subject to change.*/
377
380void fz_decode_tile(fz_context *ctx, fz_pixmap *pix, const float *decode);
381void fz_md5_pixmap(fz_context *ctx, fz_pixmap *pixmap, unsigned char digest[16]);
382
383fz_stream *
384fz_unpack_stream(fz_context *ctx, fz_stream *src, int depth, int w, int h, int n, int indexed, int pad, int skip);
385
432{
434 int x, y, w, h;
435 unsigned char n;
436 unsigned char s;
437 unsigned char alpha;
438 unsigned char flags;
439 ptrdiff_t stride;
441 int xres, yres;
443 unsigned char *samples;
445};
446
447enum
448{
451};
452
453/* Create a new pixmap from a warped section of another.
454 *
455 * Colorspace, resolution etc are inherited from the original.
456 * points give the corner points within the original pixmap of a
457 * (convex) quadrilateral. These corner points will be 'warped' to be
458 * the corner points of the returned bitmap, which will have the given
459 * width/height.
460 */
461fz_pixmap *
462fz_warp_pixmap(fz_context *ctx, fz_pixmap *src, fz_quad points, int width, int height);
463
464/* As for fz_warp_pixmap, where width/height are automatically 'guessed'. */
465fz_pixmap *
467
468/* Search for a "document" within a pixmap (greyscale or rgb, no alpha).
469 *
470 * points should point to an array of 4 fz_points.
471 *
472 * If the function return false, no document was found.
473 * If true, points has been updated to include the corner positions of
474 * the detected document within the src image.
475 */
476int
478
479/*
480 Convert between different separation results.
481*/
483
484/*
485 * Extract alpha channel as a separate pixmap.
486 * Returns NULL if there is no alpha channel in the source.
487 */
489
490/*
491 * Combine a pixmap without an alpha channel with a soft mask.
492 */
494
495/*
496 * Scale the pixmap up or down in size to fit the rectangle. Will return `NULL`
497 * if the scaling factors are out of range. This applies fancy filtering and
498 * will anti-alias the edges for subpixel positioning if using non-integer
499 * coordinates. If the clip rectangle is set, the returned pixmap may be subset
500 * to fit the clip rectangle. Pass `NULL` to the clip if you want the whole
501 * pixmap scaled.
502 */
503fz_pixmap *fz_scale_pixmap(fz_context *ctx, fz_pixmap *src, float x, float y, float w, float h, const fz_irect *clip);
504
505/*
506 * Reduces size to:
507 * tile->w => (tile->w + 2^factor-1) / 2^factor
508 * tile->h => (tile->h + 2^factor-1) / 2^factor
509 */
510void fz_subsample_pixmap(fz_context *ctx, fz_pixmap *tile, int factor);
511
512/*
513 * Copies r (clipped to both src and dest) in src to dest.
514 */
516
517#endif
int fz_pixmap_y(fz_context *ctx, const fz_pixmap *pix)
void fz_tint_pixmap(fz_context *ctx, fz_pixmap *pix, int black, int white)
void fz_subsample_pixmap(fz_context *ctx, fz_pixmap *tile, int factor)
fz_pixmap * fz_clone_pixmap_area_with_different_seps(fz_context *ctx, fz_pixmap *src, const fz_irect *bbox, fz_colorspace *dcs, fz_separations *seps, fz_color_params color_params, fz_default_colorspaces *default_cs)
void fz_md5_pixmap(fz_context *ctx, fz_pixmap *pixmap, unsigned char digest[16])
int fz_pixmap_width(fz_context *ctx, const fz_pixmap *pix)
void fz_drop_pixmap(fz_context *ctx, fz_pixmap *pix)
size_t fz_pixmap_size(fz_context *ctx, fz_pixmap *pix)
fz_pixmap * fz_new_pixmap_from_pixmap(fz_context *ctx, fz_pixmap *pixmap, const fz_irect *rect)
fz_pixmap * fz_new_pixmap_from_alpha_channel(fz_context *ctx, fz_pixmap *src)
void fz_decode_tile(fz_context *ctx, fz_pixmap *pix, const float *decode)
int fz_detect_document(fz_context *ctx, fz_quad *points, fz_pixmap *src)
void fz_fill_pixmap_with_color(fz_context *ctx, fz_pixmap *pix, fz_colorspace *colorspace, float *color, fz_color_params color_params)
void fz_clear_pixmap_rect_with_value(fz_context *ctx, fz_pixmap *pix, int value, fz_irect r)
fz_pixmap * fz_alpha_from_gray(fz_context *ctx, fz_pixmap *gray)
fz_pixmap * fz_scale_pixmap(fz_context *ctx, fz_pixmap *src, float x, float y, float w, float h, const fz_irect *clip)
void fz_clear_pixmap_with_value(fz_context *ctx, fz_pixmap *pix, int value)
int fz_pixmap_spots(fz_context *ctx, const fz_pixmap *pix)
void fz_clear_pixmap(fz_context *ctx, fz_pixmap *pix)
@ FZ_PIXMAP_FLAG_INTERPOLATE
Definition pixmap.h:449
@ FZ_PIXMAP_FLAG_FREE_SAMPLES
Definition pixmap.h:450
int fz_pixmap_stride(fz_context *ctx, const fz_pixmap *pix)
void fz_invert_pixmap(fz_context *ctx, fz_pixmap *pix)
fz_pixmap * fz_keep_pixmap(fz_context *ctx, fz_pixmap *pix)
void fz_gamma_pixmap(fz_context *ctx, fz_pixmap *pix, float gamma)
void fz_set_pixmap_resolution(fz_context *ctx, fz_pixmap *pix, int xres, int yres)
struct fz_overprint fz_overprint
Definition pixmap.h:41
fz_irect fz_pixmap_bbox(fz_context *ctx, const fz_pixmap *pix)
int fz_pixmap_colorants(fz_context *ctx, const fz_pixmap *pix)
fz_colorspace * fz_pixmap_colorspace(fz_context *ctx, const fz_pixmap *pix)
fz_pixmap * fz_autowarp_pixmap(fz_context *ctx, fz_pixmap *src, fz_quad points)
fz_pixmap * fz_new_pixmap_with_bbox_and_data(fz_context *ctx, fz_colorspace *colorspace, fz_irect rect, fz_separations *seps, int alpha, unsigned char *samples)
void fz_invert_pixmap_luminance(fz_context *ctx, fz_pixmap *pix)
fz_pixmap * fz_new_pixmap_with_bbox(fz_context *ctx, fz_colorspace *colorspace, fz_irect bbox, fz_separations *seps, int alpha)
int fz_pixmap_alpha(fz_context *ctx, const fz_pixmap *pix)
int fz_pixmap_components(fz_context *ctx, const fz_pixmap *pix)
unsigned char * fz_pixmap_samples(fz_context *ctx, const fz_pixmap *pix)
fz_pixmap * fz_new_pixmap_from_color_and_mask(fz_context *ctx, fz_pixmap *color, fz_pixmap *mask)
fz_pixmap * fz_convert_pixmap(fz_context *ctx, const fz_pixmap *pix, fz_colorspace *cs_des, fz_colorspace *prf, fz_default_colorspaces *default_cs, fz_color_params color_params, int keep_alpha)
fz_pixmap * fz_clone_pixmap(fz_context *ctx, const fz_pixmap *old)
fz_pixmap * fz_new_pixmap_with_data(fz_context *ctx, fz_colorspace *colorspace, int w, int h, fz_separations *seps, int alpha, int stride, unsigned char *samples)
int fz_pixmap_x(fz_context *ctx, const fz_pixmap *pix)
fz_pixmap * fz_alpha_from_rgb(fz_context *ctx, fz_pixmap *color)
void fz_invert_pixmap_raw(fz_context *ctx, fz_pixmap *pix)
fz_stream * fz_unpack_stream(fz_context *ctx, fz_stream *src, int depth, int w, int h, int n, int indexed, int pad, int skip)
fz_pixmap * fz_warp_pixmap(fz_context *ctx, fz_pixmap *src, fz_quad points, int width, int height)
int fz_pixmap_height(fz_context *ctx, const fz_pixmap *pix)
int fz_is_pixmap_monochrome(fz_context *ctx, fz_pixmap *pixmap)
void fz_invert_pixmap_rect(fz_context *ctx, fz_pixmap *image, fz_irect rect)
fz_pixmap * fz_new_pixmap(fz_context *ctx, fz_colorspace *cs, int w, int h, fz_separations *seps, int alpha)
void fz_copy_pixmap_rect(fz_context *ctx, fz_pixmap *dest, fz_pixmap *src, fz_irect r, const fz_default_colorspaces *default_cs)
void fz_invert_pixmap_alpha(fz_context *ctx, fz_pixmap *pix)
struct fz_separations fz_separations
Definition separation.h:43
Definition color.h:72
Definition color.h:417
Definition context.h:886
Definition color.h:339
Definition geometry.h:248
Definition pixmap.h:432
unsigned char flags
Definition pixmap.h:438
fz_separations * seps
Definition pixmap.h:440
int xres
Definition pixmap.h:441
int yres
Definition pixmap.h:441
int w
Definition pixmap.h:434
fz_colorspace * colorspace
Definition pixmap.h:442
int h
Definition pixmap.h:434
int x
Definition pixmap.h:434
unsigned char * samples
Definition pixmap.h:443
unsigned char alpha
Definition pixmap.h:437
fz_pixmap * underlying
Definition pixmap.h:444
unsigned char n
Definition pixmap.h:435
unsigned char s
Definition pixmap.h:436
ptrdiff_t stride
Definition pixmap.h:439
fz_storable storable
Definition pixmap.h:433
int y
Definition pixmap.h:434
Definition geometry.h:782
Definition store.h:76
Definition stream.h:320