1 #ifndef MUPDF_FITZ_COMPRESS_H 2 #define MUPDF_FITZ_COMPRESS_H 3 4 #include "mupdf/fitz/system.h" 5 6 typedef enum 7 { 8 FZ_DEFLATE_NONE = 0, 9 FZ_DEFLATE_BEST_SPEED = 1, 10 FZ_DEFLATE_BEST = 9, 11 FZ_DEFLATE_DEFAULT = -1 12 } fz_deflate_level; 13 14 /** 15 Returns the upper bound on the 16 size of flated data of length size. 17 */ 18 size_t fz_deflate_bound(fz_context *ctx, size_t size); 19 20 /** 21 Compress source_length bytes of data starting 22 at source, into a buffer of length *destLen, starting at dest. 23 *compressed_length will be updated on exit to contain the size 24 actually used. 25 */ 26 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); 27 28 /** 29 Compress source_length bytes of data starting 30 at source, into a new memory block malloced for that purpose. 31 *compressed_length is updated on exit to contain the size used. 32 Ownership of the block is returned from this function, and the 33 caller is therefore responsible for freeing it. The block may be 34 considerably larger than is actually required. The caller is 35 free to fz_realloc it down if it wants to. 36 */ 37 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); 38 39 /** 40 Compress the contents of a fz_buffer into a 41 new block malloced for that purpose. *compressed_length is 42 updated on exit to contain the size used. Ownership of the block 43 is returned from this function, and the caller is therefore 44 responsible for freeing it. The block may be considerably larger 45 than is actually required. The caller is free to fz_realloc it 46 down if it wants to. 47 */ 48 unsigned char *fz_new_deflated_data_from_buffer(fz_context *ctx, size_t *compressed_length, fz_buffer *buffer, fz_deflate_level level); 49 50 /** 51 Compress bitmap data as CCITT Group 3 1D fax image. 52 Creates a stream assuming the default PDF parameters, 53 except the number of columns. 54 */ 55 fz_buffer *fz_compress_ccitt_fax_g3(fz_context *ctx, const unsigned char *data, int columns, int rows); 56 57 /** 58 Compress bitmap data as CCITT Group 4 2D fax image. 59 Creates a stream assuming the default PDF parameters, except 60 K=-1 and the number of columns. 61 */ 62 fz_buffer *fz_compress_ccitt_fax_g4(fz_context *ctx, const unsigned char *data, int columns, int rows); 63 64 #endif 65