Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
Download
7858 views
1
#ifndef MUPDF_FITZ_IMAGE_H
2
#define MUPDF_FITZ_IMAGE_H
3
4
#include "mupdf/fitz/system.h"
5
#include "mupdf/fitz/context.h"
6
#include "mupdf/fitz/store.h"
7
#include "mupdf/fitz/colorspace.h"
8
#include "mupdf/fitz/pixmap.h"
9
10
#include "mupdf/fitz/buffer.h"
11
#include "mupdf/fitz/stream.h"
12
#include "mupdf/fitz/compressed-buffer.h"
13
14
/*
15
Images are storable objects from which we can obtain fz_pixmaps.
16
These may be implemented as simple wrappers around a pixmap, or as
17
more complex things that decode at different subsample settings on
18
demand.
19
*/
20
typedef struct fz_image_s fz_image;
21
22
/*
23
fz_new_pixmap_from_image: Called to get a handle to a pixmap from an image.
24
25
image: The image to retrieve a pixmap from.
26
27
w: The desired width (in pixels). This may be completely ignored, but
28
may serve as an indication of a suitable subsample factor to use for
29
image types that support this.
30
31
h: The desired height (in pixels). This may be completely ignored, but
32
may serve as an indication of a suitable subsample factor to use for
33
image types that support this.
34
35
Returns a non NULL pixmap pointer. May throw exceptions.
36
*/
37
fz_pixmap *fz_new_pixmap_from_image(fz_context *ctx, fz_image *image, int w, int h);
38
39
/*
40
fz_drop_image: Drop a reference to an image.
41
42
image: The image to drop a reference to.
43
*/
44
void fz_drop_image(fz_context *ctx, fz_image *image);
45
46
/*
47
fz_keep_image: Increment the reference count of an image.
48
49
image: The image to take a reference to.
50
51
Returns a pointer to the image.
52
*/
53
fz_image *fz_keep_image(fz_context *ctx, fz_image *image);
54
55
fz_image *fz_new_image(fz_context *ctx, int w, int h, int bpc, fz_colorspace *colorspace, int xres, int yres, int interpolate, int imagemask, float *decode, int *colorkey, fz_compressed_buffer *buffer, fz_image *mask);
56
fz_image *fz_new_image_from_pixmap(fz_context *ctx, fz_pixmap *pixmap, fz_image *mask);
57
fz_image *fz_new_image_from_data(fz_context *ctx, unsigned char *data, int len);
58
fz_image *fz_new_image_from_buffer(fz_context *ctx, fz_buffer *buffer);
59
fz_pixmap *fz_image_get_pixmap(fz_context *ctx, fz_image *image, int w, int h);
60
void fz_drop_image_imp(fz_context *ctx, fz_storable *image);
61
fz_pixmap *fz_decomp_image_from_stream(fz_context *ctx, fz_stream *stm, fz_image *image, int indexed, int l2factor, int native_l2factor);
62
fz_pixmap *fz_expand_indexed_pixmap(fz_context *ctx, fz_pixmap *src);
63
64
struct fz_image_s
65
{
66
fz_storable storable;
67
int w, h, n, bpc;
68
fz_image *mask;
69
fz_colorspace *colorspace;
70
fz_pixmap *(*get_pixmap)(fz_context *, fz_image *, int w, int h);
71
fz_compressed_buffer *buffer;
72
int colorkey[FZ_MAX_COLORS * 2];
73
float decode[FZ_MAX_COLORS * 2];
74
int imagemask;
75
int interpolate;
76
int usecolorkey;
77
fz_pixmap *tile; /* Private to the implementation */
78
int xres; /* As given in the image, not necessarily as rendered */
79
int yres; /* As given in the image, not necessarily as rendered */
80
int invert_cmyk_jpeg;
81
};
82
83
fz_pixmap *fz_load_jpx(fz_context *ctx, unsigned char *data, int size, fz_colorspace *cs, int indexed);
84
fz_pixmap *fz_load_png(fz_context *ctx, unsigned char *data, int size);
85
fz_pixmap *fz_load_tiff(fz_context *ctx, unsigned char *data, int size);
86
fz_pixmap *fz_load_jxr(fz_context *ctx, unsigned char *data, int size);
87
88
void fz_load_jpeg_info(fz_context *ctx, unsigned char *data, int size, int *w, int *h, int *xres, int *yres, fz_colorspace **cspace);
89
void fz_load_png_info(fz_context *ctx, unsigned char *data, int size, int *w, int *h, int *xres, int *yres, fz_colorspace **cspace);
90
void fz_load_tiff_info(fz_context *ctx, unsigned char *data, int size, int *w, int *h, int *xres, int *yres, fz_colorspace **cspace);
91
void fz_load_jxr_info(fz_context *ctx, unsigned char *data, int size, int *w, int *h, int *xres, int *yres, fz_colorspace **cspace);
92
93
int fz_load_tiff_subimage_count(fz_context *ctx, unsigned char *buf, int len);
94
fz_pixmap *fz_load_tiff_subimage(fz_context *ctx, unsigned char *buf, int len, int subimage);
95
96
void fz_image_get_sanitised_res(fz_image *image, int *xres, int *yres);
97
98
#endif
99
100