summaryrefslogtreecommitdiff
path: root/fitz
diff options
context:
space:
mode:
authorTor Andersson <tor.andersson@artifex.com>2012-03-07 15:31:36 +0100
committerTor Andersson <tor.andersson@artifex.com>2012-03-07 15:31:36 +0100
commit16c6f406911b9c93491a244cfe1ec37603284489 (patch)
tree2c51405766263722bcf9c4cad6c9f68a6447717d /fitz
parentd55162d649a12d62a1d1c738d99ca9dee7de575d (diff)
downloadmupdf-16c6f406911b9c93491a244cfe1ec37603284489.tar.xz
Splitting tweaks.
Diffstat (limited to 'fitz')
-rw-r--r--fitz/base_string.c7
-rw-r--r--fitz/fitz-internal.h97
-rw-r--r--fitz/fitz.h92
3 files changed, 87 insertions, 109 deletions
diff --git a/fitz/base_string.c b/fitz/base_string.c
index 6fdfef62..8ab09438 100644
--- a/fitz/base_string.c
+++ b/fitz/base_string.c
@@ -1,12 +1,5 @@
#include "fitz-internal.h"
-int
-fz_is_big_endian(void)
-{
- static const int one = 1;
- return *(char*)&one == 0;
-}
-
char *
fz_strsep(char **stringp, const char *delim)
{
diff --git a/fitz/fitz-internal.h b/fitz/fitz-internal.h
index 4ede601d..f9175c65 100644
--- a/fitz/fitz-internal.h
+++ b/fitz/fitz-internal.h
@@ -1,5 +1,5 @@
-#ifndef _FITZ_INTERNAL_H_
-#define _FITZ_INTERNAL_H_
+#ifndef FITZ_INTERNAL_H
+#define FITZ_INTERNAL_H
#include "fitz.h"
@@ -57,11 +57,6 @@ fz_unlock(fz_context *ctx, int lock)
/* Range checking atof */
float fz_atof(const char *s);
-/* utf-8 encoding and decoding */
-int chartorune(int *rune, char *str);
-int runetochar(char *str, int *rune);
-int runelen(int c);
-
/*
* Generic hash-table with fixed-length keys.
*/
@@ -109,11 +104,6 @@ static inline int fz_mul255(int a, int b)
* AMOUNT (in the 0...256 range). */
#define FZ_BLEND(SRC, DST, AMOUNT) ((((SRC)-(DST))*(AMOUNT) + ((DST)<<8))>>8)
-
-float fz_matrix_expansion(fz_matrix m);
-float fz_matrix_max_expansion(fz_matrix m);
-
-
void fz_gridfit_matrix(fz_matrix *m);
/*
@@ -190,19 +180,6 @@ void aes_crypt_cbc( fz_aes *ctx, int mode, int length,
const unsigned char *input,
unsigned char *output );
-struct fz_buffer_s
-{
- int refs;
- unsigned char *data;
- int cap, len;
-};
-
-fz_buffer *fz_new_buffer(fz_context *ctx, int size);
-
-void fz_resize_buffer(fz_context *ctx, fz_buffer *buf, int size);
-void fz_grow_buffer(fz_context *ctx, fz_buffer *buf);
-void fz_trim_buffer(fz_context *ctx, fz_buffer *buf);
-
/*
Resource store
@@ -397,46 +374,13 @@ struct fz_stream_s
unsigned char buf[4096];
};
-/*
- fz_open_file: Open the named file and wrap it in a stream.
-
- filename: Path to a file as it would be given to open(2).
-*/
-fz_stream *fz_open_file(fz_context *ctx, const char *filename);
-
-/*
- fz_open_file_w: Open the named file and wrap it in a stream.
-
- This function is only available when compiling for Win32.
-
- filename: Wide character path to the file as it would be given
- to _wopen().
-*/
-fz_stream *fz_open_file_w(fz_context *ctx, const wchar_t *filename);
-
-
-/*
- fz_open_buffer: XXX
-*/
-fz_stream *fz_open_buffer(fz_context *ctx, fz_buffer *buf);
-
-/*
- fz_open_memory: XXX
-*/
-fz_stream *fz_open_memory(fz_context *ctx, unsigned char *data, int len);
-
void fz_lock_stream(fz_stream *stm);
fz_stream *fz_new_stream(fz_context *ctx, void*, int(*)(fz_stream*, unsigned char*, int), void(*)(fz_context *, void *));
fz_stream *fz_keep_stream(fz_stream *stm);
void fz_fill_buffer(fz_stream *stm);
-int fz_tell(fz_stream *stm);
-void fz_seek(fz_stream *stm, int offset, int whence);
-
-int fz_read(fz_stream *stm, unsigned char *buf, int len);
void fz_read_line(fz_stream *stm, char *buf, int max);
-fz_buffer *fz_read_all(fz_stream *stm, int initial);
static inline int fz_read_byte(fz_stream *stm)
{
@@ -583,27 +527,6 @@ struct fz_pixmap_s
int free_samples;
};
-
-fz_pixmap *fz_new_pixmap_with_data(fz_context *ctx, fz_colorspace *colorspace, int w, int h, unsigned char *samples);
-
-/*
- fz_new_pixmap_with_rect_and_data: Create a pixmap using the
- provided buffer for pixel data.
-
- While fz_new_pixmap_with_rect allocates its own buffer for
- pixel data, fz_new_pixmap_with_rect_and_data lets the caller
- allocate and provide a buffer to be used. Otherwise the two
- functions are identical.
-
- samples: An array of pixel samples. The created pixmap will
- keep a pointer to the array so it must not be modified or
- freed until the created pixmap is dropped and freed by
- fz_drop_pixmap.
-*/
-fz_pixmap *fz_new_pixmap_with_rect_and_data(fz_context *ctx,
-fz_colorspace *colorspace, fz_bbox bbox, unsigned char *samples);
-fz_pixmap *fz_new_pixmap(fz_context *ctx, fz_colorspace *, int w, int h);
-
void fz_free_pixmap_imp(fz_context *ctx, fz_storable *pix);
void fz_clear_pixmap_rect_with_value(fz_context *ctx, fz_pixmap *pix, int value, fz_bbox r);
@@ -628,18 +551,6 @@ fz_pixmap *fz_load_jpeg(fz_context *doc, unsigned char *data, int size);
fz_pixmap *fz_load_png(fz_context *doc, unsigned char *data, int size);
fz_pixmap *fz_load_tiff(fz_context *doc, unsigned char *data, int size);
-struct fz_bitmap_s
-{
- int refs;
- int w, h, stride, n;
- unsigned char *samples;
-};
-
-fz_bitmap *fz_new_bitmap(fz_context *ctx, int w, int h, int n);
-fz_bitmap *fz_keep_bitmap(fz_context *ctx, fz_bitmap *bit);
-void fz_clear_bitmap(fz_context *ctx, fz_bitmap *bit);
-
-
struct fz_halftone_s
{
int refs;
@@ -650,7 +561,6 @@ struct fz_halftone_s
fz_halftone *fz_new_halftone(fz_context *ctx, int num_comps);
fz_halftone *fz_keep_halftone(fz_context *ctx, fz_halftone *half);
-
struct fz_colorspace_s
{
fz_storable storable;
@@ -669,9 +579,6 @@ void fz_drop_colorspace(fz_context *ctx, fz_colorspace *colorspace);
void fz_free_colorspace_imp(fz_context *ctx, fz_storable *colorspace);
void fz_convert_color(fz_context *ctx, fz_colorspace *srcs, float *srcv, fz_colorspace *dsts, float *dstv);
-void fz_convert_pixmap(fz_context *ctx, fz_pixmap *src, fz_pixmap *dst);
-
-fz_colorspace *fz_find_device_colorspace(char *name);
/*
* Fonts come in two variants:
diff --git a/fitz/fitz.h b/fitz/fitz.h
index 732f2fc7..4de15e0e 100644
--- a/fitz/fitz.h
+++ b/fitz/fitz.h
@@ -1,5 +1,5 @@
-#ifndef _FITZ_H_
-#define _FITZ_H_
+#ifndef FITZ_H
+#define FITZ_H
/*
Include the standard libc headers.
@@ -351,8 +351,10 @@ char *fz_strsep(char **stringp, const char *delim);
int fz_strlcpy(char *dst, const char *src, int n);
int fz_strlcat(char *dst, const char *src, int n);
-/* runtime (hah!) test for endian-ness */
-int fz_is_big_endian(void);
+/* utf-8 encoding and decoding */
+int chartorune(int *rune, char *str);
+int runetochar(char *str, int *rune);
+int runelen(int c);
/* getopt */
extern int fz_getopt(int nargc, char * const *nargv, const char *ostr);
@@ -590,6 +592,12 @@ fz_matrix fz_invert_matrix(fz_matrix matrix);
int fz_is_rectilinear(fz_matrix m);
/*
+ fz_matrix_expansion: Calculate average scaling factor of matrix.
+*/
+float fz_matrix_expansion(fz_matrix m); /* sumatrapdf */
+float fz_matrix_max_expansion(fz_matrix m);
+
+/*
fz_round_rect: Convert a rect into a bounding box.
Coordinates in a bounding box are integers, so rounding of the
@@ -701,14 +709,25 @@ fz_rect fz_transform_rect(fz_matrix transform, fz_rect rect);
fz_bbox fz_transform_bbox(fz_matrix matrix, fz_bbox bbox);
/*
- fz_buffer is a XXX
+ fz_buffer is a wrapper around a dynamically allocated array of bytes
*/
typedef struct fz_buffer_s fz_buffer;
-fz_buffer *fz_keep_buffer(fz_context *ctx, fz_buffer *buf);
+struct fz_buffer_s
+{
+ int refs;
+ unsigned char *data;
+ int cap, len;
+};
+fz_buffer *fz_new_buffer(fz_context *ctx, int size);
+fz_buffer *fz_keep_buffer(fz_context *ctx, fz_buffer *buf);
void fz_drop_buffer(fz_context *ctx, fz_buffer *buf);
+void fz_resize_buffer(fz_context *ctx, fz_buffer *buf, int size);
+void fz_grow_buffer(fz_context *ctx, fz_buffer *buf);
+void fz_trim_buffer(fz_context *ctx, fz_buffer *buf);
+
/*
fz_stream is a buffered reader capable of seeking in both
directions.
@@ -721,6 +740,23 @@ void fz_drop_buffer(fz_context *ctx, fz_buffer *buf);
typedef struct fz_stream_s fz_stream;
/*
+ fz_open_file: Open the named file and wrap it in a stream.
+
+ filename: Path to a file as it would be given to open(2).
+*/
+fz_stream *fz_open_file(fz_context *ctx, const char *filename);
+
+/*
+ fz_open_file_w: Open the named file and wrap it in a stream.
+
+ This function is only available when compiling for Win32.
+
+ filename: Wide character path to the file as it would be given
+ to _wopen().
+*/
+fz_stream *fz_open_file_w(fz_context *ctx, const wchar_t *filename);
+
+/*
fz_open_fd: Wrap an open file descriptor in a stream.
file: An open file descriptor supporting bidirectional
@@ -732,6 +768,16 @@ typedef struct fz_stream_s fz_stream;
fz_stream *fz_open_fd(fz_context *ctx, int file);
/*
+ fz_open_memory: XXX
+*/
+fz_stream *fz_open_memory(fz_context *ctx, unsigned char *data, int len);
+
+/*
+ fz_open_buffer: XXX
+*/
+fz_stream *fz_open_buffer(fz_context *ctx, fz_buffer *buf);
+
+/*
fz_close: Close an open stream.
Drops a reference for the stream. Once no references remain
@@ -742,6 +788,11 @@ fz_stream *fz_open_fd(fz_context *ctx, int file);
*/
void fz_close(fz_stream *stm);
+int fz_tell(fz_stream *stm);
+void fz_seek(fz_stream *stm, int offset, int whence);
+int fz_read(fz_stream *stm, unsigned char *buf, int len);
+fz_buffer *fz_read_all(fz_stream *stm, int initial);
+
/*
Bitmaps have 1 bit per component. Only used for creating halftoned
versions of contone buffers, and saving out. Samples are stored msb
@@ -749,6 +800,16 @@ void fz_close(fz_stream *stm);
*/
typedef struct fz_bitmap_s fz_bitmap;
+struct fz_bitmap_s
+{
+ int refs;
+ int w, h, stride, n;
+ unsigned char *samples;
+};
+
+fz_bitmap *fz_new_bitmap(fz_context *ctx, int w, int h, int n);
+fz_bitmap *fz_keep_bitmap(fz_context *ctx, fz_bitmap *bit);
+void fz_clear_bitmap(fz_context *ctx, fz_bitmap *bit);
void fz_drop_bitmap(fz_context *ctx, fz_bitmap *bit);
/*
@@ -763,6 +824,8 @@ typedef struct fz_colorspace_s fz_colorspace;
fz_bbox fz_bound_pixmap(fz_pixmap *pix);
+fz_pixmap *fz_new_pixmap(fz_context *ctx, fz_colorspace *, int w, int h);
+
/*
fz_new_pixmap_with_rect: Create a pixmap of a given size,
location and pixel format.
@@ -779,6 +842,17 @@ fz_bbox fz_bound_pixmap(fz_pixmap *pix);
*/
fz_pixmap *fz_new_pixmap_with_rect(fz_context *ctx, fz_colorspace *colorspace, fz_bbox bbox);
+fz_pixmap *fz_new_pixmap_with_data(fz_context *ctx, fz_colorspace *colorspace, int w, int h, unsigned char *samples);
+
+/*
+ fz_keep_pixmap: Take a reference to a pixmap.
+
+ pix: The pixmap to increment the reference for.
+
+ Returns pix. Does not throw exceptions.
+*/
+fz_pixmap *fz_new_pixmap_with_rect_and_data(fz_context *ctx, fz_colorspace *colorspace, fz_bbox bbox, unsigned char *samples);
+
/*
fz_keep_pixmap: Take a reference to a pixmap.
@@ -899,6 +973,10 @@ fz_bitmap *fz_halftone_pixmap(fz_context *ctx, fz_pixmap *pix, fz_halftone *ht);
Colorspace resources.
*/
+void fz_convert_pixmap(fz_context *ctx, fz_pixmap *src, fz_pixmap *dst);
+
+fz_colorspace *fz_find_device_colorspace(char *name);
+
/*
fz_device_gray: XXX
*/
@@ -1418,4 +1496,4 @@ void fz_run_page(fz_document *doc, fz_page *page, fz_device *dev, fz_matrix tran
*/
void fz_free_page(fz_document *doc, fz_page *page);
-#endif /* _FITZ_H_ */
+#endif