From 21b8f3b454732f0a68f66eba223ee8afe754ced1 Mon Sep 17 00:00:00 2001 From: Tor Andersson Date: Thu, 17 Jul 2014 16:19:28 +0200 Subject: Add feature testing device, and call it from mudraw with -T flag. Currently only tests for the presence of non-grayscale color. --- source/tools/mudraw.c | 27 +++++++++++++++++++++------ 1 file changed, 21 insertions(+), 6 deletions(-) (limited to 'source/tools') diff --git a/source/tools/mudraw.c b/source/tools/mudraw.c index 0eb5e477..79092d9c 100644 --- a/source/tools/mudraw.c +++ b/source/tools/mudraw.c @@ -122,6 +122,7 @@ static int memtrace_current = 0; static int memtrace_peak = 0; static int memtrace_total = 0; static int showmemory = 0; +static int showfeatures = 0; static fz_text_sheet *sheet = NULL; static fz_colorspace *colorspace; static char *filename; @@ -162,6 +163,7 @@ static void usage(void) "\t-G -\tgamma correct output\n" "\t-I\tinvert output\n" "\t-l\tprint outline\n" + "\t-T\ttest for features (grayscale or color)\n" "\t-i\tignore errors and continue with the next file\n" "\tpages\tcomma separated list of ranges\n"); exit(1); @@ -308,9 +310,22 @@ static void drawpage(fz_context *ctx, fz_document *doc, int pagenum) } } - if (showmd5 || showtime) + if (showmd5 || showtime || showfeatures) printf("page %s %d", filename, pagenum); + if (showfeatures) + { + int iscolor; + dev = fz_new_test_device(ctx, &iscolor); + if (list) + fz_run_display_list(list, dev, &fz_identity, &fz_infinite_rect, NULL); + else + fz_run_page(doc, page, dev, &fz_identity, &cookie); + fz_free_device(dev); + dev = NULL; + printf(" %s", iscolor ? "color" : "grayscale"); + } + if (pdfout) { fz_matrix ctm; @@ -656,7 +671,7 @@ static void drawpage(fz_context *ctx, fz_document *doc, int pagenum) printf(" %dms", diff); } - if (showmd5 || showtime) + if (showmd5 || showtime || showfeatures) printf("\n"); if (showmemory) @@ -811,7 +826,7 @@ int main(int argc, char **argv) fz_var(doc); - while ((c = fz_getopt(argc, argv, "lo:F:p:r:R:b:c:dgmtx5G:Iw:h:fiMB:")) != -1) + while ((c = fz_getopt(argc, argv, "lo:F:p:r:R:b:c:dgmTtx5G:Iw:h:fiMB:")) != -1) { switch (c) { @@ -828,6 +843,7 @@ int main(int argc, char **argv) case 't': showtext++; break; case 'x': showxml++; break; case '5': showmd5++; break; + case 'T': showfeatures++; break; case 'g': out_cs = CS_GRAY; break; case 'd': uselist = 0; break; case 'c': out_cs = parse_colorspace(fz_optarg); break; @@ -844,7 +860,7 @@ int main(int argc, char **argv) if (fz_optind == argc) usage(); - if (!showtext && !showxml && !showtime && !showmd5 && !showoutline && !output) + if (!showtext && !showxml && !showtime && !showmd5 && !showoutline && !showfeatures && !output) { printf("nothing to do\n"); exit(0); @@ -915,7 +931,6 @@ int main(int argc, char **argv) fprintf(stderr, "Banded operation not compatible with MD5\n"); exit(1); } - } { @@ -1031,7 +1046,7 @@ int main(int argc, char **argv) if (showoutline) drawoutline(ctx, doc); - if (showtext || showxml || showtime || showmd5 || output) + if (showtext || showxml || showtime || showmd5 || showfeatures || output) { if (fz_optind == argc || !isrange(argv[fz_optind])) drawrange(ctx, doc, "1-"); -- cgit v1.2.3