summaryrefslogtreecommitdiff
path: root/include/mupdf/fitz
diff options
context:
space:
mode:
authorRobin Watts <robin.watts@artifex.com>2017-07-03 18:33:48 +0100
committerRobin Watts <robin.watts@artifex.com>2017-07-19 19:41:23 +0100
commitf957eae764e6dbc74401b66d6a18ba3290fdb982 (patch)
tree224513a5080adde16386669feb0881aefe75794a /include/mupdf/fitz
parent3d6cf4e4e543ce0d204db71ef8d0b9277219f250 (diff)
downloadmupdf-f957eae764e6dbc74401b66d6a18ba3290fdb982.tar.xz
Add spots to fz_pixmaps.
Update separations interface further to cope with whether spots should be rendered separately, or as composite colors.
Diffstat (limited to 'include/mupdf/fitz')
-rw-r--r--include/mupdf/fitz/document.h2
-rw-r--r--include/mupdf/fitz/pixmap.h85
-rw-r--r--include/mupdf/fitz/separation.h33
3 files changed, 85 insertions, 35 deletions
diff --git a/include/mupdf/fitz/document.h b/include/mupdf/fitz/document.h
index 70529329..a94aa53f 100644
--- a/include/mupdf/fitz/document.h
+++ b/include/mupdf/fitz/document.h
@@ -167,7 +167,7 @@ typedef void (fz_page_control_separation_fn)(fz_context *ctx, fz_page *page, int
/*
fz_page_separation_disabled_fn: Type for a function to detect
whether a given separation is enabled or disabled on a page.
- See fz_separation_disabled for more information.
+ See FZ_SEPARATION_DISABLED for more information.
*/
typedef int (fz_page_separation_disabled_fn)(fz_context *ctx, fz_page *page, int separation);
diff --git a/include/mupdf/fitz/pixmap.h b/include/mupdf/fitz/pixmap.h
index 45e12b03..16217578 100644
--- a/include/mupdf/fitz/pixmap.h
+++ b/include/mupdf/fitz/pixmap.h
@@ -6,6 +6,7 @@
#include "mupdf/fitz/geometry.h"
#include "mupdf/fitz/store.h"
#include "mupdf/fitz/colorspace.h"
+#include "mupdf/fitz/separation.h"
/*
Pixmaps represent a set of pixels for a 2 dimensional region of a
@@ -51,12 +52,14 @@ int fz_pixmap_y(fz_context *ctx, fz_pixmap *pix);
h: The height of the pixmap (in pixels)
+ seps: Details of separations.
+
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, int alpha);
+fz_pixmap *fz_new_pixmap(fz_context *ctx, fz_colorspace *cs, int w, int h, fz_separations *seps, int alpha);
/*
fz_new_pixmap_with_bbox: Create a pixmap of a given size,
@@ -72,12 +75,14 @@ fz_pixmap *fz_new_pixmap(fz_context *ctx, fz_colorspace *cs, int w, int h, int a
bbox: Bounding box specifying location/size of created pixmap.
+ seps: Details of separations.
+
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, int alpha);
+fz_pixmap *fz_new_pixmap_with_bbox(fz_context *ctx, fz_colorspace *colorspace, const fz_irect *bbox, fz_separations *seps, int alpha);
/*
fz_new_pixmap_with_data: Create a new pixmap, with its origin at
@@ -90,6 +95,8 @@ fz_pixmap *fz_new_pixmap_with_bbox(fz_context *ctx, fz_colorspace *colorspace, c
h: The height of the pixmap (in pixels)
+ seps: Details of separations.
+
alpha: 0 for no alpha, 1 for alpha.
stride: The byte offset from the pixel data in a row to the pixel
@@ -100,7 +107,7 @@ fz_pixmap *fz_new_pixmap_with_bbox(fz_context *ctx, fz_colorspace *colorspace, c
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, int alpha, int stride, unsigned char *samples);
+fz_pixmap *fz_new_pixmap_with_data(fz_context *ctx, fz_colorspace *colorspace, int w, int h, fz_separations *seps, int alpha, int stride, unsigned char *samples);
/*
fz_new_pixmap_with_bbox_and_data: Create a pixmap of a given size,
@@ -114,14 +121,18 @@ fz_pixmap *fz_new_pixmap_with_data(fz_context *ctx, fz_colorspace *colorspace, i
colorspace: Colorspace format used for the created pixmap. The
pixmap will keep a reference to the colorspace.
- bbox: Bounding box specifying location/size of created pixmap.
+ rect: Bounding box specifying location/size of created pixmap.
+
+ seps: Details of separations.
+
+ alpha: Number of alpha planes (0 or 1).
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_bbox_and_data(fz_context *ctx, fz_colorspace *colorspace, const fz_irect *rect, int alpha, unsigned char *samples);
+fz_pixmap *fz_new_pixmap_with_bbox_and_data(fz_context *ctx, fz_colorspace *colorspace, const fz_irect *rect, fz_separations *seps, int alpha, unsigned char *samples);
/*
fz_keep_pixmap: Take a reference to a pixmap.
@@ -152,18 +163,32 @@ 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 (including alpha). Does not throw exceptions.
+ Returns the number of components (including spots and 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.
+ fz_pixmap_colorants: Return the number of colorants in a pixmap.
- Returns the number of colorants (components, less any alpha). Does not throw exceptions.
+ Returns the number of colorants (components, less any spots and alpha). Does not throw exceptions.
*/
int fz_pixmap_colorants(fz_context *ctx, fz_pixmap *pix);
/*
+ fz_pixmap_spots: Return the number of spots in a pixmap.
+
+ Returns the number of spots (components, less colorants and alpha). Does not throw exceptions.
+*/
+int fz_pixmap_spots(fz_context *ctx, fz_pixmap *pix);
+
+/*
+ fz_pixmap_alpha: Return the number of alpha planes in a pixmap.
+
+ Returns the number of alphas. Does not throw exceptions.
+*/
+int fz_pixmap_alpha(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.
@@ -293,19 +318,25 @@ fz_pixmap *fz_convert_pixmap(fz_context *ctx, fz_pixmap *pix, fz_colorspace *cs_
w, h: The width and height of the region in pixels.
- 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.
+ n: The number of color components in the image.
+ n = num composite colors + num spots + num alphas
- stride: The byte offset from the data for any given pixel
- to the data for the same pixel on the row below.
+ s: The number of spot channels in the image.
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
- image will be using nearest neighbour sampling.
+ flags: flag bits.
+ Bit 0: If set, draw the image with linear interpolation.
+ Bit 1: If set, free the samples buffer when the pixmap
+ is destroyed.
+ Bit 2: If set, all separations are enabled (ignore the
+ fields in the seps structure).
+
+ stride: The byte offset from the data for any given pixel
+ to the data for the same pixel on the row below.
+
+ seps: NULL, or a pointer to a separations structure. If NULL,
+ s should be 0.
xres, yres: Image resolution in dpi. Default is 96 dpi.
@@ -316,22 +347,26 @@ fz_pixmap *fz_convert_pixmap(fz_context *ctx, fz_pixmap *pix, fz_colorspace *cs_
the components are stored. The first n bytes are components 0 to n-1
for the pixel at (x,y). Each successive n bytes gives another pixel
in scanline order. Subsequent scanlines follow on with no padding.
-
- free_samples: Is zero when an application has provided its own
- buffer for pixel data through fz_new_pixmap_with_bbox_and_data.
- If non-zero the buffer will be freed along with the pixmap.
*/
struct fz_pixmap_s
{
fz_storable storable;
- int x, y, w, h, n;
+ int x, y, w, h;
+ unsigned char n;
+ unsigned char s;
+ unsigned char alpha;
+ unsigned char flags;
ptrdiff_t stride;
- int alpha;
- int interpolate;
+ fz_separations *seps;
int xres, yres;
fz_colorspace *colorspace;
unsigned char *samples;
- int free_samples;
+};
+
+enum
+{
+ FZ_PIXMAP_FLAG_INTERPOLATE = 1,
+ FZ_PIXMAP_FLAG_FREE_SAMPLES = 2,
};
void fz_drop_pixmap_imp(fz_context *ctx, fz_storable *pix);
diff --git a/include/mupdf/fitz/separation.h b/include/mupdf/fitz/separation.h
index 2f0ed596..4d17fc53 100644
--- a/include/mupdf/fitz/separation.h
+++ b/include/mupdf/fitz/separation.h
@@ -19,6 +19,18 @@ enum
typedef struct fz_separations_s fz_separations;
+typedef enum
+{
+ /* "Composite" separations are rendered using process
+ * colors using the equivalent colors */
+ FZ_SEPARATION_COMPOSITE = 0,
+ /* Spot colors are rendered into their own spot plane. */
+ FZ_SEPARATION_SPOT = 1,
+ /* Disabled colors are not rendered at all in the final
+ * output. */
+ FZ_SEPARATION_DISABLED = 2
+} fz_separation_behavior;
+
/* Create a new separations structure (initially empty) */
fz_separations *fz_new_separations(fz_context *ctx, int controllable);
@@ -31,22 +43,25 @@ void fz_drop_separations(fz_context *ctx, fz_separations *sep);
/* Add a separation (RGBA and CYMK equivalents, null terminated name) */
void fz_add_separation(fz_context *ctx, fz_separations *sep, uint32_t rgba, uint32_t cmyk, const char *name);
-/* Enable or disable a given separation */
-void fz_control_separation(fz_context *ctx, fz_separations *sep, int separation, int disable);
+/* Control the rendering of a given separation */
+void fz_set_separation_behavior(fz_context *ctx, fz_separations *sep, int separation, fz_separation_behavior behavior);
-/* Test for a separation being enabled or disabled */
-int fz_separation_disabled(fz_context *ctx, fz_separations *sep, int separation);
+/* Test for the current behavior of a separation */
+fz_separation_behavior fz_separation_current_behavior(fz_context *ctx, const fz_separations *sep, int separation);
-/* Quick test for all separations enabled (the common case) */
-int fz_separations_all_enabled(fz_context *ctx, fz_separations *sep);
+/* Quick test for all separations composite (the common case) */
+int fz_separations_all_composite(fz_context *ctx, const fz_separations *sep);
/* Read separation details */
-const char *fz_get_separation(fz_context *ctx, fz_separations *sep, int separation, uint32_t *rgb, uint32_t *cmyk);
+const char *fz_get_separation(fz_context *ctx, const fz_separations *sep, int separation, uint32_t *rgb, uint32_t *cmyk);
/* Count the number of separations */
-int fz_count_separations(fz_context *ctx, fz_separations *sep);
+int fz_count_separations(fz_context *ctx, const fz_separations *sep);
/* Find out if separations are controllable. */
-int fz_separations_controllable(fz_context *ctx, fz_separations *seps);
+int fz_separations_controllable(fz_context *ctx, const fz_separations *seps);
+
+/* Return the number of active separations. */
+int fz_count_active_separations(fz_context *ctx, const fz_separations *seps);
#endif