summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorRobin Watts <robin.watts@artifex.com>2016-05-23 17:45:21 +0100
committerRobin Watts <robin.watts@artifex.com>2016-05-24 12:48:35 +0100
commitd0b78f4166a1503ce522944002b3aab035724cd9 (patch)
treeb8c680dc401db56a28be1110759219c7c175dd8d /include
parent841952db71d6541a2e98fd4d1d49dede284b2cf8 (diff)
downloadmupdf-d0b78f4166a1503ce522944002b3aab035724cd9.tar.xz
fz_pixmap revamp: add stride and make alpha optional
fz_pixmaps now have an explicit stride value. By default no change from before, but code all copes with extra gaps at the end of the line. The alpha data in fz_pixmaps is no longer compulsory. mudraw: use rgb not rgba (ppmraw), cmyk not cmyka (pkmraw). Update halftone code to not expect alpha plane. Update PNG writing to cope with alpha less input. Also hide repeated params within the png output context. ARM code needs updating.
Diffstat (limited to 'include')
-rw-r--r--include/mupdf/fitz/glyph-cache.h4
-rw-r--r--include/mupdf/fitz/output-pcl.h2
-rw-r--r--include/mupdf/fitz/output-png.h4
-rw-r--r--include/mupdf/fitz/output-pnm.h4
-rw-r--r--include/mupdf/fitz/output-ps.h2
-rw-r--r--include/mupdf/fitz/pixmap.h47
-rw-r--r--include/mupdf/fitz/util.h2
7 files changed, 47 insertions, 18 deletions
diff --git a/include/mupdf/fitz/glyph-cache.h b/include/mupdf/fitz/glyph-cache.h
index 6a60d7be..e3573356 100644
--- a/include/mupdf/fitz/glyph-cache.h
+++ b/include/mupdf/fitz/glyph-cache.h
@@ -26,8 +26,8 @@ fz_glyph *fz_render_t3_glyph(fz_context *ctx, fz_font *font, int cid, const fz_m
fz_pixmap *fz_render_t3_glyph_pixmap(fz_context *ctx, fz_font *font, int cid, const fz_matrix *trm, fz_colorspace *model, const fz_irect *scissor);
fz_glyph *fz_render_ft_stroked_glyph(fz_context *ctx, fz_font *font, int gid, const fz_matrix *trm, const fz_matrix *ctm, const fz_stroke_state *state);
fz_pixmap *fz_render_ft_stroked_glyph_pixmap(fz_context *ctx, fz_font *font, int gid, const fz_matrix *trm, const fz_matrix *ctm, const fz_stroke_state *state);
-fz_glyph *fz_render_glyph(fz_context *ctx, fz_font*, int, fz_matrix *, fz_colorspace *model, const fz_irect *scissor);
-fz_pixmap *fz_render_glyph_pixmap(fz_context *ctx, fz_font*, int, fz_matrix *, fz_colorspace *model, const fz_irect *scissor);
+fz_glyph *fz_render_glyph(fz_context *ctx, fz_font*, int, fz_matrix *, fz_colorspace *model, const fz_irect *scissor, int alpha);
+fz_pixmap *fz_render_glyph_pixmap(fz_context *ctx, fz_font*, int, fz_matrix *, const fz_irect *scissor);
fz_glyph *fz_render_stroked_glyph(fz_context *ctx, fz_font*, int, fz_matrix *, const fz_matrix *, const fz_stroke_state *stroke, const fz_irect *scissor);
fz_pixmap *fz_render_stroked_glyph_pixmap(fz_context *ctx, fz_font*, int, fz_matrix *, const fz_matrix *, const fz_stroke_state *stroke, const fz_irect *scissor);
void fz_render_t3_glyph_direct(fz_context *ctx, fz_device *dev, fz_font *font, int gid, const fz_matrix *trm, void *gstate, int nestedDepth);
diff --git a/include/mupdf/fitz/output-pcl.h b/include/mupdf/fitz/output-pcl.h
index 7b72c718..053af1e8 100644
--- a/include/mupdf/fitz/output-pcl.h
+++ b/include/mupdf/fitz/output-pcl.h
@@ -107,7 +107,7 @@ typedef struct fz_color_pcl_output_context_s fz_color_pcl_output_context;
fz_color_pcl_output_context *fz_write_color_pcl_header(fz_context *ctx, fz_output *out, int w, int h, int n, int xres, int yres, int pagenum, const fz_pcl_options *options);
-void fz_write_color_pcl_band(fz_context *ctx, fz_output *out, fz_color_pcl_output_context *poc, int w, int h, int n, int band, int bandheight, unsigned char *samples);
+void fz_write_color_pcl_band(fz_context *ctx, fz_output *out, fz_color_pcl_output_context *poc, int w, int h, int n, int stride, int band, int bandheight, unsigned char *samples);
void fz_write_color_pcl_trailer(fz_context *ctx, fz_output *out, fz_color_pcl_output_context *pcoc);
diff --git a/include/mupdf/fitz/output-png.h b/include/mupdf/fitz/output-png.h
index c77f9e5f..337e838d 100644
--- a/include/mupdf/fitz/output-png.h
+++ b/include/mupdf/fitz/output-png.h
@@ -22,8 +22,8 @@ void fz_write_pixmap_as_png(fz_context *ctx, fz_output *out, const fz_pixmap *pi
typedef struct fz_png_output_context_s fz_png_output_context;
-fz_png_output_context *fz_write_png_header(fz_context *ctx, fz_output *out, int w, int h, int n, int savealpha);
-void fz_write_png_band(fz_context *ctx, fz_output *out, fz_png_output_context *poc, int w, int h, int n, int band, int bandheight, unsigned char *samples, int savealpha);
+fz_png_output_context *fz_write_png_header(fz_context *ctx, fz_output *out, int w, int h, int n, int alpha, int savealpha);
+void fz_write_png_band(fz_context *ctx, fz_output *out, fz_png_output_context *poc, int stride, int band, int bandheight, unsigned char *samples);
void fz_write_png_trailer(fz_context *ctx, fz_output *out, fz_png_output_context *poc);
/*
diff --git a/include/mupdf/fitz/output-pnm.h b/include/mupdf/fitz/output-pnm.h
index f45744a2..42259780 100644
--- a/include/mupdf/fitz/output-pnm.h
+++ b/include/mupdf/fitz/output-pnm.h
@@ -14,7 +14,7 @@ void fz_save_pixmap_as_pnm(fz_context *ctx, fz_pixmap *pixmap, char *filename);
void fz_write_pixmap_as_pnm(fz_context *ctx, fz_output *out, fz_pixmap *pixmap);
void fz_write_pnm_header(fz_context *ctx, fz_output *out, int w, int h, int n);
-void fz_write_pnm_band(fz_context *ctx, fz_output *out, int w, int h, int n, int band, int bandheight, unsigned char *p);
+void fz_write_pnm_band(fz_context *ctx, fz_output *out, int w, int h, int n, int stride, int band, int bandheight, unsigned char *p);
/*
fz_save_pixmap_as_pam: Save a pixmap as a PAM image file.
@@ -23,7 +23,7 @@ void fz_save_pixmap_as_pam(fz_context *ctx, fz_pixmap *pixmap, char *filename, i
void fz_write_pixmap_as_pam(fz_context *ctx, fz_output *out, fz_pixmap *pixmap, int savealpha);
void fz_write_pam_header(fz_context *ctx, fz_output *out, int w, int h, int n, int savealpha);
-void fz_write_pam_band(fz_context *ctx, fz_output *out, int w, int h, int n, int band, int bandheight, unsigned char *sp, int savealpha);
+void fz_write_pam_band(fz_context *ctx, fz_output *out, int w, int h, int n, int stride, int band, int bandheight, unsigned char *sp, int savealpha);
/*
fz_save_bitmap_as_pbm: Save a bitmap as a PBM image file.
diff --git a/include/mupdf/fitz/output-ps.h b/include/mupdf/fitz/output-ps.h
index 83fdd607..f9eb6974 100644
--- a/include/mupdf/fitz/output-ps.h
+++ b/include/mupdf/fitz/output-ps.h
@@ -19,7 +19,7 @@ void fz_write_ps_file_header(fz_context *ctx, fz_output *out);
fz_ps_output_context *fz_write_ps_header(fz_context *ctx, fz_output *out, int w, int h, int n, int xres, int yres, int pagenum);
-void fz_write_ps_band(fz_context *ctx, fz_output *out, fz_ps_output_context *psoc, int w, int h, int n, int band, int bandheight, unsigned char *samples);
+void fz_write_ps_band(fz_context *ctx, fz_output *out, fz_ps_output_context *psoc, int w, int h, int n, int stride, int band, int bandheight, unsigned char *samples);
void fz_write_ps_trailer(fz_context *ctx, fz_output *out, fz_ps_output_context *psoc);
diff --git a/include/mupdf/fitz/pixmap.h b/include/mupdf/fitz/pixmap.h
index be8f45ba..33d127ce 100644
--- a/include/mupdf/fitz/pixmap.h
+++ b/include/mupdf/fitz/pixmap.h
@@ -43,10 +43,12 @@ int fz_pixmap_y(fz_context *ctx, fz_pixmap *pix);
h: The height of the pixmap (in pixels)
+ alpha: 0 for no alpha, 1 for alpha.
+
Returns a pointer to the new pixmap. Throws exception on failure to
allocate.
*/
-fz_pixmap *fz_new_pixmap(fz_context *ctx, fz_colorspace *cs, int w, int h);
+fz_pixmap *fz_new_pixmap(fz_context *ctx, fz_colorspace *cs, int w, int h, int alpha);
/*
fz_new_pixmap_with_bbox: Create a pixmap of a given size,
@@ -62,10 +64,12 @@ fz_pixmap *fz_new_pixmap(fz_context *ctx, fz_colorspace *cs, int w, int h);
bbox: Bounding box specifying location/size of created pixmap.
+ alpha: 0 for no alpha, 1 for alpha.
+
Returns a pointer to the new pixmap. Throws exception on failure to
allocate.
*/
-fz_pixmap *fz_new_pixmap_with_bbox(fz_context *ctx, fz_colorspace *colorspace, const fz_irect *bbox);
+fz_pixmap *fz_new_pixmap_with_bbox(fz_context *ctx, fz_colorspace *colorspace, const fz_irect *bbox, int alpha);
/*
fz_new_pixmap_with_data: Create a new pixmap, with it's origin at
@@ -78,12 +82,17 @@ fz_pixmap *fz_new_pixmap_with_bbox(fz_context *ctx, fz_colorspace *colorspace, c
h: The height of the pixmap (in pixels)
+ alpha: 0 for no alpha, 1 for alpha.
+
+ stride: The byte offset from the pixel data in a row to the pixel
+ data in the next row.
+
samples: The data block to keep the samples in.
Returns a pointer to the new pixmap. Throws exception on failure to
allocate.
*/
-fz_pixmap *fz_new_pixmap_with_data(fz_context *ctx, fz_colorspace *colorspace, int w, int h, unsigned char *samples);
+fz_pixmap *fz_new_pixmap_with_data(fz_context *ctx, fz_colorspace *colorspace, int w, int h, int alpha, int stride, unsigned char *samples);
/*
fz_new_pixmap_with_bbox_and_data: Create a pixmap of a given size,
@@ -104,7 +113,7 @@ fz_pixmap *fz_new_pixmap_with_data(fz_context *ctx, fz_colorspace *colorspace, i
Returns a pointer to the new pixmap. Throws exception on failure to
allocate.
*/
-fz_pixmap *fz_new_pixmap_with_bbox_and_data(fz_context *ctx, fz_colorspace *colorspace, const fz_irect *rect, unsigned char *samples);
+fz_pixmap *fz_new_pixmap_with_bbox_and_data(fz_context *ctx, fz_colorspace *colorspace, const fz_irect *rect, int alpha, unsigned char *samples);
/*
fz_keep_pixmap: Take a reference to a pixmap.
@@ -135,11 +144,18 @@ fz_colorspace *fz_pixmap_colorspace(fz_context *ctx, fz_pixmap *pix);
/*
fz_pixmap_components: Return the number of components in a pixmap.
- Returns the number of components. Does not throw exceptions.
+ Returns the number of components (including alpha). Does not throw exceptions.
*/
int fz_pixmap_components(fz_context *ctx, fz_pixmap *pix);
/*
+ fz_pixmap_components: Return the number of components in a pixmap.
+
+ Returns the number of colorants (components, less any alpha). Does not throw exceptions.
+*/
+int fz_pixmap_colorants(fz_context *ctx, fz_pixmap *pix);
+
+/*
fz_pixmap_samples: Returns a pointer to the pixel data of a pixmap.
Returns the pointer. Does not throw exceptions.
@@ -255,9 +271,15 @@ void fz_convert_pixmap(fz_context *ctx, fz_pixmap *dst, fz_pixmap *src);
w, h: The width and height of the region in pixels.
- n: The number of color components in the image. Always
- includes a separate alpha channel. For mask images n=1, for greyscale
- (plus alpha) images n=2, for rgb (plus alpha) images n=4.
+ n: The number of color components in the image. Includes
+ a separate alpha channel if alpha is set. For mask images
+ n=1, for greyscale (plus alpha) images n=2, for rgb (plus
+ alpha) images n=4.
+
+ stride: The byte offset from the data for any given pixel
+ to the data for the same pixel on the row below.
+
+ alpha: 0 for no alpha, 1 for alpha present.
interpolate: A boolean flag set to non-zero if the image
will be drawn using linear interpolation, or set to zero if
@@ -280,7 +302,8 @@ void fz_convert_pixmap(fz_context *ctx, fz_pixmap *dst, fz_pixmap *src);
struct fz_pixmap_s
{
fz_storable storable;
- int x, y, w, h, n;
+ int x, y, w, h, n, stride;
+ int alpha;
int interpolate;
int xres, yres;
fz_colorspace *colorspace;
@@ -319,4 +342,10 @@ void fz_md5_pixmap(fz_context *ctx, fz_pixmap *pixmap, unsigned char digest[16])
fz_pixmap *fz_new_pixmap_from_8bpp_data(fz_context *ctx, int x, int y, int w, int h, unsigned char *sp, int span);
fz_pixmap *fz_new_pixmap_from_1bpp_data(fz_context *ctx, int x, int y, int w, int h, unsigned char *sp, int span);
+#ifdef HAVE_VALGRIND
+int fz_valgrind_pixmap(const fz_pixmap *pix);
+#else
+#define fz_valgrind_pixmap(pix) do {} while (0)
+#endif
+
#endif
diff --git a/include/mupdf/fitz/util.h b/include/mupdf/fitz/util.h
index ffc13382..ad8816c0 100644
--- a/include/mupdf/fitz/util.h
+++ b/include/mupdf/fitz/util.h
@@ -20,7 +20,7 @@ fz_display_list *fz_new_display_list_from_page_number(fz_context *ctx, fz_docume
*/
fz_pixmap *fz_new_pixmap_from_page(fz_context *ctx, fz_page *page, const fz_matrix *ctm, fz_colorspace *cs);
fz_pixmap *fz_new_pixmap_from_page_number(fz_context *ctx, fz_document *doc, int number, const fz_matrix *ctm, fz_colorspace *cs);
-fz_pixmap *fz_new_pixmap_from_display_list(fz_context *ctx, fz_display_list *list, const fz_matrix *ctm, fz_colorspace *cs, int opaque);
+fz_pixmap *fz_new_pixmap_from_display_list(fz_context *ctx, fz_display_list *list, const fz_matrix *ctm, fz_colorspace *cs, int alpha);
/*
fz_new_pixmap_from_page_contents: Render the page contents without annotations to an opaque pixmap.