diff options
author | Robin Watts <robin.watts@artifex.com> | 2016-04-14 13:51:32 +0100 |
---|---|---|
committer | Robin Watts <robin.watts@artifex.com> | 2016-04-28 12:30:43 +0100 |
commit | 44fff08dc64d358df441a9e615bbaacf7b01d54a (patch) | |
tree | bab4f36472952ccdfff594fd699230f2f15b1b23 /include | |
parent | 88e9fd50724cff8d656060715fa56409ba7dab84 (diff) | |
download | mupdf-44fff08dc64d358df441a9e615bbaacf7b01d54a.tar.xz |
Refactor fz_image code cases.
Split compressed images (images based on a compressed buffer)
and pixmap images (images based on a pixmap) out into separate
subclasses.
Diffstat (limited to 'include')
-rw-r--r-- | include/mupdf/fitz/image.h | 26 | ||||
-rw-r--r-- | include/mupdf/pdf/xref.h | 2 |
2 files changed, 19 insertions, 9 deletions
diff --git a/include/mupdf/fitz/image.h b/include/mupdf/fitz/image.h index 7ddbfb69..41c4b80c 100644 --- a/include/mupdf/fitz/image.h +++ b/include/mupdf/fitz/image.h @@ -18,6 +18,7 @@ demand. */ typedef struct fz_image_s fz_image; +typedef struct fz_compressed_image_s fz_compressed_image; /* fz_get_pixmap_from_image: Called to get a handle to a pixmap from an image. @@ -58,14 +59,20 @@ void fz_drop_image(fz_context *ctx, fz_image *image); */ fz_image *fz_keep_image(fz_context *ctx, fz_image *image); -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); +typedef void (fz_drop_image_fn)(fz_context *ctx, fz_image *image); +typedef fz_pixmap *(fz_image_get_pixmap_fn)(fz_context *, fz_image *, fz_irect *, int, int, int *); +typedef size_t (fz_image_get_size_fn)(fz_context *, fz_image *); + +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_image *mask, int size, fz_image_get_pixmap_fn *get, fz_image_get_size_fn *get_size, fz_drop_image_fn *drop); +fz_image *fz_new_image_from_compressed_buffer(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); fz_image *fz_new_image_from_pixmap(fz_context *ctx, fz_pixmap *pixmap, fz_image *mask); fz_image *fz_new_image_from_data(fz_context *ctx, unsigned char *data, int len); fz_image *fz_new_image_from_buffer(fz_context *ctx, fz_buffer *buffer); fz_image *fz_new_image_from_file(fz_context *ctx, const char *path); void fz_drop_image_imp(fz_context *ctx, fz_storable *image); -fz_pixmap *fz_decomp_image_from_stream(fz_context *ctx, fz_stream *stm, fz_image *image, fz_irect *subarea, int indexed, int l2factor); +fz_pixmap *fz_decomp_image_from_stream(fz_context *ctx, fz_stream *stm, fz_compressed_image *image, fz_irect *subarea, int indexed, int l2factor); fz_pixmap *fz_expand_indexed_pixmap(fz_context *ctx, fz_pixmap *src); +size_t fz_image_size(fz_context *ctx, fz_image *im); struct fz_image_s { @@ -77,18 +84,16 @@ struct fz_image_s unsigned int interpolate:1; unsigned int use_colorkey:1; unsigned int invert_cmyk_jpeg:1; + unsigned int decoded:1; fz_image *mask; int xres; /* As given in the image, not necessarily as rendered */ int yres; /* As given in the image, not necessarily as rendered */ fz_colorspace *colorspace; - fz_pixmap *(*get_pixmap)(fz_context *, fz_image *, fz_irect *subarea, int w, int h, int *l2factor); + fz_drop_image_fn *drop_image; + fz_image_get_pixmap_fn *get_pixmap; + fz_image_get_size_fn *get_size; int colorkey[FZ_MAX_COLORS * 2]; float decode[FZ_MAX_COLORS * 2]; - - /* Only 'standard' images use these currently. Maybe they should be - * moved out into a derived image class. */ - fz_compressed_buffer *buffer; - fz_pixmap *tile; }; fz_pixmap *fz_load_jpeg(fz_context *ctx, unsigned char *data, int size); @@ -111,4 +116,9 @@ fz_pixmap *fz_load_tiff_subimage(fz_context *ctx, unsigned char *buf, int len, i void fz_image_resolution(fz_image *image, int *xres, int *yres); +fz_pixmap *fz_compressed_image_tile(fz_context *ctx, fz_compressed_image *cimg); +void fz_set_compressed_image_tile(fz_context *ctx, fz_compressed_image *cimg, fz_pixmap *pix); +fz_compressed_buffer *fz_compressed_image_buffer(fz_context *ctx, fz_image *image); +void fz_set_compressed_image_buffer(fz_context *ctx, fz_compressed_image *cimg, fz_compressed_buffer *buf); + #endif diff --git a/include/mupdf/pdf/xref.h b/include/mupdf/pdf/xref.h index 410791c7..a6692cab 100644 --- a/include/mupdf/pdf/xref.h +++ b/include/mupdf/pdf/xref.h @@ -85,7 +85,7 @@ fz_stream *pdf_open_stream(fz_context *ctx, pdf_document *doc, int num, int gen) fz_stream *pdf_open_inline_stream(fz_context *ctx, pdf_document *doc, pdf_obj *stmobj, int length, fz_stream *chain, fz_compression_params *params); fz_compressed_buffer *pdf_load_compressed_stream(fz_context *ctx, pdf_document *doc, int num, int gen); -void pdf_load_compressed_inline_image(fz_context *ctx, pdf_document *doc, pdf_obj *dict, int length, fz_stream *cstm, int indexed, fz_image *image); +void pdf_load_compressed_inline_image(fz_context *ctx, pdf_document *doc, pdf_obj *dict, int length, fz_stream *cstm, int indexed, fz_compressed_image *image); fz_stream *pdf_open_stream_with_offset(fz_context *ctx, pdf_document *doc, int num, int gen, pdf_obj *dict, fz_off_t stm_ofs); fz_stream *pdf_open_compressed_stream(fz_context *ctx, fz_compressed_buffer *); fz_stream *pdf_open_contents_stream(fz_context *ctx, pdf_document *doc, pdf_obj *obj); |