diff options
Diffstat (limited to 'source/tools')
-rw-r--r-- | source/tools/mudraw.c | 27 | ||||
-rw-r--r-- | source/tools/muraster.c | 4 | ||||
-rw-r--r-- | source/tools/murun.c | 100 | ||||
-rw-r--r-- | source/tools/pdfextract.c | 2 |
4 files changed, 89 insertions, 44 deletions
diff --git a/source/tools/mudraw.c b/source/tools/mudraw.c index ef95f1d3..aebe441e 100644 --- a/source/tools/mudraw.c +++ b/source/tools/mudraw.c @@ -254,6 +254,12 @@ static int files = 0; static int num_workers = 0; static worker_t *workers; +#ifdef NO_ICC +static fz_cmm_engine *icc_engine = NULL; +#else +static fz_cmm_engine *icc_engine = &fz_cmm_engine_lcms; +#endif + static const char *layer_config = NULL; static struct { @@ -327,6 +333,7 @@ static void usage(void) "\t-i\tignore errors\n" "\t-L\tlow memory mode (avoid caching, clear objects after each page)\n" "\t-P\tparallel interpretation/rendering\n" + "\t-N\tdisable ICC workflow (\"N\"o color management)\n" "\n" "\t-y l\tList the layer configs to stderr\n" "\t-y -\tSelect layer config (by number)\n" @@ -797,7 +804,9 @@ static void dodrawpage(fz_context *ctx, fz_page *page, fz_display_list *list, in bander = fz_new_color_pcl_band_writer(ctx, out, NULL); } if (bander) - fz_write_header(ctx, bander, pix->w, totalheight, pix->n, pix->alpha, pix->xres, pix->yres, output_pagenum++); + { + fz_write_header(ctx, bander, pix->w, totalheight, pix->n, pix->alpha, pix->xres, pix->yres, output_pagenum++, pix->colorspace); + } } for (band = 0; band < bands; band++) @@ -1345,10 +1354,11 @@ int mudraw_main(int argc, char **argv) fz_context *ctx; fz_alloc_context alloc_ctx = { NULL, trace_malloc, trace_realloc, trace_free }; fz_locks_context *locks = NULL; + fz_colorspace *oi = NULL; fz_var(doc); - while ((c = fz_getopt(argc, argv, "p:o:F:R:r:w:h:fB:c:G:Is:A:DiW:H:S:T:U:XLvPl:y:")) != -1) + while ((c = fz_getopt(argc, argv, "p:o:F:R:r:w:h:fB:c:G:Is:A:DiW:H:S:T:U:XLvPl:y:N")) != -1) { switch (c) { @@ -1397,6 +1407,7 @@ int mudraw_main(int argc, char **argv) case 'D': uselist = 0; break; case 'l': min_line_width = fz_atof(fz_optarg); break; case 'i': ignore_errors = 1; break; + case 'N': icc_engine = NULL; break; case 'T': #ifndef DISABLE_MUTHREADS @@ -1459,6 +1470,7 @@ int mudraw_main(int argc, char **argv) fz_set_text_aa_level(ctx, alphabits_text); fz_set_graphics_aa_level(ctx, alphabits_graphics); fz_set_graphics_min_line_width(ctx, min_line_width); + fz_set_cmm_engine(ctx, icc_engine); #ifndef DISABLE_MUTHREADS if (bgprint.active) @@ -1659,6 +1671,17 @@ int mudraw_main(int argc, char **argv) doc = fz_open_document(ctx, filename); + /* Once document is open check for output intent colorspace */ + oi = fz_document_output_intent(ctx, doc); + if (oi) + { + if (fz_colorspace_n(ctx, oi) == fz_colorspace_n(ctx, colorspace)) + { + fz_drop_colorspace(ctx, colorspace); + colorspace = fz_keep_colorspace(ctx, oi); + } + } + if (fz_needs_password(ctx, doc)) { if (!fz_authenticate_password(ctx, doc, password)) diff --git a/source/tools/muraster.c b/source/tools/muraster.c index 41d5e3bf..77d60b8f 100644 --- a/source/tools/muraster.c +++ b/source/tools/muraster.c @@ -615,7 +615,7 @@ static int dodrawpage(fz_context *ctx, int pagenum, fz_cookie *cookie, render_de pix = fz_new_pixmap_with_bbox(ctx, colorspace, &ibounds, 0); fz_set_pixmap_resolution(ctx, pix, x_resolution, y_resolution); } - fz_write_header(ctx, render->bander, pix->w, total_height, pix->n, pix->alpha, pix->xres, pix->yres, pagenum); + fz_write_header(ctx, render->bander, pix->w, total_height, pix->n, pix->alpha, pix->xres, pix->yres, pagenum, pix->colorspace); for (band = 0; band < bands; band++) { @@ -718,7 +718,7 @@ static int try_render_page(fz_context *ctx, int pagenum, fz_cookie *cookie, int { int w = render->ibounds.x1 - render->ibounds.x0; int h = render->ibounds.y1 - render->ibounds.y0; - fz_write_header(ctx, render->bander, w, h, render->n, 0, 0, 0, 0); + fz_write_header(ctx, render->bander, w, h, render->n, 0, 0, 0, 0, NULL); } fz_catch(ctx) { diff --git a/source/tools/murun.c b/source/tools/murun.c index 205e8f91..47cc1884 100644 --- a/source/tools/murun.c +++ b/source/tools/murun.c @@ -538,6 +538,18 @@ static struct color ffi_tocolor(js_State *J, int idx) return c; } +static fz_color_params *ffi_tocolorparams(js_State *J, int idx) +{ + /* TODO */ + return NULL; +} + +static void ffi_pushcolorparams(js_State *J, const fz_color_params *color_params) +{ + /* TODO */ + js_pushnull(J); +} + static const char *string_from_cap(fz_linecap cap) { switch (cap) { @@ -771,7 +783,7 @@ typedef struct js_device_s static void js_dev_fill_path(fz_context *ctx, fz_device *dev, const fz_path *path, int even_odd, const fz_matrix *ctm, - fz_colorspace *colorspace, const float *color, float alpha) + fz_colorspace *colorspace, const float *color, float alpha, const fz_color_params *color_params) { js_State *J = ((js_device*)dev)->J; if (js_try(J)) @@ -782,7 +794,8 @@ js_dev_fill_path(fz_context *ctx, fz_device *dev, const fz_path *path, int even_ js_pushboolean(J, even_odd); ffi_pushmatrix(J, *ctm); ffi_pushcolor(J, colorspace, color, alpha); - js_call(J, 6); + ffi_pushcolorparams(J, color_params); + js_call(J, 7); js_pop(J, 1); } js_endtry(J); @@ -809,7 +822,7 @@ js_dev_clip_path(fz_context *ctx, fz_device *dev, const fz_path *path, int even_ static void js_dev_stroke_path(fz_context *ctx, fz_device *dev, const fz_path *path, const fz_stroke_state *stroke, const fz_matrix *ctm, - fz_colorspace *colorspace, const float *color, float alpha) + fz_colorspace *colorspace, const float *color, float alpha, const fz_color_params *color_params) { js_State *J = ((js_device*)dev)->J; if (js_try(J)) @@ -820,7 +833,8 @@ js_dev_stroke_path(fz_context *ctx, fz_device *dev, const fz_path *path, ffi_pushstroke(J, stroke); ffi_pushmatrix(J, *ctm); ffi_pushcolor(J, colorspace, color, alpha); - js_call(J, 6); + ffi_pushcolorparams(J, color_params); + js_call(J, 7); js_pop(J, 1); } js_endtry(J); @@ -846,7 +860,7 @@ js_dev_clip_stroke_path(fz_context *ctx, fz_device *dev, const fz_path *path, co static void js_dev_fill_text(fz_context *ctx, fz_device *dev, const fz_text *text, const fz_matrix *ctm, - fz_colorspace *colorspace, const float *color, float alpha) + fz_colorspace *colorspace, const float *color, float alpha, const fz_color_params *color_params) { js_State *J = ((js_device*)dev)->J; if (js_try(J)) @@ -856,7 +870,8 @@ js_dev_fill_text(fz_context *ctx, fz_device *dev, const fz_text *text, const fz_ ffi_pushtext(J, text); ffi_pushmatrix(J, *ctm); ffi_pushcolor(J, colorspace, color, alpha); - js_call(J, 5); + ffi_pushcolorparams(J, color_params); + js_call(J, 6); js_pop(J, 1); } js_endtry(J); @@ -864,7 +879,7 @@ js_dev_fill_text(fz_context *ctx, fz_device *dev, const fz_text *text, const fz_ static void js_dev_stroke_text(fz_context *ctx, fz_device *dev, const fz_text *text, const fz_stroke_state *stroke, - const fz_matrix *ctm, fz_colorspace *colorspace, const float *color, float alpha) + const fz_matrix *ctm, fz_colorspace *colorspace, const float *color, float alpha, const fz_color_params *color_params) { js_State *J = ((js_device*)dev)->J; if (js_try(J)) @@ -875,7 +890,8 @@ js_dev_stroke_text(fz_context *ctx, fz_device *dev, const fz_text *text, const f ffi_pushstroke(J, stroke); ffi_pushmatrix(J, *ctm); ffi_pushcolor(J, colorspace, color, alpha); - js_call(J, 6); + ffi_pushcolorparams(J, color_params); + js_call(J, 7); js_pop(J, 1); } js_endtry(J); @@ -932,7 +948,7 @@ js_dev_ignore_text(fz_context *ctx, fz_device *dev, const fz_text *text, const f } static void -js_dev_fill_shade(fz_context *ctx, fz_device *dev, fz_shade *shade, const fz_matrix *ctm, float alpha) +js_dev_fill_shade(fz_context *ctx, fz_device *dev, fz_shade *shade, const fz_matrix *ctm, float alpha, const fz_color_params *color_params) { js_State *J = ((js_device*)dev)->J; if (js_try(J)) @@ -942,14 +958,15 @@ js_dev_fill_shade(fz_context *ctx, fz_device *dev, fz_shade *shade, const fz_mat ffi_pushshade(J, shade); ffi_pushmatrix(J, *ctm); js_pushnumber(J, alpha); - js_call(J, 3); + ffi_pushcolorparams(J, color_params); + js_call(J, 4); js_pop(J, 1); } js_endtry(J); } static void -js_dev_fill_image(fz_context *ctx, fz_device *dev, fz_image *image, const fz_matrix *ctm, float alpha) +js_dev_fill_image(fz_context *ctx, fz_device *dev, fz_image *image, const fz_matrix *ctm, float alpha, const fz_color_params *color_params) { js_State *J = ((js_device*)dev)->J; if (js_try(J)) @@ -959,7 +976,8 @@ js_dev_fill_image(fz_context *ctx, fz_device *dev, fz_image *image, const fz_mat ffi_pushimage(J, image); ffi_pushmatrix(J, *ctm); js_pushnumber(J, alpha); - js_call(J, 3); + ffi_pushcolorparams(J, color_params); + js_call(J, 4); js_pop(J, 1); } js_endtry(J); @@ -967,7 +985,7 @@ js_dev_fill_image(fz_context *ctx, fz_device *dev, fz_image *image, const fz_mat static void js_dev_fill_image_mask(fz_context *ctx, fz_device *dev, fz_image *image, const fz_matrix *ctm, - fz_colorspace *colorspace, const float *color, float alpha) + fz_colorspace *colorspace, const float *color, float alpha, const fz_color_params *color_params) { js_State *J = ((js_device*)dev)->J; if (js_try(J)) @@ -977,7 +995,8 @@ js_dev_fill_image_mask(fz_context *ctx, fz_device *dev, fz_image *image, const f ffi_pushimage(J, image); ffi_pushmatrix(J, *ctm); ffi_pushcolor(J, colorspace, color, alpha); - js_call(J, 5); + ffi_pushcolorparams(J, color_params); + js_call(J, 6); js_pop(J, 1); } js_endtry(J); @@ -1015,7 +1034,7 @@ js_dev_pop_clip(fz_context *ctx, fz_device *dev) static void js_dev_begin_mask(fz_context *ctx, fz_device *dev, const fz_rect *bbox, int luminosity, - fz_colorspace *colorspace, const float *color) + fz_colorspace *colorspace, const float *color, const fz_color_params *color_params) { js_State *J = ((js_device*)dev)->J; if (js_try(J)) @@ -1024,14 +1043,9 @@ js_dev_begin_mask(fz_context *ctx, fz_device *dev, const fz_rect *bbox, int lumi js_copy(J, -2); ffi_pushrect(J, *bbox); js_pushboolean(J, luminosity); - if (colorspace) { - ffi_pushcolorspace(J, colorspace); - ffi_pusharray(J, color, fz_colorspace_n(ctx, colorspace)); - } else { - js_pushnull(J); - js_pushnull(J); - } - js_call(J, 4); + ffi_pushcolor(J, colorspace, color, 1); + ffi_pushcolorparams(J, color_params); + js_call(J, 6); js_pop(J, 1); } js_endtry(J); @@ -1178,8 +1192,9 @@ static void ffi_Device_fillPath(js_State *J) int even_odd = js_toboolean(J, 2); fz_matrix ctm = ffi_tomatrix(J, 3); struct color c = ffi_tocolor(J, 4); + fz_color_params *color_params = ffi_tocolorparams(J, 7); fz_try(ctx) - fz_fill_path(ctx, dev, path, even_odd, &ctm, c.colorspace, c.color, c.alpha); + fz_fill_path(ctx, dev, path, even_odd, &ctm, c.colorspace, c.color, c.alpha, color_params); fz_catch(ctx) rethrow(J); } @@ -1192,8 +1207,9 @@ static void ffi_Device_strokePath(js_State *J) fz_stroke_state stroke = ffi_tostroke(J, 2); fz_matrix ctm = ffi_tomatrix(J, 3); struct color c = ffi_tocolor(J, 4); + fz_color_params *color_params = ffi_tocolorparams(J, 7); fz_try(ctx) - fz_stroke_path(ctx, dev, path, &stroke, &ctm, c.colorspace, c.color, c.alpha); + fz_stroke_path(ctx, dev, path, &stroke, &ctm, c.colorspace, c.color, c.alpha, color_params); fz_catch(ctx) rethrow(J); } @@ -1231,8 +1247,9 @@ static void ffi_Device_fillText(js_State *J) fz_text *text = js_touserdata(J, 1, "fz_text"); fz_matrix ctm = ffi_tomatrix(J, 2); struct color c = ffi_tocolor(J, 3); + fz_color_params *color_params = ffi_tocolorparams(J, 6); fz_try(ctx) - fz_fill_text(ctx, dev, text, &ctm, c.colorspace, c.color, c.alpha); + fz_fill_text(ctx, dev, text, &ctm, c.colorspace, c.color, c.alpha, color_params); fz_catch(ctx) rethrow(J); } @@ -1245,8 +1262,9 @@ static void ffi_Device_strokeText(js_State *J) fz_stroke_state stroke = ffi_tostroke(J, 2); fz_matrix ctm = ffi_tomatrix(J, 3); struct color c = ffi_tocolor(J, 4); + fz_color_params *color_params = ffi_tocolorparams(J, 7); fz_try(ctx) - fz_stroke_text(ctx, dev, text, &stroke, &ctm, c.colorspace, c.color, c.alpha); + fz_stroke_text(ctx, dev, text, &stroke, &ctm, c.colorspace, c.color, c.alpha, color_params); fz_catch(ctx) rethrow(J); } @@ -1295,8 +1313,9 @@ static void ffi_Device_fillShade(js_State *J) fz_shade *shade = js_touserdata(J, 1, "fz_shade"); fz_matrix ctm = ffi_tomatrix(J, 2); float alpha = js_tonumber(J, 3); + fz_color_params *color_params = ffi_tocolorparams(J, 4); fz_try(ctx) - fz_fill_shade(ctx, dev, shade, &ctm, alpha); + fz_fill_shade(ctx, dev, shade, &ctm, alpha, color_params); fz_catch(ctx) rethrow(J); } @@ -1308,8 +1327,9 @@ static void ffi_Device_fillImage(js_State *J) fz_image *image = js_touserdata(J, 1, "fz_image"); fz_matrix ctm = ffi_tomatrix(J, 2); float alpha = js_tonumber(J, 3); + fz_color_params *color_params = ffi_tocolorparams(J, 4); fz_try(ctx) - fz_fill_image(ctx, dev, image, &ctm, alpha); + fz_fill_image(ctx, dev, image, &ctm, alpha, color_params); fz_catch(ctx) rethrow(J); } @@ -1321,8 +1341,9 @@ static void ffi_Device_fillImageMask(js_State *J) fz_image *image = js_touserdata(J, 1, "fz_image"); fz_matrix ctm = ffi_tomatrix(J, 2); struct color c = ffi_tocolor(J, 3); + fz_color_params *color_params = ffi_tocolorparams(J, 6); fz_try(ctx) - fz_fill_image_mask(ctx, dev, image, &ctm, c.colorspace, c.color, c.alpha); + fz_fill_image_mask(ctx, dev, image, &ctm, c.colorspace, c.color, c.alpha, color_params); fz_catch(ctx) rethrow(J); } @@ -1356,8 +1377,9 @@ static void ffi_Device_beginMask(js_State *J) fz_rect area = ffi_torect(J, 1); int luminosity = js_toboolean(J, 2); struct color c = ffi_tocolor(J, 3); + fz_color_params *color_params = ffi_tocolorparams(J, 6); fz_try(ctx) - fz_begin_mask(ctx, dev, &area, luminosity, c.colorspace, c.color); + fz_begin_mask(ctx, dev, &area, luminosity, c.colorspace, c.color, color_params); fz_catch(ctx) rethrow(J); } @@ -4312,25 +4334,25 @@ int murun_main(int argc, char **argv) { jsB_propfun(J, "Device.close", ffi_Device_close, 0); - jsB_propfun(J, "Device.fillPath", ffi_Device_fillPath, 6); - jsB_propfun(J, "Device.strokePath", ffi_Device_strokePath, 6); + jsB_propfun(J, "Device.fillPath", ffi_Device_fillPath, 7); + jsB_propfun(J, "Device.strokePath", ffi_Device_strokePath, 7); jsB_propfun(J, "Device.clipPath", ffi_Device_clipPath, 3); jsB_propfun(J, "Device.clipStrokePath", ffi_Device_clipStrokePath, 3); - jsB_propfun(J, "Device.fillText", ffi_Device_fillText, 5); - jsB_propfun(J, "Device.strokeText", ffi_Device_strokeText, 6); + jsB_propfun(J, "Device.fillText", ffi_Device_fillText, 6); + jsB_propfun(J, "Device.strokeText", ffi_Device_strokeText, 7); jsB_propfun(J, "Device.clipText", ffi_Device_clipText, 2); jsB_propfun(J, "Device.clipStrokeText", ffi_Device_clipStrokeText, 3); jsB_propfun(J, "Device.ignoreText", ffi_Device_ignoreText, 2); - jsB_propfun(J, "Device.fillShade", ffi_Device_fillShade, 3); - jsB_propfun(J, "Device.fillImage", ffi_Device_fillImage, 3); - jsB_propfun(J, "Device.fillImageMask", ffi_Device_fillImageMask, 5); + jsB_propfun(J, "Device.fillShade", ffi_Device_fillShade, 4); + jsB_propfun(J, "Device.fillImage", ffi_Device_fillImage, 4); + jsB_propfun(J, "Device.fillImageMask", ffi_Device_fillImageMask, 6); jsB_propfun(J, "Device.clipImageMask", ffi_Device_clipImageMask, 2); jsB_propfun(J, "Device.popClip", ffi_Device_popClip, 0); - jsB_propfun(J, "Device.beginMask", ffi_Device_beginMask, 5); /* should be 4 */ + jsB_propfun(J, "Device.beginMask", ffi_Device_beginMask, 6); jsB_propfun(J, "Device.endMask", ffi_Device_endMask, 0); jsB_propfun(J, "Device.beginGroup", ffi_Device_beginGroup, 5); jsB_propfun(J, "Device.endGroup", ffi_Device_endGroup, 0); diff --git a/source/tools/pdfextract.c b/source/tools/pdfextract.c index 49a2747e..984cda16 100644 --- a/source/tools/pdfextract.c +++ b/source/tools/pdfextract.c @@ -42,7 +42,7 @@ static void writepixmap(fz_context *ctx, fz_pixmap *pix, char *file, int dorgb) if (dorgb && pix->colorspace && pix->colorspace != fz_device_rgb(ctx)) { - rgb = fz_convert_pixmap(ctx, pix, fz_device_rgb(ctx), 1); + rgb = fz_convert_pixmap(ctx, pix, fz_device_rgb(ctx), NULL, NULL, NULL /* FIXME */, 1); pix = rgb; } |