comparison mupdf-source/include/mupdf/fitz/compress.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_FITZ_COMPRESS_H
24 #define MUPDF_FITZ_COMPRESS_H
25
26 #include "mupdf/fitz/system.h"
27 #include "mupdf/fitz/buffer.h"
28 #include "mupdf/fitz/pixmap.h"
29
30 typedef enum
31 {
32 FZ_DEFLATE_NONE = 0,
33 FZ_DEFLATE_BEST_SPEED = 1,
34 FZ_DEFLATE_BEST = 9,
35 FZ_DEFLATE_DEFAULT = -1
36 } fz_deflate_level;
37
38 /**
39 Returns the upper bound on the
40 size of flated data of length size.
41 */
42 size_t fz_deflate_bound(fz_context *ctx, size_t size);
43
44 /**
45 Compress source_length bytes of data starting
46 at source, into a buffer of length *compressed_length, starting at
47 dest. *compressed_length will be updated on exit to contain the size
48 actually used.
49 */
50 void fz_deflate(fz_context *ctx, unsigned char *dest, size_t *compressed_length, const unsigned char *source, size_t source_length, fz_deflate_level level);
51
52 /**
53 Compress source_length bytes of data starting
54 at source, into a new memory block malloced for that purpose.
55 *compressed_length is updated on exit to contain the size used.
56 Ownership of the block is returned from this function, and the
57 caller is therefore responsible for freeing it. The block may be
58 considerably larger than is actually required. The caller is
59 free to fz_realloc it down if it wants to.
60 */
61 unsigned char *fz_new_deflated_data(fz_context *ctx, size_t *compressed_length, const unsigned char *source, size_t source_length, fz_deflate_level level);
62
63 /**
64 Compress the contents of a fz_buffer into a
65 new block malloced for that purpose. *compressed_length is
66 updated on exit to contain the size used. Ownership of the block
67 is returned from this function, and the caller is therefore
68 responsible for freeing it. The block may be considerably larger
69 than is actually required. The caller is free to fz_realloc it
70 down if it wants to.
71 */
72 unsigned char *fz_new_deflated_data_from_buffer(fz_context *ctx, size_t *compressed_length, fz_buffer *buffer, fz_deflate_level level);
73
74 typedef enum
75 {
76 FZ_BROTLI_NONE = 0,
77 FZ_BROTLI_BEST_SPEED = 1,
78 FZ_BROTLI_BEST = 11,
79 FZ_BROTLI_DEFAULT = 6 /* Guess */
80 } fz_brotli_level;
81
82 /**
83 Returns the upper bound on the
84 size of brotli compressed data of length size.
85 */
86 size_t fz_brotli_bound(fz_context *ctx, size_t size);
87
88 /**
89 Compress source_length bytes of data starting
90 at source, into a buffer of length *destLen, starting at dest.
91 *compressed_length will be updated on exit to contain the size
92 actually used.
93 */
94 void fz_compress_brotli(fz_context *ctx, unsigned char *dest, size_t *compressed_length, const unsigned char *source, size_t source_length, fz_brotli_level level);
95
96 /**
97 Compress source_length bytes of data starting
98 at source, into a new memory block malloced for that purpose.
99 *compressed_length is updated on exit to contain the size used.
100 Ownership of the block is returned from this function, and the
101 caller is therefore responsible for freeing it. The block may be
102 considerably larger than is actually required. The caller is
103 free to fz_realloc it down if it wants to.
104 */
105 unsigned char *fz_new_brotli_data(fz_context *ctx, size_t *compressed_length, const unsigned char *source, size_t source_length, fz_brotli_level level);
106
107 /**
108 Compress the contents of a fz_buffer into a
109 new block malloced for that purpose. *compressed_length is
110 updated on exit to contain the size used. Ownership of the block
111 is returned from this function, and the caller is therefore
112 responsible for freeing it. The block may be considerably larger
113 than is actually required. The caller is free to fz_realloc it
114 down if it wants to.
115 */
116 unsigned char *fz_new_brotli_data_from_buffer(fz_context *ctx, size_t *compressed_length, fz_buffer *buffer, fz_brotli_level level);
117
118 /**
119 Compress bitmap data as CCITT Group 3 1D fax image.
120 Creates a stream assuming the default PDF parameters,
121 except the number of columns.
122 */
123 fz_buffer *fz_compress_ccitt_fax_g3(fz_context *ctx, const unsigned char *data, int columns, int rows, ptrdiff_t stride);
124
125 /**
126 Compress bitmap data as CCITT Group 4 2D fax image.
127 Creates a stream assuming the default PDF parameters, except
128 K=-1 and the number of columns.
129 */
130 fz_buffer *fz_compress_ccitt_fax_g4(fz_context *ctx, const unsigned char *data, int columns, int rows, ptrdiff_t stride);
131
132 #endif