summaryrefslogtreecommitdiff
path: root/source/tools
diff options
context:
space:
mode:
authorTor Andersson <tor.andersson@artifex.com>2014-07-17 16:19:28 +0200
committerTor Andersson <tor.andersson@artifex.com>2014-07-17 16:19:28 +0200
commit21b8f3b454732f0a68f66eba223ee8afe754ced1 (patch)
treea70a8402c7ac9cb78796980d1abbacfa8673aa7e /source/tools
parent2a1a79c623636c8cf47a96ca8424174a9283aa10 (diff)
downloadmupdf-21b8f3b454732f0a68f66eba223ee8afe754ced1.tar.xz
Add feature testing device, and call it from mudraw with -T flag.
Currently only tests for the presence of non-grayscale color.
Diffstat (limited to 'source/tools')
-rw-r--r--source/tools/mudraw.c27
1 files changed, 21 insertions, 6 deletions
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-");