summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Build/source/texk/dvipdfm-x/ChangeLog24
-rw-r--r--Build/source/texk/dvipdfm-x/Makefile.am24
-rw-r--r--Build/source/texk/dvipdfm-x/Makefile.in129
-rwxr-xr-xBuild/source/texk/dvipdfm-x/dvipdfm-bb.test47
-rw-r--r--Build/source/texk/dvipdfm-x/dvipdfmx.h2
-rwxr-xr-xBuild/source/texk/dvipdfm-x/dvipdfmx.test4
-rw-r--r--Build/source/texk/dvipdfm-x/pdfdoc.h2
-rw-r--r--Build/source/texk/dvipdfm-x/pdfobj.h (renamed from Build/source/texk/dvipdfm-x/src/pdfobj.h)20
-rw-r--r--Build/source/texk/dvipdfm-x/pdfximage.h1
-rw-r--r--Build/source/texk/dvipdfm-x/pngimage.c (renamed from Build/source/texk/dvipdfm-x/src/pngimage.c)31
-rw-r--r--Build/source/texk/dvipdfm-x/src/dvipdfmx.c42
-rw-r--r--Build/source/texk/dvipdfm-x/src/pdfobj.c18
-rw-r--r--Build/source/texk/dvipdfm-x/src/pdfximage.c14
-rw-r--r--Build/source/texk/dvipdfm-x/src/xbb.c170
-rw-r--r--Build/source/texk/dvipdfm-x/tests/dvipdfmx.cfg222
-rw-r--r--Build/source/texk/dvipdfm-x/tests/image.jpegbin0 -> 5778 bytes
-rw-r--r--Build/source/texk/dvipdfm-x/tests/image.pdfbin0 -> 2690 bytes
-rw-r--r--Build/source/texk/dvipdfm-x/tests/image.pngbin0 -> 1436 bytes
-rw-r--r--Build/source/texk/dvipdfm-x/tests/imgjpeg.bb4
-rw-r--r--Build/source/texk/dvipdfm-x/tests/imgjpeg.xbb5
-rw-r--r--Build/source/texk/dvipdfm-x/tests/imgpdf.bb4
-rw-r--r--Build/source/texk/dvipdfm-x/tests/imgpdf.xbb7
-rw-r--r--Build/source/texk/dvipdfm-x/tests/imgpng.bb4
-rw-r--r--Build/source/texk/dvipdfm-x/tests/imgpng.xbb5
-rw-r--r--Build/source/texk/dvipdfm-x/tests/picjpeg.bb4
-rw-r--r--Build/source/texk/dvipdfm-x/tests/picjpeg.xbb5
-rw-r--r--Build/source/texk/dvipdfm-x/tests/picpdf.bb4
-rw-r--r--Build/source/texk/dvipdfm-x/tests/picpdf.xbb4
-rw-r--r--Build/source/texk/dvipdfm-x/tests/picpng.bb4
-rw-r--r--Build/source/texk/dvipdfm-x/tests/picpng.xbb5
-rw-r--r--Build/source/texk/dvipdfm-x/xbb.h31
-rwxr-xr-xBuild/source/texk/dvipdfm-x/xdvipdfm-bb.test47
-rwxr-xr-xBuild/source/texk/dvipdfm-x/xdvipdfmx.test4
-rw-r--r--Build/source/texk/dvipdfm-x/xsrc/dvipdfmx.c36
-rw-r--r--Build/source/texk/dvipdfm-x/xsrc/epdf.c50
-rw-r--r--Build/source/texk/dvipdfm-x/xsrc/jpegimage.c68
-rw-r--r--Build/source/texk/dvipdfm-x/xsrc/pdfdoc.c236
-rw-r--r--Build/source/texk/dvipdfm-x/xsrc/pdfobj.c78
-rw-r--r--Build/source/texk/dvipdfm-x/xsrc/pdfobj.h196
-rw-r--r--Build/source/texk/dvipdfm-x/xsrc/pdfximage.c22
-rw-r--r--Build/source/texk/dvipdfm-x/xsrc/pngimage.c1013
-rw-r--r--Build/source/texk/dvipdfm-x/xsrc/xbb.c296
42 files changed, 1248 insertions, 1634 deletions
diff --git a/Build/source/texk/dvipdfm-x/ChangeLog b/Build/source/texk/dvipdfm-x/ChangeLog
index 0b1fa9bb906..59ef6e152a2 100644
--- a/Build/source/texk/dvipdfm-x/ChangeLog
+++ b/Build/source/texk/dvipdfm-x/ChangeLog
@@ -1,3 +1,27 @@
+2013-07-15 Peter Breitenlohner <peb@mppmu.mpg.de>
+
+ * xsrc/jpegimage.c: Added jpeg_get_bbox() and jpeg_get_density()
+ from src/jpegimage.c.
+ * xsrc/pdfdoc.c: Added pdf_doc_get_page() from src/pdfdoc.c.
+ * xsrc/pngimage.c: Added png_get_bbox() from src/pngimage.c.
+ * xbb.h (removed): Merged ...
+ * dvipdfmx.h: ... into here.
+
+ * Removed diffs between src/ and xsrc/ version of these files
+ and moved them to the top-level: pdfobj.h, pngimage.c.
+
+ * Reduced dvipdfmx/xdvipdfmx diffs in these files:
+ dvipdfmx.c, epdf.c, pdfdoc.c, pdfobj.c, pdfximage.c, xbb.c.
+
+ * src/dvipdfmx.c, xsrc/dvipdfmx.c: Add '--xbb', '--ebb' options.
+
+ * (x)dvipdfmx.test: Correctly set the environment variables.
+ * (x)dvipdfm-bb.test: New shell scripts to test bounding box
+ extraction.
+ * tests/dvipdfmx.cfg, tests/image.* (new): Test input files.
+ * tests/img*.*, tests/pic*.* (new): Expected output files.
+ input and expected output files.
+
2013-07-10 Peter Breitenlohner <peb@mppmu.mpg.de>
* Removed diffs between src/ and xsrc/ version of these files
diff --git a/Build/source/texk/dvipdfm-x/Makefile.am b/Build/source/texk/dvipdfm-x/Makefile.am
index 2bacfc0cd31..f8d07edc0d5 100644
--- a/Build/source/texk/dvipdfm-x/Makefile.am
+++ b/Build/source/texk/dvipdfm-x/Makefile.am
@@ -95,6 +95,7 @@ common_sources = \
pdffont.c \
pdffont.h \
pdflimits.h \
+ pdfobj.h \
pdfparse.c \
pdfparse.h \
pdfresource.c \
@@ -102,6 +103,7 @@ common_sources = \
pdfximage.h \
pkfont.c \
pkfont.h \
+ pngimage.c \
pngimage.h \
pst.c \
pst.h \
@@ -148,8 +150,7 @@ common_sources = \
unicode.c \
unicode.h \
vf.c \
- vf.h \
- xbb.h
+ vf.h
dvipdfmx_sources = \
src/cff_dict.c \
@@ -167,9 +168,7 @@ dvipdfmx_sources = \
src/pdfnames.c \
src/pdfnames.h \
src/pdfobj.c \
- src/pdfobj.h \
src/pdfximage.c \
- src/pngimage.c \
src/spc_dvips.c \
src/spc_pdfm.c \
src/spc_tpic.c \
@@ -196,9 +195,7 @@ xdvipdfmx_sources = \
xsrc/pdfnames.c \
xsrc/pdfnames.h \
xsrc/pdfobj.c \
- xsrc/pdfobj.h \
xsrc/pdfximage.c \
- xsrc/pngimage.c \
xsrc/spc_dvips.c \
xsrc/spc_pdfm.c \
xsrc/spc_tpic.c \
@@ -300,11 +297,20 @@ DISTCLEANFILES = config.force
## Tests
##
TESTS =
+dvipdfmx_tests = dvipdfmx.test dvipdfm-bb.test
if DVIPDFMX
-TESTS += dvipdfmx.test
+TESTS += $(dvipdfmx_tests)
endif DVIPDFMX
+xdvipdfmx_tests = xdvipdfmx.test xdvipdfm-bb.test
if XDVIPDFMX
-TESTS += xdvipdfmx.test
+TESTS += $(xdvipdfmx_tests)
endif XDVIPDFMX
-EXTRA_DIST += dvipdfmx.test xdvipdfmx.test
+EXTRA_DIST += $(dvipdfmx_tests) $(xdvipdfmx_tests)
+## Test Data
+##
+EXTRA_DIST += tests/dvipdfmx.cfg
+EXTRA_DIST += tests/image.jpeg tests/imgjpeg.bb tests/imgjpeg.xbb tests/picjpeg.bb tests/picjpeg.xbb
+EXTRA_DIST += tests/image.pdf tests/imgpdf.bb tests/imgpdf.xbb tests/picpdf.bb tests/picpdf.xbb
+EXTRA_DIST += tests/image.png tests/imgpng.bb tests/imgpng.xbb tests/picpng.bb tests/picpng.xbb
+DISTCLEANFILES += img*.* pic*.*
diff --git a/Build/source/texk/dvipdfm-x/Makefile.in b/Build/source/texk/dvipdfm-x/Makefile.in
index 10d6a860a6e..b81ce45f402 100644
--- a/Build/source/texk/dvipdfm-x/Makefile.in
+++ b/Build/source/texk/dvipdfm-x/Makefile.in
@@ -112,8 +112,8 @@ DIST_COMMON = $(top_srcdir)/../../am/bin_links.am \
$(top_srcdir)/../../build-aux/ltmain.sh \
$(top_srcdir)/../../build-aux/missing
@DVIPDFMX_TRUE@am__append_4 = extractbb:ebb
-@DVIPDFMX_TRUE@am__append_5 = dvipdfmx.test
-@XDVIPDFMX_TRUE@am__append_6 = xdvipdfmx.test
+@DVIPDFMX_TRUE@am__append_5 = $(dvipdfmx_tests)
+@XDVIPDFMX_TRUE@am__append_6 = $(xdvipdfmx_tests)
subdir = .
ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
am__aclocal_m4_deps = $(top_srcdir)/../../m4/cho-libs.m4 \
@@ -166,15 +166,16 @@ am__objects_1 = dvipdfmx-agl.$(OBJEXT) dvipdfmx-bmpimage.$(OBJEXT) \
dvipdfmx-otl_opt.$(OBJEXT) dvipdfmx-pdfencoding.$(OBJEXT) \
dvipdfmx-pdffont.$(OBJEXT) dvipdfmx-pdfparse.$(OBJEXT) \
dvipdfmx-pdfresource.$(OBJEXT) dvipdfmx-pkfont.$(OBJEXT) \
- dvipdfmx-pst.$(OBJEXT) dvipdfmx-pst_obj.$(OBJEXT) \
- dvipdfmx-sfnt.$(OBJEXT) dvipdfmx-spc_color.$(OBJEXT) \
- dvipdfmx-spc_html.$(OBJEXT) dvipdfmx-spc_misc.$(OBJEXT) \
- dvipdfmx-spc_util.$(OBJEXT) dvipdfmx-subfont.$(OBJEXT) \
- dvipdfmx-t1_char.$(OBJEXT) dvipdfmx-t1_load.$(OBJEXT) \
- dvipdfmx-tt_aux.$(OBJEXT) dvipdfmx-tt_glyf.$(OBJEXT) \
- dvipdfmx-tt_gsub.$(OBJEXT) dvipdfmx-tt_post.$(OBJEXT) \
- dvipdfmx-tt_table.$(OBJEXT) dvipdfmx-type0.$(OBJEXT) \
- dvipdfmx-unicode.$(OBJEXT) dvipdfmx-vf.$(OBJEXT)
+ dvipdfmx-pngimage.$(OBJEXT) dvipdfmx-pst.$(OBJEXT) \
+ dvipdfmx-pst_obj.$(OBJEXT) dvipdfmx-sfnt.$(OBJEXT) \
+ dvipdfmx-spc_color.$(OBJEXT) dvipdfmx-spc_html.$(OBJEXT) \
+ dvipdfmx-spc_misc.$(OBJEXT) dvipdfmx-spc_util.$(OBJEXT) \
+ dvipdfmx-subfont.$(OBJEXT) dvipdfmx-t1_char.$(OBJEXT) \
+ dvipdfmx-t1_load.$(OBJEXT) dvipdfmx-tt_aux.$(OBJEXT) \
+ dvipdfmx-tt_glyf.$(OBJEXT) dvipdfmx-tt_gsub.$(OBJEXT) \
+ dvipdfmx-tt_post.$(OBJEXT) dvipdfmx-tt_table.$(OBJEXT) \
+ dvipdfmx-type0.$(OBJEXT) dvipdfmx-unicode.$(OBJEXT) \
+ dvipdfmx-vf.$(OBJEXT)
am__dirstamp = $(am__leading_dot)dirstamp
am__objects_2 = src/dvipdfmx-cff_dict.$(OBJEXT) \
src/dvipdfmx-cidtype0.$(OBJEXT) src/dvipdfmx-dvi.$(OBJEXT) \
@@ -185,7 +186,6 @@ am__objects_2 = src/dvipdfmx-cff_dict.$(OBJEXT) \
src/dvipdfmx-pdfencrypt.$(OBJEXT) \
src/dvipdfmx-pdfnames.$(OBJEXT) src/dvipdfmx-pdfobj.$(OBJEXT) \
src/dvipdfmx-pdfximage.$(OBJEXT) \
- src/dvipdfmx-pngimage.$(OBJEXT) \
src/dvipdfmx-spc_dvips.$(OBJEXT) \
src/dvipdfmx-spc_pdfm.$(OBJEXT) \
src/dvipdfmx-spc_tpic.$(OBJEXT) \
@@ -211,15 +211,16 @@ am__objects_3 = xdvipdfmx-agl.$(OBJEXT) xdvipdfmx-bmpimage.$(OBJEXT) \
xdvipdfmx-otl_opt.$(OBJEXT) xdvipdfmx-pdfencoding.$(OBJEXT) \
xdvipdfmx-pdffont.$(OBJEXT) xdvipdfmx-pdfparse.$(OBJEXT) \
xdvipdfmx-pdfresource.$(OBJEXT) xdvipdfmx-pkfont.$(OBJEXT) \
- xdvipdfmx-pst.$(OBJEXT) xdvipdfmx-pst_obj.$(OBJEXT) \
- xdvipdfmx-sfnt.$(OBJEXT) xdvipdfmx-spc_color.$(OBJEXT) \
- xdvipdfmx-spc_html.$(OBJEXT) xdvipdfmx-spc_misc.$(OBJEXT) \
- xdvipdfmx-spc_util.$(OBJEXT) xdvipdfmx-subfont.$(OBJEXT) \
- xdvipdfmx-t1_char.$(OBJEXT) xdvipdfmx-t1_load.$(OBJEXT) \
- xdvipdfmx-tt_aux.$(OBJEXT) xdvipdfmx-tt_glyf.$(OBJEXT) \
- xdvipdfmx-tt_gsub.$(OBJEXT) xdvipdfmx-tt_post.$(OBJEXT) \
- xdvipdfmx-tt_table.$(OBJEXT) xdvipdfmx-type0.$(OBJEXT) \
- xdvipdfmx-unicode.$(OBJEXT) xdvipdfmx-vf.$(OBJEXT)
+ xdvipdfmx-pngimage.$(OBJEXT) xdvipdfmx-pst.$(OBJEXT) \
+ xdvipdfmx-pst_obj.$(OBJEXT) xdvipdfmx-sfnt.$(OBJEXT) \
+ xdvipdfmx-spc_color.$(OBJEXT) xdvipdfmx-spc_html.$(OBJEXT) \
+ xdvipdfmx-spc_misc.$(OBJEXT) xdvipdfmx-spc_util.$(OBJEXT) \
+ xdvipdfmx-subfont.$(OBJEXT) xdvipdfmx-t1_char.$(OBJEXT) \
+ xdvipdfmx-t1_load.$(OBJEXT) xdvipdfmx-tt_aux.$(OBJEXT) \
+ xdvipdfmx-tt_glyf.$(OBJEXT) xdvipdfmx-tt_gsub.$(OBJEXT) \
+ xdvipdfmx-tt_post.$(OBJEXT) xdvipdfmx-tt_table.$(OBJEXT) \
+ xdvipdfmx-type0.$(OBJEXT) xdvipdfmx-unicode.$(OBJEXT) \
+ xdvipdfmx-vf.$(OBJEXT)
am__objects_4 = xsrc/xdvipdfmx-cff_dict.$(OBJEXT) \
xsrc/xdvipdfmx-cidtype0.$(OBJEXT) xsrc/xdvipdfmx-dvi.$(OBJEXT) \
xsrc/xdvipdfmx-dvipdfmx.$(OBJEXT) \
@@ -233,7 +234,6 @@ am__objects_4 = xsrc/xdvipdfmx-cff_dict.$(OBJEXT) \
xsrc/xdvipdfmx-pdfnames.$(OBJEXT) \
xsrc/xdvipdfmx-pdfobj.$(OBJEXT) \
xsrc/xdvipdfmx-pdfximage.$(OBJEXT) \
- xsrc/xdvipdfmx-pngimage.$(OBJEXT) \
xsrc/xdvipdfmx-spc_dvips.$(OBJEXT) \
xsrc/xdvipdfmx-spc_pdfm.$(OBJEXT) \
xsrc/xdvipdfmx-spc_tpic.$(OBJEXT) xdvipdfmx-spc_xtx.$(OBJEXT) \
@@ -742,6 +742,7 @@ common_sources = \
pdffont.c \
pdffont.h \
pdflimits.h \
+ pdfobj.h \
pdfparse.c \
pdfparse.h \
pdfresource.c \
@@ -749,6 +750,7 @@ common_sources = \
pdfximage.h \
pkfont.c \
pkfont.h \
+ pngimage.c \
pngimage.h \
pst.c \
pst.h \
@@ -795,8 +797,7 @@ common_sources = \
unicode.c \
unicode.h \
vf.c \
- vf.h \
- xbb.h
+ vf.h
dvipdfmx_sources = \
src/cff_dict.c \
@@ -814,9 +815,7 @@ dvipdfmx_sources = \
src/pdfnames.c \
src/pdfnames.h \
src/pdfobj.c \
- src/pdfobj.h \
src/pdfximage.c \
- src/pngimage.c \
src/spc_dvips.c \
src/spc_pdfm.c \
src/spc_tpic.c \
@@ -843,9 +842,7 @@ xdvipdfmx_sources = \
xsrc/pdfnames.c \
xsrc/pdfnames.h \
xsrc/pdfobj.c \
- xsrc/pdfobj.h \
xsrc/pdfximage.c \
- xsrc/pngimage.c \
xsrc/spc_dvips.c \
xsrc/spc_pdfm.c \
xsrc/spc_tpic.c \
@@ -860,7 +857,13 @@ xdvipdfmx_sources = \
xsrc/xbb.c
EXTRA_DIST = $(common_sources) $(dvipdfmx_sources) \
- $(xdvipdfmx_sources) dvipdfmx.test xdvipdfmx.test
+ $(xdvipdfmx_sources) $(dvipdfmx_tests) $(xdvipdfmx_tests) \
+ tests/dvipdfmx.cfg tests/image.jpeg tests/imgjpeg.bb \
+ tests/imgjpeg.xbb tests/picjpeg.bb tests/picjpeg.xbb \
+ tests/image.pdf tests/imgpdf.bb tests/imgpdf.xbb \
+ tests/picpdf.bb tests/picpdf.xbb tests/image.png \
+ tests/imgpng.bb tests/imgpng.xbb tests/picpng.bb \
+ tests/picpng.xbb
bin_links = $(am__append_3)
call_dvipdfmx_CPPFLAGS = -DEXEPROG=\"dvipdfmx.exe\"
nodist_call_dvipdfmx_SOURCES = callexe.c
@@ -877,8 +880,10 @@ mapdatadir = $(datarootdir)/texmf-dist/fonts/map/dvipdfmx
dist_mapdata_DATA = data/cid-x.map
cmapdatadir = $(datarootdir)/texmf-dist/fonts/cmap/dvipdfmx
dist_cmapdata_DATA = data/EUC-UCS2
-DISTCLEANFILES = config.force
+DISTCLEANFILES = config.force img*.* pic*.*
TESTS = $(am__append_5) $(am__append_6)
+dvipdfmx_tests = dvipdfmx.test dvipdfm-bb.test
+xdvipdfmx_tests = xdvipdfmx.test xdvipdfm-bb.test
all: config.h
$(MAKE) $(AM_MAKEFLAGS) all-am
@@ -1030,8 +1035,6 @@ src/dvipdfmx-pdfobj.$(OBJEXT): src/$(am__dirstamp) \
src/$(DEPDIR)/$(am__dirstamp)
src/dvipdfmx-pdfximage.$(OBJEXT): src/$(am__dirstamp) \
src/$(DEPDIR)/$(am__dirstamp)
-src/dvipdfmx-pngimage.$(OBJEXT): src/$(am__dirstamp) \
- src/$(DEPDIR)/$(am__dirstamp)
src/dvipdfmx-spc_dvips.$(OBJEXT): src/$(am__dirstamp) \
src/$(DEPDIR)/$(am__dirstamp)
src/dvipdfmx-spc_pdfm.$(OBJEXT): src/$(am__dirstamp) \
@@ -1090,8 +1093,6 @@ xsrc/xdvipdfmx-pdfobj.$(OBJEXT): xsrc/$(am__dirstamp) \
xsrc/$(DEPDIR)/$(am__dirstamp)
xsrc/xdvipdfmx-pdfximage.$(OBJEXT): xsrc/$(am__dirstamp) \
xsrc/$(DEPDIR)/$(am__dirstamp)
-xsrc/xdvipdfmx-pngimage.$(OBJEXT): xsrc/$(am__dirstamp) \
- xsrc/$(DEPDIR)/$(am__dirstamp)
xsrc/xdvipdfmx-spc_dvips.$(OBJEXT): xsrc/$(am__dirstamp) \
xsrc/$(DEPDIR)/$(am__dirstamp)
xsrc/xdvipdfmx-spc_pdfm.$(OBJEXT): xsrc/$(am__dirstamp) \
@@ -1187,6 +1188,7 @@ distclean-compile:
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/dvipdfmx-pdfparse.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/dvipdfmx-pdfresource.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/dvipdfmx-pkfont.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/dvipdfmx-pngimage.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/dvipdfmx-pst.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/dvipdfmx-pst_obj.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/dvipdfmx-sfnt.Po@am__quote@
@@ -1231,6 +1233,7 @@ distclean-compile:
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/xdvipdfmx-pdfparse.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/xdvipdfmx-pdfresource.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/xdvipdfmx-pkfont.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/xdvipdfmx-pngimage.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/xdvipdfmx-pst.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/xdvipdfmx-pst_obj.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/xdvipdfmx-sfnt.Po@am__quote@
@@ -1264,7 +1267,6 @@ distclean-compile:
@AMDEP_TRUE@@am__include@ @am__quote@src/$(DEPDIR)/dvipdfmx-pdfnames.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@src/$(DEPDIR)/dvipdfmx-pdfobj.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@src/$(DEPDIR)/dvipdfmx-pdfximage.Po@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@src/$(DEPDIR)/dvipdfmx-pngimage.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@src/$(DEPDIR)/dvipdfmx-spc_dvips.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@src/$(DEPDIR)/dvipdfmx-spc_pdfm.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@src/$(DEPDIR)/dvipdfmx-spc_tpic.Po@am__quote@
@@ -1289,7 +1291,6 @@ distclean-compile:
@AMDEP_TRUE@@am__include@ @am__quote@xsrc/$(DEPDIR)/xdvipdfmx-pdfnames.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@xsrc/$(DEPDIR)/xdvipdfmx-pdfobj.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@xsrc/$(DEPDIR)/xdvipdfmx-pdfximage.Po@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@xsrc/$(DEPDIR)/xdvipdfmx-pngimage.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@xsrc/$(DEPDIR)/xdvipdfmx-spc_dvips.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@xsrc/$(DEPDIR)/xdvipdfmx-spc_pdfm.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@xsrc/$(DEPDIR)/xdvipdfmx-spc_tpic.Po@am__quote@
@@ -1703,6 +1704,20 @@ dvipdfmx-pkfont.obj: pkfont.c
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(dvipdfmx_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o dvipdfmx-pkfont.obj `if test -f 'pkfont.c'; then $(CYGPATH_W) 'pkfont.c'; else $(CYGPATH_W) '$(srcdir)/pkfont.c'; fi`
+dvipdfmx-pngimage.o: pngimage.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(dvipdfmx_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT dvipdfmx-pngimage.o -MD -MP -MF $(DEPDIR)/dvipdfmx-pngimage.Tpo -c -o dvipdfmx-pngimage.o `test -f 'pngimage.c' || echo '$(srcdir)/'`pngimage.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/dvipdfmx-pngimage.Tpo $(DEPDIR)/dvipdfmx-pngimage.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='pngimage.c' object='dvipdfmx-pngimage.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(dvipdfmx_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o dvipdfmx-pngimage.o `test -f 'pngimage.c' || echo '$(srcdir)/'`pngimage.c
+
+dvipdfmx-pngimage.obj: pngimage.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(dvipdfmx_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT dvipdfmx-pngimage.obj -MD -MP -MF $(DEPDIR)/dvipdfmx-pngimage.Tpo -c -o dvipdfmx-pngimage.obj `if test -f 'pngimage.c'; then $(CYGPATH_W) 'pngimage.c'; else $(CYGPATH_W) '$(srcdir)/pngimage.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/dvipdfmx-pngimage.Tpo $(DEPDIR)/dvipdfmx-pngimage.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='pngimage.c' object='dvipdfmx-pngimage.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(dvipdfmx_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o dvipdfmx-pngimage.obj `if test -f 'pngimage.c'; then $(CYGPATH_W) 'pngimage.c'; else $(CYGPATH_W) '$(srcdir)/pngimage.c'; fi`
+
dvipdfmx-pst.o: pst.c
@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(dvipdfmx_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT dvipdfmx-pst.o -MD -MP -MF $(DEPDIR)/dvipdfmx-pst.Tpo -c -o dvipdfmx-pst.o `test -f 'pst.c' || echo '$(srcdir)/'`pst.c
@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/dvipdfmx-pst.Tpo $(DEPDIR)/dvipdfmx-pst.Po
@@ -2151,20 +2166,6 @@ src/dvipdfmx-pdfximage.obj: src/pdfximage.c
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(dvipdfmx_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o src/dvipdfmx-pdfximage.obj `if test -f 'src/pdfximage.c'; then $(CYGPATH_W) 'src/pdfximage.c'; else $(CYGPATH_W) '$(srcdir)/src/pdfximage.c'; fi`
-src/dvipdfmx-pngimage.o: src/pngimage.c
-@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(dvipdfmx_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT src/dvipdfmx-pngimage.o -MD -MP -MF src/$(DEPDIR)/dvipdfmx-pngimage.Tpo -c -o src/dvipdfmx-pngimage.o `test -f 'src/pngimage.c' || echo '$(srcdir)/'`src/pngimage.c
-@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) src/$(DEPDIR)/dvipdfmx-pngimage.Tpo src/$(DEPDIR)/dvipdfmx-pngimage.Po
-@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='src/pngimage.c' object='src/dvipdfmx-pngimage.o' libtool=no @AMDEPBACKSLASH@
-@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
-@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(dvipdfmx_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o src/dvipdfmx-pngimage.o `test -f 'src/pngimage.c' || echo '$(srcdir)/'`src/pngimage.c
-
-src/dvipdfmx-pngimage.obj: src/pngimage.c
-@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(dvipdfmx_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT src/dvipdfmx-pngimage.obj -MD -MP -MF src/$(DEPDIR)/dvipdfmx-pngimage.Tpo -c -o src/dvipdfmx-pngimage.obj `if test -f 'src/pngimage.c'; then $(CYGPATH_W) 'src/pngimage.c'; else $(CYGPATH_W) '$(srcdir)/src/pngimage.c'; fi`
-@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) src/$(DEPDIR)/dvipdfmx-pngimage.Tpo src/$(DEPDIR)/dvipdfmx-pngimage.Po
-@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='src/pngimage.c' object='src/dvipdfmx-pngimage.obj' libtool=no @AMDEPBACKSLASH@
-@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
-@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(dvipdfmx_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o src/dvipdfmx-pngimage.obj `if test -f 'src/pngimage.c'; then $(CYGPATH_W) 'src/pngimage.c'; else $(CYGPATH_W) '$(srcdir)/src/pngimage.c'; fi`
-
src/dvipdfmx-spc_dvips.o: src/spc_dvips.c
@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(dvipdfmx_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT src/dvipdfmx-spc_dvips.o -MD -MP -MF src/$(DEPDIR)/dvipdfmx-spc_dvips.Tpo -c -o src/dvipdfmx-spc_dvips.o `test -f 'src/spc_dvips.c' || echo '$(srcdir)/'`src/spc_dvips.c
@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) src/$(DEPDIR)/dvipdfmx-spc_dvips.Tpo src/$(DEPDIR)/dvipdfmx-spc_dvips.Po
@@ -2669,6 +2670,20 @@ xdvipdfmx-pkfont.obj: pkfont.c
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(xdvipdfmx_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o xdvipdfmx-pkfont.obj `if test -f 'pkfont.c'; then $(CYGPATH_W) 'pkfont.c'; else $(CYGPATH_W) '$(srcdir)/pkfont.c'; fi`
+xdvipdfmx-pngimage.o: pngimage.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(xdvipdfmx_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT xdvipdfmx-pngimage.o -MD -MP -MF $(DEPDIR)/xdvipdfmx-pngimage.Tpo -c -o xdvipdfmx-pngimage.o `test -f 'pngimage.c' || echo '$(srcdir)/'`pngimage.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/xdvipdfmx-pngimage.Tpo $(DEPDIR)/xdvipdfmx-pngimage.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='pngimage.c' object='xdvipdfmx-pngimage.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(xdvipdfmx_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o xdvipdfmx-pngimage.o `test -f 'pngimage.c' || echo '$(srcdir)/'`pngimage.c
+
+xdvipdfmx-pngimage.obj: pngimage.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(xdvipdfmx_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT xdvipdfmx-pngimage.obj -MD -MP -MF $(DEPDIR)/xdvipdfmx-pngimage.Tpo -c -o xdvipdfmx-pngimage.obj `if test -f 'pngimage.c'; then $(CYGPATH_W) 'pngimage.c'; else $(CYGPATH_W) '$(srcdir)/pngimage.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/xdvipdfmx-pngimage.Tpo $(DEPDIR)/xdvipdfmx-pngimage.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='pngimage.c' object='xdvipdfmx-pngimage.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(xdvipdfmx_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o xdvipdfmx-pngimage.obj `if test -f 'pngimage.c'; then $(CYGPATH_W) 'pngimage.c'; else $(CYGPATH_W) '$(srcdir)/pngimage.c'; fi`
+
xdvipdfmx-pst.o: pst.c
@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(xdvipdfmx_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT xdvipdfmx-pst.o -MD -MP -MF $(DEPDIR)/xdvipdfmx-pst.Tpo -c -o xdvipdfmx-pst.o `test -f 'pst.c' || echo '$(srcdir)/'`pst.c
@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/xdvipdfmx-pst.Tpo $(DEPDIR)/xdvipdfmx-pst.Po
@@ -3117,20 +3132,6 @@ xsrc/xdvipdfmx-pdfximage.obj: xsrc/pdfximage.c
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(xdvipdfmx_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o xsrc/xdvipdfmx-pdfximage.obj `if test -f 'xsrc/pdfximage.c'; then $(CYGPATH_W) 'xsrc/pdfximage.c'; else $(CYGPATH_W) '$(srcdir)/xsrc/pdfximage.c'; fi`
-xsrc/xdvipdfmx-pngimage.o: xsrc/pngimage.c
-@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(xdvipdfmx_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT xsrc/xdvipdfmx-pngimage.o -MD -MP -MF xsrc/$(DEPDIR)/xdvipdfmx-pngimage.Tpo -c -o xsrc/xdvipdfmx-pngimage.o `test -f 'xsrc/pngimage.c' || echo '$(srcdir)/'`xsrc/pngimage.c
-@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) xsrc/$(DEPDIR)/xdvipdfmx-pngimage.Tpo xsrc/$(DEPDIR)/xdvipdfmx-pngimage.Po
-@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='xsrc/pngimage.c' object='xsrc/xdvipdfmx-pngimage.o' libtool=no @AMDEPBACKSLASH@
-@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
-@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(xdvipdfmx_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o xsrc/xdvipdfmx-pngimage.o `test -f 'xsrc/pngimage.c' || echo '$(srcdir)/'`xsrc/pngimage.c
-
-xsrc/xdvipdfmx-pngimage.obj: xsrc/pngimage.c
-@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(xdvipdfmx_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT xsrc/xdvipdfmx-pngimage.obj -MD -MP -MF xsrc/$(DEPDIR)/xdvipdfmx-pngimage.Tpo -c -o xsrc/xdvipdfmx-pngimage.obj `if test -f 'xsrc/pngimage.c'; then $(CYGPATH_W) 'xsrc/pngimage.c'; else $(CYGPATH_W) '$(srcdir)/xsrc/pngimage.c'; fi`
-@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) xsrc/$(DEPDIR)/xdvipdfmx-pngimage.Tpo xsrc/$(DEPDIR)/xdvipdfmx-pngimage.Po
-@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='xsrc/pngimage.c' object='xsrc/xdvipdfmx-pngimage.obj' libtool=no @AMDEPBACKSLASH@
-@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
-@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(xdvipdfmx_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o xsrc/xdvipdfmx-pngimage.obj `if test -f 'xsrc/pngimage.c'; then $(CYGPATH_W) 'xsrc/pngimage.c'; else $(CYGPATH_W) '$(srcdir)/xsrc/pngimage.c'; fi`
-
xsrc/xdvipdfmx-spc_dvips.o: xsrc/spc_dvips.c
@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(xdvipdfmx_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT xsrc/xdvipdfmx-spc_dvips.o -MD -MP -MF xsrc/$(DEPDIR)/xdvipdfmx-spc_dvips.Tpo -c -o xsrc/xdvipdfmx-spc_dvips.o `test -f 'xsrc/spc_dvips.c' || echo '$(srcdir)/'`xsrc/spc_dvips.c
@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) xsrc/$(DEPDIR)/xdvipdfmx-spc_dvips.Tpo xsrc/$(DEPDIR)/xdvipdfmx-spc_dvips.Po
diff --git a/Build/source/texk/dvipdfm-x/dvipdfm-bb.test b/Build/source/texk/dvipdfm-x/dvipdfm-bb.test
new file mode 100755
index 00000000000..4d5e9bac67e
--- /dev/null
+++ b/Build/source/texk/dvipdfm-x/dvipdfm-bb.test
@@ -0,0 +1,47 @@
+#! /bin/sh
+
+# Copyright (C) 2013 Peter Breitenlohner <tex-live@tug.org>
+# You may freely use, modify and/or distribute this file.
+
+TEXMFCNF=${srcdir}/../kpathsea
+DVIPDFMXINPUTS=${srcdir}/tests:${srcdir}/data
+export TEXMFCNF DVIPDFMXINPUTS
+
+testsrc=$srcdir/tests
+
+failed=
+
+rm -f img*.*
+
+for e in jpeg png pdf; do
+ cp $testsrc/image.$e img$e.$e
+done
+
+./dvipdfmx --ebb --help \
+ && echo "ebb-help tests OK" \
+ || failed="$failed ebb-help"
+
+for e in jpeg png pdf; do
+ ./dvipdfmx --ebb -O img$e.$e \
+ | sed '/%%CreationDate/d' >img$e.bb \
+ && diff $testsrc/img$e.bb img$e.bb \
+ && echo "ebb-$e tests OK" \
+ || failed="$failed ebb-$e"
+done
+
+./dvipdfmx --xbb --help \
+ && echo "xbb-help tests OK" \
+ || failed="$failed xbb-help"
+
+for e in jpeg png pdf; do
+ ./dvipdfmx --xbb -O img$e.$e \
+ | sed '/%%CreationDate/d' >img$e.xbb \
+ && diff $testsrc/img$e.xbb img$e.xbb \
+ && echo "xbb-$e tests OK" \
+ || failed="$failed xbb-$e"
+done
+
+test -z "$failed" && exit 0
+echo "failed tests:$failed"
+exit 1
+
diff --git a/Build/source/texk/dvipdfm-x/dvipdfmx.h b/Build/source/texk/dvipdfm-x/dvipdfmx.h
index 0736e061988..0617de47daf 100644
--- a/Build/source/texk/dvipdfm-x/dvipdfmx.h
+++ b/Build/source/texk/dvipdfm-x/dvipdfmx.h
@@ -25,4 +25,6 @@
extern int compat_mode;
+extern int extractbb(int argc, char *argv[]);
+
#endif /* _DVIPDFMX_H_ */
diff --git a/Build/source/texk/dvipdfm-x/dvipdfmx.test b/Build/source/texk/dvipdfm-x/dvipdfmx.test
index 2a18fdf9be7..cc61bb85a1b 100755
--- a/Build/source/texk/dvipdfm-x/dvipdfmx.test
+++ b/Build/source/texk/dvipdfm-x/dvipdfmx.test
@@ -5,7 +5,7 @@
# Not really a test, just making sure the program executes.
-TEXMFCNF=${srcdir}/../../kpathsea \
- DVIPDFMXINPUTS=${srcdir}/../data \
+TEXMFCNF=${srcdir}/../kpathsea \
+ DVIPDFMXINPUTS=${srcdir}/tests:${srcdir}/data \
./dvipdfmx --help || exit 1
diff --git a/Build/source/texk/dvipdfm-x/pdfdoc.h b/Build/source/texk/dvipdfm-x/pdfdoc.h
index c42fbd55410..793bd2d2b05 100644
--- a/Build/source/texk/dvipdfm-x/pdfdoc.h
+++ b/Build/source/texk/dvipdfm-x/pdfdoc.h
@@ -63,10 +63,8 @@ extern pdf_obj *pdf_doc_get_reference (const char *category);
#define pdf_doc_names() pdf_doc_get_dictionary("Names")
#define pdf_doc_this_page() pdf_doc_get_dictionary("@THISPAGE")
-#ifndef XETEX
extern pdf_obj *pdf_doc_get_page (pdf_file *pf, long page_no, long *count_p,
pdf_rect *bbox, pdf_obj **resources_p);
-#endif
extern long pdf_doc_current_page_number (void);
extern pdf_obj *pdf_doc_current_page_resources (void);
diff --git a/Build/source/texk/dvipdfm-x/src/pdfobj.h b/Build/source/texk/dvipdfm-x/pdfobj.h
index 85d78870506..c68b9a6b0ed 100644
--- a/Build/source/texk/dvipdfm-x/src/pdfobj.h
+++ b/Build/source/texk/dvipdfm-x/pdfobj.h
@@ -77,17 +77,18 @@ extern int pdf_obj_typeof (pdf_obj *object);
#define PDF_OBJ_TYPEOF(o) pdf_obj_typeof((o))
-
extern pdf_obj *pdf_ref_obj (pdf_obj *object);
extern pdf_obj *pdf_link_obj (pdf_obj *object);
-extern void pdf_transfer_label (pdf_obj *dst, pdf_obj *src);
+#ifndef XETEX
+extern void pdf_transfer_label (pdf_obj *dst, pdf_obj *src);
extern pdf_obj *pdf_new_undefined (void);
+#endif
extern pdf_obj *pdf_new_null (void);
extern pdf_obj *pdf_new_boolean (char value);
-#if 0
+#ifdef XETEX
extern void pdf_set_boolean (pdf_obj *object, char value);
#endif
extern char pdf_boolean_value (pdf_obj *object);
@@ -103,7 +104,7 @@ extern unsigned pdf_string_length (pdf_obj *object);
/* Name does not include the / */
extern pdf_obj *pdf_new_name (const char *name);
-#if 0
+#ifdef XETEX
extern void pdf_set_name (pdf_obj *object, const char *name);
#endif
extern char *pdf_name_value (pdf_obj *object);
@@ -185,16 +186,20 @@ extern int pdf_compare_reference (pdf_obj *ref1, pdf_obj *ref2);
extern void pdf_set_compression (int level);
extern void pdf_set_info (pdf_obj *obj);
-extern void pdf_set_id (pdf_obj *id);
extern void pdf_set_root (pdf_obj *obj);
+#ifdef XETEX
+extern void pdf_set_encrypt (pdf_obj *encrypt, pdf_obj *id);
+#else
+extern void pdf_set_id (pdf_obj *id);
extern void pdf_set_encrypt (pdf_obj *encrypt);
+#endif
extern void pdf_files_init (void);
extern void pdf_files_close (void);
extern int check_for_pdf (FILE *file);
extern pdf_file *pdf_open (const char *ident, FILE *file);
extern void pdf_close (pdf_file *pf);
-#if 0
+#ifdef XETEX
extern pdf_obj *pdf_file_get_trailer (pdf_file *pf);
#endif
extern int pdf_file_get_version (pdf_file *pf);
@@ -206,5 +211,8 @@ extern pdf_obj *pdf_import_object (pdf_obj *object);
extern int pdfobj_escape_str (char *buffer, int size, const unsigned char *s, int len);
extern pdf_obj *pdf_new_indirect (pdf_file *pf, unsigned long label, unsigned short generation);
+#ifdef XETEX
+extern void pdf_copy_object (pdf_obj *dst, pdf_obj *src);
+#endif
#endif /* _PDFOBJ_H_ */
diff --git a/Build/source/texk/dvipdfm-x/pdfximage.h b/Build/source/texk/dvipdfm-x/pdfximage.h
index dc9c54e4a3c..5c37c710a33 100644
--- a/Build/source/texk/dvipdfm-x/pdfximage.h
+++ b/Build/source/texk/dvipdfm-x/pdfximage.h
@@ -72,7 +72,6 @@ extern void pdf_ximage_init_image_info (ximage_info *info);
extern void pdf_ximage_init_form_info (xform_info *info);
#ifdef XETEX
extern char *pdf_ximage_get_ident (pdf_ximage *ximage);
-extern void pdf_ximage_set_page (pdf_ximage *ximage, long page_no, long page_count);
#endif
extern void pdf_ximage_set_image (pdf_ximage *ximage, void *info, pdf_obj *resource);
extern void pdf_ximage_set_form (pdf_ximage *ximage, void *info, pdf_obj *resource);
diff --git a/Build/source/texk/dvipdfm-x/src/pngimage.c b/Build/source/texk/dvipdfm-x/pngimage.c
index 2583a8a6ced..d15809527fe 100644
--- a/Build/source/texk/dvipdfm-x/src/pngimage.c
+++ b/Build/source/texk/dvipdfm-x/pngimage.c
@@ -167,7 +167,7 @@ png_include_image (pdf_ximage *ximage, FILE *png_file)
png_structp png_ptr;
png_infop png_info_ptr;
png_byte bpc, color_type;
- png_uint_32 width, height, rowbytes, xppm, yppm;
+ png_uint_32 width, height, rowbytes;
pdf_ximage_init_image_info(&info);
@@ -194,8 +194,6 @@ png_include_image (pdf_ximage *ximage, FILE *png_file)
width = png_get_image_width (png_ptr, png_info_ptr);
height = png_get_image_height(png_ptr, png_info_ptr);
bpc = png_get_bit_depth (png_ptr, png_info_ptr);
- xppm = png_get_x_pixels_per_meter(png_ptr, png_info_ptr);
- yppm = png_get_y_pixels_per_meter(png_ptr, png_info_ptr);
/* We do not need 16-bpc color. Ask libpng to convert down to 8-bpc. */
if (bpc > 8) {
@@ -215,7 +213,11 @@ png_include_image (pdf_ximage *ximage, FILE *png_file)
if (compat_mode)
info.xdensity = info.ydensity = 72.0 / 100.0;
- else {
+ else
+ {
+ png_uint_32 xppm = png_get_x_pixels_per_meter(png_ptr, png_info_ptr);
+ png_uint_32 yppm = png_get_y_pixels_per_meter(png_ptr, png_info_ptr);
+
if (xppm > 0)
info.xdensity = 72.0 / 0.0254 / xppm;
if (yppm > 0)
@@ -1023,7 +1025,6 @@ png_get_bbox (FILE *png_file, long *width, long *height,
{
png_structp png_ptr;
png_infop png_info_ptr;
- png_uint_32 xppm, yppm;
rewind (png_file);
png_ptr = png_create_read_struct(PNG_LIBPNG_VER_STRING, NULL, NULL, NULL);
@@ -1042,22 +1043,24 @@ png_get_bbox (FILE *png_file, long *width, long *height,
png_read_info(png_ptr, png_info_ptr);
*width = png_get_image_width (png_ptr, png_info_ptr);
*height = png_get_image_height(png_ptr, png_info_ptr);
- xppm = png_get_x_pixels_per_meter(png_ptr, png_info_ptr);
- yppm = png_get_y_pixels_per_meter(png_ptr, png_info_ptr);
-
- /* Cleanup */
- if (png_info_ptr)
- png_destroy_info_struct(png_ptr, &png_info_ptr);
- if (png_ptr)
- png_destroy_read_struct(&png_ptr, NULL, NULL);
if (compat_mode)
*xdensity = *ydensity = 72.0 / 100.0;
- else {
+ else
+ {
+ png_uint_32 xppm = png_get_x_pixels_per_meter(png_ptr, png_info_ptr);
+ png_uint_32 yppm = png_get_y_pixels_per_meter(png_ptr, png_info_ptr);
+
*xdensity = xppm ? 72.0 / 0.0254 / xppm : 1.0;
*ydensity = yppm ? 72.0 / 0.0254 / yppm : 1.0;
}
+ /* Cleanup */
+ if (png_info_ptr)
+ png_destroy_info_struct(png_ptr, &png_info_ptr);
+ if (png_ptr)
+ png_destroy_read_struct(&png_ptr, NULL, NULL);
+
return 0;
}
diff --git a/Build/source/texk/dvipdfm-x/src/dvipdfmx.c b/Build/source/texk/dvipdfm-x/src/dvipdfmx.c
index 0b4ea307fe9..147454d933f 100644
--- a/Build/source/texk/dvipdfm-x/src/dvipdfmx.c
+++ b/Build/source/texk/dvipdfm-x/src/dvipdfmx.c
@@ -57,7 +57,6 @@
#include "cid.h"
#include "dvipdfmx.h"
-#include "xbb.h"
#include "error.h"
@@ -866,18 +865,41 @@ int CDECL
main (int argc, char *argv[])
{
double dvi2pts;
+ char *base;
- char *base = kpse_program_basename (argv[0]);
+#ifdef MIKTEX
+ miktex_initialize();
+#else
+ kpse_set_program_name(argv[0], "dvipdfmx"); /* we pretend to be dvipdfmx for kpse purposes */
+#ifdef WIN32
+ texlive_gs_init ();
+#endif
+#endif
+
+ if (argc > 1 &&
+ (STREQ (argv[1], "--xbb") ||
+#ifndef XETEX
+ STREQ (argv[1], "--dvipdfm") ||
+#endif
+ STREQ (argv[1], "--ebb"))) {
+ argc--;
+ base = argv++[1]+2;
+ } else
+ base = kpse_program_basename (argv[0]);
if (FILESTRCASEEQ (base, "extractbb") || FILESTRCASEEQ (base, "xbb"))
- return extractbb (argc, argv, XBB_OUTPUT);
- if (FILESTRCASEEQ (base, "ebb"))
- return extractbb (argc, argv, EBB_OUTPUT);
+ return extractbb (argc, argv);
+ if (FILESTRCASEEQ (base, "ebb")) {
+ compat_mode = 1;
+ return extractbb (argc, argv);
+ }
+#ifndef XETEX
if (FILESTRCASEEQ (base, "dvipdfm"))
compat_mode = 1;
-
- free (base);
+ else
+#endif
+ free (base);
if (argc < 2) {
if (!really_quiet)
@@ -886,12 +908,6 @@ main (int argc, char *argv[])
return 1;
}
-#ifdef MIKTEX
- miktex_initialize();
-#else
- kpse_set_program_name(argv[0], "dvipdfmx"); /* we pretend to be dvipdfmx for kpse purposes */
-#endif
-
paperinit();
system_default();
diff --git a/Build/source/texk/dvipdfm-x/src/pdfobj.c b/Build/source/texk/dvipdfm-x/src/pdfobj.c
index 82a10a0b504..779baf18497 100644
--- a/Build/source/texk/dvipdfm-x/src/pdfobj.c
+++ b/Build/source/texk/dvipdfm-x/src/pdfobj.c
@@ -596,6 +596,9 @@ pdf_new_obj(int type)
{
pdf_obj *result;
+ if (type >= PDF_UNDEFINED || type < 0)
+ ERROR("Invalid object type: %d", type);
+
result = NEW(1, pdf_obj);
result->type = type;
result->data = NULL;
@@ -604,9 +607,6 @@ pdf_new_obj(int type)
result->refcount = 1;
result->flags = 0;
- if (INVALIDOBJ(result))
- ERROR("Invalid object type: %d", type);
-
return result;
}
@@ -771,7 +771,7 @@ write_boolean (pdf_boolean *data, FILE *file)
}
}
-#if 0
+#ifdef XETEX
void
pdf_set_boolean (pdf_obj *object, char value)
{
@@ -1100,7 +1100,7 @@ release_name (pdf_name *data)
RELEASE(data);
}
-#if 0
+#ifdef XETEX
void
pdf_set_name (pdf_obj *object, const char *name)
{
@@ -1343,11 +1343,10 @@ pdf_pop_array (pdf_obj *array)
}
#endif
-
static void
write_dict (pdf_dict *dict, FILE *file)
{
-#if 0
+#ifdef XETEX
pdf_out (file, "<<\n", 3); /* dropping \n saves few kb. */
#else
pdf_out (file, "<<", 2);
@@ -1358,7 +1357,7 @@ write_dict (pdf_dict *dict, FILE *file)
pdf_out_white(file);
}
pdf_write_obj(dict->value, file);
-#if 0
+#ifdef XETEX
pdf_out_char (file, '\n'); /* removing this saves few kb. */
#endif
dict = dict->next;
@@ -2766,6 +2765,7 @@ parse_xref_stream (pdf_file *pf, long xref_pos, pdf_obj **trailer)
return 0;
}
+/* TODO: parse Version entry */
static pdf_obj *
read_xref (pdf_file *pf)
{
@@ -2903,7 +2903,7 @@ pdf_file_get_version (pdf_file *pf)
return pf->version;
}
-#if 0
+#ifdef XETEX
pdf_obj *
pdf_file_get_trailer (pdf_file *pf)
{
diff --git a/Build/source/texk/dvipdfm-x/src/pdfximage.c b/Build/source/texk/dvipdfm-x/src/pdfximage.c
index 54f59531389..6b43f531c3f 100644
--- a/Build/source/texk/dvipdfm-x/src/pdfximage.c
+++ b/Build/source/texk/dvipdfm-x/src/pdfximage.c
@@ -48,7 +48,7 @@
/* From psimage.h */
static int check_for_ps (FILE *fp);
-static int ps_include_page (pdf_ximage *ximage);
+static int ps_include_page (pdf_ximage *ximage, const char *file_name);
#define IMAGE_TYPE_UNKNOWN -1
@@ -71,7 +71,7 @@ struct pdf_ximage_
{
char *ident;
char res_name[16];
- long page_no;
+ long page_no, page_count;
int subtype;
@@ -121,6 +121,7 @@ pdf_init_ximage_struct (pdf_ximage *I,
} else
I ->ident = NULL;
I->page_no = page_no;
+ I->page_count = 0;
if (filename) {
I->filename = NEW(strlen(filename)+1, char);
strcpy(I->filename, filename);
@@ -295,7 +296,7 @@ load_image (const char *ident, const char *fullname, int format, FILE *fp,
int result = pdf_include_page(I, fp, fullname);
if (result > 0)
/* PDF version too recent */
- result = ps_include_page(I);
+ result = ps_include_page(I, NULL);
if (result < 0)
goto error;
}
@@ -307,7 +308,7 @@ load_image (const char *ident, const char *fullname, int format, FILE *fp,
default:
if (_opts.verbose)
MESG(format == IMAGE_TYPE_EPS ? "[PS]" : "[UNKNOWN]");
- if (ps_include_page(I) < 0)
+ if (ps_include_page(I, NULL) < 0)
goto error;
if (_opts.verbose)
MESG(",Page:%ld", I->page_no);
@@ -861,15 +862,16 @@ void set_distiller_template (char *s)
}
static int
-ps_include_page (pdf_ximage *ximage)
+ps_include_page (pdf_ximage *ximage, const char *filename)
{
char *distiller_template = _opts.cmdtmpl;
- char *filename = ximage->filename;
char *temp;
FILE *fp;
int error = 0;
struct stat stat_o, stat_t;
+ filename = ximage->filename;
+
if (!distiller_template) {
WARN("No image converter available for converting file \"%s\" to PDF format.", filename);
WARN(">> Please check if you have 'D' option in config file.");
diff --git a/Build/source/texk/dvipdfm-x/src/xbb.c b/Build/source/texk/dvipdfm-x/src/xbb.c
index f11640e6b17..69f653cef19 100644
--- a/Build/source/texk/dvipdfm-x/src/xbb.c
+++ b/Build/source/texk/dvipdfm-x/src/xbb.c
@@ -43,7 +43,6 @@
#include "pngimage.h"
#include "dvipdfmx.h"
-#include "xbb.h"
#define XBB_PROGRAM "extractbb"
#define XBB_VERSION VERSION
@@ -125,7 +124,7 @@ static char *make_xbb_filename(const char *name)
strncpy(result, name, strlen(name)-strlen(extensions[i]));
result[strlen(name)-strlen(extensions[i])] = 0;
}
- strcat(result, (!compat_mode ? ".xbb" : ".bb"));
+ strcat(result, (compat_mode ? ".bb" : ".xbb"));
return result;
}
@@ -200,7 +199,6 @@ static void do_jpeg (FILE *fp, char *filename)
}
#ifdef HAVE_LIBPNG
-
static void do_png (FILE *fp, char *filename)
{
long width, height;
@@ -214,9 +212,166 @@ static void do_png (FILE *fp, char *filename)
write_xbb(filename, 0, 0, xdensity*width, ydensity*height, -1, -1);
return;
}
-
#endif /* HAVE_LIBPNG */
+#ifdef XETEX
+static void write_xbb_old(char *fname, int bbllx, int bblly, int bburx, int bbury)
+{
+ char *outname;
+ FILE *fp;
+
+ outname = make_xbb_filename(fname);
+ if ((fp = MFOPEN(outname, xbb_file_mode)) == NULL) {
+ fprintf(stderr, "Unable to open output file: %s\n", outname);
+ RELEASE(outname);
+ return;
+ }
+ if (verbose) {
+ MESG("Writing to %s: ", outname);
+ MESG("Bounding box: %d %d %d %d\n", bbllx, bblly, bburx, bbury);
+ }
+ fprintf(fp, "%%%%Title: %s\n", fname);
+ fprintf(fp, "%%%%Creator: %s %s\n", XBB_PROGRAM, XBB_VERSION);
+ fprintf(fp, "%%%%BoundingBox: %d %d %d %d\n", bbllx, bblly, bburx, bbury);
+ do_time(fp);
+ RELEASE(outname);
+ MFCLOSE(fp);
+}
+
+static int rect_equal (pdf_obj *rect1, pdf_obj *rect2)
+{
+ int i;
+ if (!rect1 || !rect2) return 0;
+ for (i = 0; i < 4; i++) {
+ if (pdf_number_value(pdf_get_array(rect1, i)) != pdf_number_value(pdf_get_array(rect2, i))) return 0;
+ }
+ return 1;
+}
+
+static int pdf_get_info (FILE *image_file, char *filename, int *llx, int *lly, int *urx, int *ury)
+{
+ pdf_obj *page_tree;
+ pdf_obj *bbox;
+ pdf_file *pf;
+
+ page_tree = NULL;
+ {
+ pdf_obj *trailer, *catalog;
+
+ pf = pdf_open(filename, image_file);
+ if (!pf)
+ return -1;
+
+ trailer = pdf_file_get_trailer(pf);
+
+ if (pdf_lookup_dict(trailer, "Encrypt")) {
+ WARN("This PDF document is encrypted.");
+ pdf_release_obj(trailer);
+ pdf_close(pf);
+ return -1;
+ }
+ catalog = pdf_deref_obj(pdf_lookup_dict(trailer, "Root"));
+ if (!catalog) {
+ WARN("Catalog isn't where I expect it.");
+ pdf_close(pf);
+ return -1;
+ }
+ pdf_release_obj(trailer);
+ page_tree = pdf_deref_obj(pdf_lookup_dict(catalog, "Pages"));
+ pdf_release_obj(catalog);
+ }
+ if (!page_tree) {
+ WARN("Page tree not found.");
+ pdf_close(pf);
+ return -1;
+ }
+ {
+ pdf_obj *kids_ref, *kids;
+ pdf_obj *crop_box;
+ pdf_obj *tmp;
+
+ tmp = pdf_lookup_dict(page_tree, "MediaBox");
+ bbox = tmp ? pdf_deref_obj(tmp) : NULL;
+ tmp = pdf_lookup_dict(page_tree, "CropBox");
+ crop_box = tmp ? pdf_deref_obj(tmp) : NULL;
+
+ while ((kids_ref = pdf_lookup_dict(page_tree, "Kids")) != NULL) {
+ kids = pdf_deref_obj(kids_ref);
+ pdf_release_obj(page_tree);
+ page_tree = pdf_deref_obj(pdf_get_array(kids, 0));
+ pdf_release_obj(kids);
+
+ if ((tmp = pdf_deref_obj(pdf_lookup_dict(page_tree, "MediaBox")))) {
+ if (bbox)
+ pdf_release_obj(bbox);
+ bbox = tmp;
+ }
+ if ((tmp = pdf_deref_obj(pdf_lookup_dict(page_tree, "BleedBox")))) {
+ if (!rect_equal(tmp, bbox)) {
+ if (bbox)
+ pdf_release_obj(bbox);
+ bbox = tmp;
+ } else
+ pdf_release_obj(tmp);
+ }
+ if ((tmp = pdf_deref_obj(pdf_lookup_dict(page_tree, "TrimBox")))) {
+ if (!rect_equal(tmp, bbox)) {
+ if (bbox)
+ pdf_release_obj(bbox);
+ bbox = tmp;
+ } else
+ pdf_release_obj(tmp);
+ }
+ if ((tmp = pdf_deref_obj(pdf_lookup_dict(page_tree, "ArtBox")))) {
+ if (!rect_equal(tmp, bbox)) {
+ if (bbox)
+ pdf_release_obj(bbox);
+ bbox = tmp;
+ } else
+ pdf_release_obj(tmp);
+ }
+ if ((tmp = pdf_deref_obj(pdf_lookup_dict(page_tree, "CropBox")))) {
+ if (crop_box)
+ pdf_release_obj(crop_box);
+ crop_box = tmp;
+ }
+ }
+ if (crop_box) {
+ pdf_release_obj(bbox);
+ bbox = crop_box;
+ }
+ }
+ pdf_release_obj(page_tree);
+
+ if (!bbox) {
+ WARN("No BoundingBox information available.");
+ pdf_close(pf);
+ return -1;
+ }
+
+ *llx = (int)pdf_number_value(pdf_get_array(bbox, 0));
+ *lly = (int)pdf_number_value(pdf_get_array(bbox, 1));
+ *urx = (int)pdf_number_value(pdf_get_array(bbox, 2));
+ *ury = (int)pdf_number_value(pdf_get_array(bbox, 3));
+
+ pdf_release_obj(bbox);
+
+ pdf_close(pf);
+ return 0;
+}
+
+static void do_pdf (FILE *fp, char *filename)
+{
+ int llx, lly, urx, ury;
+
+ if (pdf_get_info(fp, filename, &llx, &lly, &urx, &ury) < 0) {
+ fprintf (stderr, "%s does not look like a PDF file...\n", filename);
+ return;
+ }
+ write_xbb_old(filename, llx, lly, urx, ury);
+ return;
+}
+#else
static void do_pdf (FILE *fp, char *filename)
{
pdf_obj *page;
@@ -242,17 +397,14 @@ static void do_pdf (FILE *fp, char *filename)
write_xbb(filename, bbox.llx, bbox.lly, bbox.urx, bbox.ury,
pdf_file_get_version(pf), count);
}
+#endif
-int extractbb (int argc, char *argv[], int mode)
+int extractbb (int argc, char *argv[])
{
- compat_mode = (mode == EBB_OUTPUT);
-
pdf_files_init();
pdf_set_version(5);
- kpse_set_program_name(argv[0], NULL);
-
argc -= 1; argv += 1;
if (argc == 0)
usage();
diff --git a/Build/source/texk/dvipdfm-x/tests/dvipdfmx.cfg b/Build/source/texk/dvipdfm-x/tests/dvipdfmx.cfg
new file mode 100644
index 00000000000..e7efa05ad0c
--- /dev/null
+++ b/Build/source/texk/dvipdfm-x/tests/dvipdfmx.cfg
@@ -0,0 +1,222 @@
+%% dvipdfmx.cfg for dvipdfmx and xdvipdfmx. (Public domain.)
+%%
+%% PDF Version Setting
+%%
+%% PDF (minor) version stamp to use in output file.
+%% This also implies maximal version of PDF file allowed to be included.
+%% Dvipdfmx does not support 1.0, 1.1, 1.2 since TrueType font embedded
+%% as CIDFontType2 requires at least version 1.3. Transparent imaging
+%% model requires version 1.4. So if you want soft-masking support for
+%% PNG image with alpha channels, you should set version to 4 or higher.
+%% PDF 1.5 enables object compression.
+
+V 5
+
+%% Dvipdfmx Compatibility Flags
+%%
+%% 0x0002 Use semi-transparent filling for tpic shading command,
+%% instead of opaque gray color. (requires PDF 1.4)
+%% 0x0004 Treat all CIDFont as fixed-pitch font.
+%% This is only for backward compatibility. Don't use that.
+%% 0x0008 Do not replace duplicate fontmap entries.
+%% Dvipdfm's (not 'x') behaviour.
+%% 0x0010 Do not optimize PDF destinations. Use this if you want to
+%% refer from other files to destinations in the current file.
+
+%C 0x0000
+
+%% PDF Document Settings
+%%
+%% Papersize Option:
+%%
+%% p papersize-spec
+%%
+%% papersize-spec is 'paper-format' or length-pair, e.g., 'a4', 'letter',
+%% '20cm,30cm'. Recognized unit is 'cm', 'mm', 'bp', 'pt', 'in'.
+
+p a4
+
+%% Annotation Box Margin:
+%%
+%% g length
+%%
+%% Add margin to annotation rectangle created via various \specials. Many
+%% TeX macro packages set the annotation bounding box equal to the TeX box
+%% that encloses the material. That's not always what you want.
+%% Annotations created by pdf:bannot/pdf:eannot is also affected.
+
+%g 0
+
+%% Bookmark Open Level:
+%%
+%% O integer
+%%
+%% Mark bookmark (outline) item as initial state 'open' if the depth
+%% of that item (from root node) is less than or equal to the integer
+%% specified with this option.
+
+O 0
+
+%% PDF Security (Encryption) Setting
+%%
+%% Those options won't take effects unless you use flag 'S'.
+%%
+%% Key bits for PDF encryption (40 - 128)
+
+K 40
+
+%% Permission flag for PDF encryption: Revision will be 3 if the key size
+%% is greater than 40 bits.
+%%
+%% 0x0004 (Revision 2) Print the document.
+%% (Revision 3) Print the document (possibly not at the highest quality
+%% level, depending on whether bit 12[0x0800] is also set).
+%% 0x0008 Modify the contents of the document by operations other than those
+%% controlled by bits 6[0x0020], 9[0x0100], and 11[0x0400].
+%% 0x0010 (Revision 2) Copy or otherwise extract text and graphics from the
+%% document, including extracting text and graphics (in support of
+%% accessibility to disabled users or for other purposes).
+%% (Revision 3) Copy or otherwise extract text and grphics from the
+%% document by operations other than that controlled by bit 10[0x0200].
+%% 0x0020 Add or modify text annotations, fill in interactive form fields,
+%% and, if bit 4[0x0008] is also set, create or modify interactive
+%% form fields (including signature fields).
+%%
+%% (Revision 3 only)
+%% 0x0100 Fill in existing interactive form fields (including signature
+%% fields), even if bit 6 is clear.
+%% 0x0200 Extract text and graphics (in support of accessibility to disabled
+%% users or for other purposes).
+%% 0x0400 Assemble the document (insert, rotate, or delete pages and create
+%% bookmarks or thumbnail images), even if bit 4 is clear.
+%% 0x0800 Print the document to a representation from which a faithful digital
+%% copy of the PDF content could be generated. When this bit is clear
+%% (and bit 3 is set), printing is limited to a low-level representation
+%% of the appearance, possibly of degraded quality.
+
+P 0x003C
+
+%% Image Handler
+%%
+%% With 'D' option dvipdfmx may invoke shell command via system()
+%% function call.
+%%
+%% Command-line template for a-to-b conversion:
+%%
+%% Supported target format ('b') is currently PDF.
+%% Percent sign '%' is special character:
+%%
+%% %i Input file name (FQPN). Name of file to be converted to PDF.
+%% %o Output file name (FQPN). Temporary file to store conversion
+%% result. Removed after inclusion is finished. (regardless of
+%% success or failure)
+%% %b The "base" name of the input file, e.g., "foo" instead of
+%% "foo.eps".
+%% %v The PDF version to be converted to, e.g. "1.4" for PDF 1.4.
+%% %% Replaced with single '%'.
+
+%% Ghostscript (PS-to-PDF and PDF-to-PDF):
+%%
+%% ps2pdf is a front-end to gs. For a complete list of options, see
+%% http://ghostscript.com/doc/current/Ps2pdf.htm#Options
+%%
+%% By default, gs encodes all images contained in a PS file using
+%% the lossy DCT (i.e., JPEG) filter. This often leads to inferior
+%% result (see the discussion at http://electron.mit.edu/~gsteele/pdf/).
+%% The "-dAutoFilterXXXImages" and "-dXXXImageFilter" options used
+%% below force all images to be encoded with the lossless Flate (zlib,
+%% same as PNG) filter. Note that if the PS file already contains DCT
+%% encoded images (which is possible in PS level 2), then these images
+%% will also be re-encoded using Flate. To turn the conversion off,
+%% simply remove the options mentioned above.
+%%
+%% The -dEPSCROP below converts PS files. Before TL 2013,
+%% -sPAPERSIZE=a0 was used for this. In 2013, changes were made to
+%% xetex.def, dvipdfmx.def, etc., to handle non-zero llx/lly.
+%%
+%% In TeX Live, we use the rungs wrapper instead of ps2pdf, becuse we
+%% must omit the -dSAFER which ps2pdf specifies: in order for pstricks
+%% to work with xetex,
+%% /usr/local/texlive/*/texmf-dist/dvips/pstricks/pstricks.pro (for
+%% example) needs to be accessed. (Also, it is better to use our
+%% supplied gs on Windows.) You can also add -dNOSAFER to the ps2pdf
+%% command line.
+%%
+%% Incidentally, especially in TL, more than one dvipdfmx.cfg may be
+%% extant. You can find the one that is active by running:
+%% kpsewhich -progname=dvipdfmx -format='other text files' dvipdfmx.cfg
+%% and control which one is found by setting DVIPDFMXINPUTS.
+%%
+D "rungs -q -dNOPAUSE -dBATCH -dEPSCrop -sDEVICE=pdfwrite -dCompatibilityLevel=%v -dAutoFilterGrayImages=false -dGrayImageFilter=/FlateEncode -dAutoFilterColorImages=false -dColorImageFilter=/FlateEncode -sOutputFile='%o' '%i' -c quit"
+
+% pre-2013 invocation using -sPAPERSIZE instead of -dEPSCrop, no other changes:
+%D "rungs -q -dNOPAUSE -dBATCH -sPAPERSIZE=a0 -sDEVICE=pdfwrite -dCompatibilityLevel=%v -dAutoFilterGrayImages=false -dGrayImageFilter=/FlateEncode -dAutoFilterColorImages=false -dColorImageFilter=/FlateEncode -sOutputFile='%o' '%i' -c quit"
+
+% other random ps converters people have experimented with.
+%D "/usr/local/bin/ps2pdf -dEPSCrop '%i' '%o'"
+%D "/usr/texbin/epstopdf '%i' -o '%o'"
+%D "/usr/bin/pstopdf '%i' -o '%o'"
+%
+%% Frank Siegert's PStill:
+%D "/usr/local/bin/pstill -c -o '%o' '%i'"
+%
+%% Batik + Fop (SVG-to-PDF):
+%% If you want both PS and SVG, you need to write a script or program
+%% that selectively invokes converters.
+%D "java -classpath classpaths -jar /path/to/batik-rasterizer.jar -m application/pdf -d '%o' '%i'"
+%
+%% There are no way to directly know suggested size of (raster) images.
+%% You may want to use %b here, since you can try reading the ebb file
+%% to see what is natural (physical) size of images.
+%D "ras2pdf -r 300x300 -b '%b.bb' -o '%o' '%i'"
+%
+%% ImageMagick:
+%% Easiest way to support various file formats.
+%D "convert '%i' 'epdf:%o'"
+
+%% Other Options
+%%
+%% DPI for PK font creation
+
+%r 600
+
+%% Set number of fractional digit kept for various numbers in PDF page
+%% content output. By setting this to 2 (default), dvipdfmx rounds
+%% real numbers at 2nd fractional (decimal) digit; e.g., "3.14159" is
+%% written as "3.14". Increasing this to more than 2 isn't meaningful
+%% for old Acrobat due to implementation limit of Acrobat.
+%% Length 0.01 in unscaled coordinate system amount to width of 1 pixel
+%% in 7200ppi display.
+
+%d 5
+
+%% Image cache life in hours
+%% 0 means erase all old images and leave new images
+%% -1 means erase all old images and also erase new images
+%% -2 means ignore image cache
+%I -2
+
+%% Font Map Files
+%%
+%% teTeX 2.x and TeX Live using updmap (pdfTeX format)
+%f pdftex.map
+
+%% teTeX 2.x and TeX Live using updmap (DVIPDFM format)
+%f dvipdfm.map
+
+%% teTeX 2.x and TeX Live using updmap (DVIPS format)
+%% MiKTeX 2.2 and 2.3
+%f psfonts.map
+
+%% Put additional fontmap files here (usually for Type0 fonts)
+f cid-x.map
+
+% the following file is generated by updmap(-sys) from the
+% KanjiMap entries in the updmap.cfg file.
+%f kanjix.map
+% minimal example for Chinese and Korean users
+% improvements please to tex-live@tug.org
+%f ckx.map
+
+%% Include other config files
+%i <filename>
diff --git a/Build/source/texk/dvipdfm-x/tests/image.jpeg b/Build/source/texk/dvipdfm-x/tests/image.jpeg
new file mode 100644
index 00000000000..5312aab5fc4
--- /dev/null
+++ b/Build/source/texk/dvipdfm-x/tests/image.jpeg
Binary files differ
diff --git a/Build/source/texk/dvipdfm-x/tests/image.pdf b/Build/source/texk/dvipdfm-x/tests/image.pdf
new file mode 100644
index 00000000000..12c4576b56f
--- /dev/null
+++ b/Build/source/texk/dvipdfm-x/tests/image.pdf
Binary files differ
diff --git a/Build/source/texk/dvipdfm-x/tests/image.png b/Build/source/texk/dvipdfm-x/tests/image.png
new file mode 100644
index 00000000000..9b225237c0f
--- /dev/null
+++ b/Build/source/texk/dvipdfm-x/tests/image.png
Binary files differ
diff --git a/Build/source/texk/dvipdfm-x/tests/imgjpeg.bb b/Build/source/texk/dvipdfm-x/tests/imgjpeg.bb
new file mode 100644
index 00000000000..51173a963cb
--- /dev/null
+++ b/Build/source/texk/dvipdfm-x/tests/imgjpeg.bb
@@ -0,0 +1,4 @@
+%%Title: ./imgjpeg.jpeg
+%%Creator: extractbb 20130624
+%%BoundingBox: 0 0 108 148
+
diff --git a/Build/source/texk/dvipdfm-x/tests/imgjpeg.xbb b/Build/source/texk/dvipdfm-x/tests/imgjpeg.xbb
new file mode 100644
index 00000000000..8c3a8eecb95
--- /dev/null
+++ b/Build/source/texk/dvipdfm-x/tests/imgjpeg.xbb
@@ -0,0 +1,5 @@
+%%Title: ./imgjpeg.jpeg
+%%Creator: extractbb 20130624
+%%BoundingBox: 0 0 150 205
+%%HiResBoundingBox: 0.000000 0.000000 150.000000 205.000000
+
diff --git a/Build/source/texk/dvipdfm-x/tests/imgpdf.bb b/Build/source/texk/dvipdfm-x/tests/imgpdf.bb
new file mode 100644
index 00000000000..e0c81b1db89
--- /dev/null
+++ b/Build/source/texk/dvipdfm-x/tests/imgpdf.bb
@@ -0,0 +1,4 @@
+%%Title: ./imgpdf.pdf
+%%Creator: extractbb 20130624
+%%BoundingBox: 0 0 69 83
+
diff --git a/Build/source/texk/dvipdfm-x/tests/imgpdf.xbb b/Build/source/texk/dvipdfm-x/tests/imgpdf.xbb
new file mode 100644
index 00000000000..315c951f1e4
--- /dev/null
+++ b/Build/source/texk/dvipdfm-x/tests/imgpdf.xbb
@@ -0,0 +1,7 @@
+%%Title: ./imgpdf.pdf
+%%Creator: extractbb 20130624
+%%BoundingBox: 0 0 69 83
+%%HiResBoundingBox: 0.000000 0.000000 69.000000 83.000000
+%%PDFVersion: 1.4
+%%Pages: 1
+
diff --git a/Build/source/texk/dvipdfm-x/tests/imgpng.bb b/Build/source/texk/dvipdfm-x/tests/imgpng.bb
new file mode 100644
index 00000000000..a5835d0a584
--- /dev/null
+++ b/Build/source/texk/dvipdfm-x/tests/imgpng.bb
@@ -0,0 +1,4 @@
+%%Title: ./imgpng.png
+%%Creator: extractbb 20130624
+%%BoundingBox: 0 0 124 89
+
diff --git a/Build/source/texk/dvipdfm-x/tests/imgpng.xbb b/Build/source/texk/dvipdfm-x/tests/imgpng.xbb
new file mode 100644
index 00000000000..d8c6fd2a9e6
--- /dev/null
+++ b/Build/source/texk/dvipdfm-x/tests/imgpng.xbb
@@ -0,0 +1,5 @@
+%%Title: ./imgpng.png
+%%Creator: extractbb 20130624
+%%BoundingBox: 0 0 172 124
+%%HiResBoundingBox: 0.000000 0.000000 172.000000 124.000000
+
diff --git a/Build/source/texk/dvipdfm-x/tests/picjpeg.bb b/Build/source/texk/dvipdfm-x/tests/picjpeg.bb
new file mode 100644
index 00000000000..c748c0836c6
--- /dev/null
+++ b/Build/source/texk/dvipdfm-x/tests/picjpeg.bb
@@ -0,0 +1,4 @@
+%%Title: ./picjpeg.jpeg
+%%Creator: extractbb 20130624
+%%BoundingBox: 0 0 108 148
+
diff --git a/Build/source/texk/dvipdfm-x/tests/picjpeg.xbb b/Build/source/texk/dvipdfm-x/tests/picjpeg.xbb
new file mode 100644
index 00000000000..5392815c903
--- /dev/null
+++ b/Build/source/texk/dvipdfm-x/tests/picjpeg.xbb
@@ -0,0 +1,5 @@
+%%Title: ./picjpeg.jpeg
+%%Creator: extractbb 20130624
+%%BoundingBox: 0 0 150 205
+%%HiResBoundingBox: 0.000000 0.000000 150.000000 205.000000
+
diff --git a/Build/source/texk/dvipdfm-x/tests/picpdf.bb b/Build/source/texk/dvipdfm-x/tests/picpdf.bb
new file mode 100644
index 00000000000..8e1f0aca12b
--- /dev/null
+++ b/Build/source/texk/dvipdfm-x/tests/picpdf.bb
@@ -0,0 +1,4 @@
+%%Title: ./picpdf.pdf
+%%Creator: extractbb 20130624
+%%BoundingBox: 0 0 69 83
+
diff --git a/Build/source/texk/dvipdfm-x/tests/picpdf.xbb b/Build/source/texk/dvipdfm-x/tests/picpdf.xbb
new file mode 100644
index 00000000000..8e1f0aca12b
--- /dev/null
+++ b/Build/source/texk/dvipdfm-x/tests/picpdf.xbb
@@ -0,0 +1,4 @@
+%%Title: ./picpdf.pdf
+%%Creator: extractbb 20130624
+%%BoundingBox: 0 0 69 83
+
diff --git a/Build/source/texk/dvipdfm-x/tests/picpng.bb b/Build/source/texk/dvipdfm-x/tests/picpng.bb
new file mode 100644
index 00000000000..2a3c7a51e7f
--- /dev/null
+++ b/Build/source/texk/dvipdfm-x/tests/picpng.bb
@@ -0,0 +1,4 @@
+%%Title: ./picpng.png
+%%Creator: extractbb 20130624
+%%BoundingBox: 0 0 124 89
+
diff --git a/Build/source/texk/dvipdfm-x/tests/picpng.xbb b/Build/source/texk/dvipdfm-x/tests/picpng.xbb
new file mode 100644
index 00000000000..d5f995b154b
--- /dev/null
+++ b/Build/source/texk/dvipdfm-x/tests/picpng.xbb
@@ -0,0 +1,5 @@
+%%Title: ./picpng.png
+%%Creator: extractbb 20130624
+%%BoundingBox: 0 0 172 124
+%%HiResBoundingBox: 0.000000 0.000000 172.000000 124.000000
+
diff --git a/Build/source/texk/dvipdfm-x/xbb.h b/Build/source/texk/dvipdfm-x/xbb.h
deleted file mode 100644
index 5c8e25c1fd8..00000000000
--- a/Build/source/texk/dvipdfm-x/xbb.h
+++ /dev/null
@@ -1,31 +0,0 @@
-/*
-
- This is dvipdfmx, an eXtended version of dvipdfm by Mark A. Wicks.
-
- Copyright (C) 2008-2012 by Jin-Hwan Cho, Matthias Franz, and Shunsaku Hirata,
- the dvipdfmx project team.
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 2 of the License, or
- (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
-*/
-
-#ifndef _XBB_H_
-#define _XBB_H_
-
-#define EBB_OUTPUT 0
-#define XBB_OUTPUT 1
-
-extern int extractbb(int argc, char *argv[], int mode);
-
-#endif /* _XBB_H_ */
diff --git a/Build/source/texk/dvipdfm-x/xdvipdfm-bb.test b/Build/source/texk/dvipdfm-x/xdvipdfm-bb.test
new file mode 100755
index 00000000000..0914438d58f
--- /dev/null
+++ b/Build/source/texk/dvipdfm-x/xdvipdfm-bb.test
@@ -0,0 +1,47 @@
+#! /bin/sh
+
+# Copyright (C) 2013 Peter Breitenlohner <tex-live@tug.org>
+# You may freely use, modify and/or distribute this file.
+
+TEXMFCNF=${srcdir}/../kpathsea
+DVIPDFMXINPUTS=${srcdir}/tests:${srcdir}/data
+export TEXMFCNF DVIPDFMXINPUTS
+
+testsrc=$srcdir/tests
+
+failed=
+
+rm -f pic*.*
+
+for e in jpeg png pdf; do
+ cp $testsrc/image.$e pic$e.$e
+done
+
+./xdvipdfmx --ebb -h \
+ && echo "ebb-help tests OK" \
+ || failed="$failed ebb-help"
+
+for e in jpeg png pdf; do
+ ./xdvipdfmx --ebb pic$e.$e \
+ && sed '/%%CreationDate/d' pic$e.bb >pic$e.bbx \
+ && diff $testsrc/pic$e.bb pic$e.bbx \
+ && echo "ebb-$e tests OK" \
+ || failed="$failed ebb-$e"
+done
+
+./xdvipdfmx --xbb -h \
+ && echo "xbb-help tests OK" \
+ || failed="$failed xbb-help"
+
+for e in jpeg png pdf; do
+ ./xdvipdfmx --xbb pic$e.$e \
+ && sed '/%%CreationDate/d' pic$e.xbb >pic$e.xbbx \
+ && diff $testsrc/pic$e.xbb pic$e.xbbx \
+ && echo "xbb-$e tests OK" \
+ || failed="$failed xbb-$e"
+done
+
+test -z "$failed" && exit 0
+echo "failed tests:$failed"
+exit 1
+
diff --git a/Build/source/texk/dvipdfm-x/xdvipdfmx.test b/Build/source/texk/dvipdfm-x/xdvipdfmx.test
index bbe4876d246..d564977c2b4 100755
--- a/Build/source/texk/dvipdfm-x/xdvipdfmx.test
+++ b/Build/source/texk/dvipdfm-x/xdvipdfmx.test
@@ -5,7 +5,7 @@
# Not really a test, just making sure the program executes.
-TEXMFCNF=${srcdir}/../../kpathsea \
- DVIPDFMXINPUTS=${srcdir}/../data \
+TEXMFCNF=${srcdir}/../kpathsea \
+ DVIPDFMXINPUTS=${srcdir}/tests:${srcdir}/data \
./xdvipdfmx -h || exit 1
diff --git a/Build/source/texk/dvipdfm-x/xsrc/dvipdfmx.c b/Build/source/texk/dvipdfm-x/xsrc/dvipdfmx.c
index 61a81057cc6..255bfecb79c 100644
--- a/Build/source/texk/dvipdfm-x/xsrc/dvipdfmx.c
+++ b/Build/source/texk/dvipdfm-x/xsrc/dvipdfmx.c
@@ -61,7 +61,6 @@
#include "cid.h"
#include "dvipdfmx.h"
-#include "xbb.h"
#include "error.h"
@@ -851,15 +850,7 @@ int CDECL
main (int argc, char *argv[])
{
double dvi2pts;
-
- char *base = kpse_program_basename (argv[0]);
-
- if (FILESTRCASEEQ (base, "extractbb") || FILESTRCASEEQ (base, "xbb"))
- return extractbb (argc, argv, XBB_OUTPUT);
- if (FILESTRCASEEQ (base, "ebb"))
- return extractbb (argc, argv, EBB_OUTPUT);
-
- free (base);
+ char *base;
#ifdef MIKTEX
miktex_initialize();
@@ -870,6 +861,31 @@ main (int argc, char *argv[])
#endif
#endif
+ if (argc > 1 &&
+ (STREQ (argv[1], "--xbb") ||
+#ifndef XETEX
+ STREQ (argv[1], "--dvipdfm") ||
+#endif
+ STREQ (argv[1], "--ebb"))) {
+ argc--;
+ base = argv++[1]+2;
+ } else
+ base = kpse_program_basename (argv[0]);
+
+ if (FILESTRCASEEQ (base, "extractbb") || FILESTRCASEEQ (base, "xbb"))
+ return extractbb (argc, argv);
+ if (FILESTRCASEEQ (base, "ebb")) {
+ compat_mode = 1;
+ return extractbb (argc, argv);
+ }
+
+#ifndef XETEX
+ if (FILESTRCASEEQ (base, "dvipdfm"))
+ compat_mode = 1;
+ else
+#endif
+ free (base);
+
paperinit();
system_default();
diff --git a/Build/source/texk/dvipdfm-x/xsrc/epdf.c b/Build/source/texk/dvipdfm-x/xsrc/epdf.c
index cef72ee0c39..58a8c527e04 100644
--- a/Build/source/texk/dvipdfm-x/xsrc/epdf.c
+++ b/Build/source/texk/dvipdfm-x/xsrc/epdf.c
@@ -469,30 +469,32 @@ pdf_include_page (pdf_ximage *ximage, FILE *image_file, const char *filename)
pdf_close(pf);
- contents_dict = pdf_stream_dict(contents);
- pdf_add_dict(contents_dict,
- pdf_new_name("Type"),
- pdf_new_name("XObject"));
- pdf_add_dict(contents_dict,
- pdf_new_name("Subtype"),
- pdf_new_name("Form"));
- pdf_add_dict(contents_dict,
- pdf_new_name("FormType"),
- pdf_new_number(1.0));
-
- pdf_add_dict(contents_dict, pdf_new_name("BBox"), bbox);
-
- matrix = pdf_new_array();
- pdf_add_array(matrix, pdf_new_number(1.0));
- pdf_add_array(matrix, pdf_new_number(0.0));
- pdf_add_array(matrix, pdf_new_number(0.0));
- pdf_add_array(matrix, pdf_new_number(1.0));
- pdf_add_array(matrix, pdf_new_number(0.0));
- pdf_add_array(matrix, pdf_new_number(0.0));
-
- pdf_add_dict(contents_dict, pdf_new_name("Matrix"), matrix);
-
- pdf_add_dict(contents_dict, pdf_new_name("Resources"), resources);
+ {
+ contents_dict = pdf_stream_dict(contents);
+ pdf_add_dict(contents_dict,
+ pdf_new_name("Type"),
+ pdf_new_name("XObject"));
+ pdf_add_dict(contents_dict,
+ pdf_new_name("Subtype"),
+ pdf_new_name("Form"));
+ pdf_add_dict(contents_dict,
+ pdf_new_name("FormType"),
+ pdf_new_number(1.0));
+
+ pdf_add_dict(contents_dict, pdf_new_name("BBox"), bbox);
+
+ matrix = pdf_new_array();
+ pdf_add_array(matrix, pdf_new_number(1.0));
+ pdf_add_array(matrix, pdf_new_number(0.0));
+ pdf_add_array(matrix, pdf_new_number(0.0));
+ pdf_add_array(matrix, pdf_new_number(1.0));
+ pdf_add_array(matrix, pdf_new_number(0.0));
+ pdf_add_array(matrix, pdf_new_number(0.0));
+
+ pdf_add_dict(contents_dict, pdf_new_name("Matrix"), matrix);
+
+ pdf_add_dict(contents_dict, pdf_new_name("Resources"), resources);
+ }
pdf_ximage_set_form(ximage, &info, contents);
diff --git a/Build/source/texk/dvipdfm-x/xsrc/jpegimage.c b/Build/source/texk/dvipdfm-x/xsrc/jpegimage.c
index f5f69685a66..7fcdad5fa73 100644
--- a/Build/source/texk/dvipdfm-x/xsrc/jpegimage.c
+++ b/Build/source/texk/dvipdfm-x/xsrc/jpegimage.c
@@ -61,6 +61,8 @@
#include "mfileio.h"
#include "numbers.h"
+#include "dvipdfmx.h"
+
#include "pdfobj.h"
#include "jpegimage.h"
@@ -198,6 +200,8 @@ static int JPEG_copy_stream (struct JPEG_info *j_info,
static void JPEG_info_init (struct JPEG_info *j_info);
static void JPEG_info_clear (struct JPEG_info *j_info);
static pdf_obj *JPEG_get_iccp (struct JPEG_info *j_info);
+static void jpeg_get_density (struct JPEG_info *j_info,
+ double *xdensity, double *ydensity);
int
check_for_jpeg (FILE *fp)
@@ -372,6 +376,46 @@ jpeg_include_image (pdf_ximage *ximage, FILE *fp)
return 0;
}
+#undef IS_JFIF
+#define IS_JFIF(j) ((j)->flags & HAVE_APPn_JFIF)
+
+static void
+jpeg_get_density (struct JPEG_info *j_info,
+ double *xdensity, double *ydensity)
+{
+ if (compat_mode) {
+ *xdensity = *ydensity = 72.0 / 100.0;
+ return;
+ }
+
+ *xdensity = *ydensity = 1.0;
+
+ if (IS_JFIF(j_info)) {
+ struct JPEG_APPn_JFIF *app_data;
+ int i;
+ for (i = 0; i < j_info->num_appn; i++) {
+ if (j_info->appn[i].marker == JM_APP0 ||
+ j_info->appn[i].app_sig == JS_APPn_JFIF)
+ break;
+ }
+ if (i < j_info->num_appn) {
+ app_data = (struct JPEG_APPn_JFIF *)j_info->appn[i].app_data;
+ switch (app_data->units) {
+ case 1: /* pixels per inch */
+ *xdensity = 72.0 / app_data->Xdensity;
+ *ydensity = 72.0 / app_data->Ydensity;
+ break;
+ case 2: /* pixels per centimeter */
+ *xdensity = 72.0 / 2.54 / app_data->Xdensity;
+ *ydensity = 72.0 / 2.54 / app_data->Ydensity;
+ break;
+ default:
+ break;
+ }
+ }
+ }
+}
+
static void
JPEG_info_init (struct JPEG_info *j_info)
{
@@ -913,3 +957,27 @@ JPEG_scan_file (struct JPEG_info *j_info, FILE *fp)
return (found_SOFn ? 0 : -1);
}
+
+int
+jpeg_get_bbox (FILE *fp, long *width, long *height,
+ double *xdensity, double *ydensity)
+{
+ struct JPEG_info j_info;
+
+ JPEG_info_init(&j_info);
+
+ if (JPEG_scan_file(&j_info, fp) < 0) {
+ WARN("%s: Not a JPEG file?", JPEG_DEBUG_STR);
+ JPEG_info_clear(&j_info);
+ return -1;
+ }
+
+ *width = j_info.width;
+ *height = j_info.height;
+
+ jpeg_get_density(&j_info, xdensity, ydensity);
+
+ JPEG_info_clear(&j_info);
+
+ return 0;
+}
diff --git a/Build/source/texk/dvipdfm-x/xsrc/pdfdoc.c b/Build/source/texk/dvipdfm-x/xsrc/pdfdoc.c
index 6dc06135ade..539ad1ab763 100644
--- a/Build/source/texk/dvipdfm-x/xsrc/pdfdoc.c
+++ b/Build/source/texk/dvipdfm-x/xsrc/pdfdoc.c
@@ -872,6 +872,242 @@ pdf_doc_close_page_tree (pdf_doc *p)
return;
}
+/*
+ * From PDFReference15_v6.pdf (p.119 and p.834)
+ *
+ * MediaBox rectangle (Required; inheritable)
+ *
+ * The media box defines the boundaries of the physical medium on which the
+ * page is to be printed. It may include any extended area surrounding the
+ * finished page for bleed, printing marks, or other such purposes. It may
+ * also include areas close to the edges of the medium that cannot be marked
+ * because of physical limitations of the output device. Content falling
+ * outside this boundary can safely be discarded without affecting the
+ * meaning of the PDF file.
+ *
+ * CropBox rectangle (Optional; inheritable)
+ *
+ * The crop box defines the region to which the contents of the page are to be
+ * clipped (cropped) when displayed or printed. Unlike the other boxes, the
+ * crop box has no defined meaning in terms of physical page geometry or
+ * intended use; it merely imposes clipping on the page contents. However,
+ * in the absence of additional information (such as imposition instructions
+ * specified in a JDF or PJTF job ticket), the crop box will determine how
+ * the page's contents are to be positioned on the output medium. The default
+ * value is the page's media box.
+ *
+ * BleedBox rectangle (Optional; PDF 1.3)
+ *
+ * The bleed box (PDF 1.3) defines the region to which the contents of the
+ * page should be clipped when output in a production environment. This may
+ * include any extra "bleed area" needed to accommodate the physical
+ * limitations of cutting, folding, and trimming equipment. The actual printed
+ * page may include printing marks that fall outside the bleed box.
+ * The default value is the page's crop box.
+ *
+ * TrimBox rectangle (Optional; PDF 1.3)
+ *
+ * The trim box (PDF 1.3) defines the intended dimensions of the finished page
+ * after trimming. It may be smaller than the media box, to allow for
+ * production-related content such as printing instructions, cut marks, or
+ * color bars. The default value is the page's crop box.
+ *
+ * ArtBox rectangle (Optional; PDF 1.3)
+ *
+ * The art box (PDF 1.3) defines the extent of the page's meaningful content
+ * (including potential white space) as intended by the page's creator.
+ * The default value is the page's crop box.
+ *
+ * Rotate integer (Optional; inheritable)
+ *
+ * The number of degrees by which the page should be rotated clockwise when
+ * displayed or printed. The value must be a multiple of 90. Default value: 0.
+ */
+
+pdf_obj *
+pdf_doc_get_page (pdf_file *pf, long page_no, long *count_p,
+ pdf_rect *bbox, pdf_obj **resources_p) {
+ pdf_obj *page_tree = NULL;
+ pdf_obj *resources = NULL, *box = NULL, *rotate = NULL;
+ pdf_obj *catalog;
+
+ catalog = pdf_file_get_catalog(pf);
+
+ page_tree = pdf_deref_obj(pdf_lookup_dict(catalog, "Pages"));
+
+ if (!PDF_OBJ_DICTTYPE(page_tree))
+ goto error;
+
+ {
+ long count;
+ pdf_obj *tmp = pdf_deref_obj(pdf_lookup_dict(page_tree, "Count"));
+ if (!PDF_OBJ_NUMBERTYPE(tmp)) {
+ if (tmp)
+ pdf_release_obj(tmp);
+ goto error;
+ }
+ count = pdf_number_value(tmp);
+ pdf_release_obj(tmp);
+ if (count_p)
+ *count_p = count;
+ if (page_no <= 0 || page_no > count) {
+ WARN("Page %ld does not exist.", page_no);
+ goto error_silent;
+ }
+ }
+
+ /*
+ * Seek correct page. Get MediaBox, CropBox and Resources.
+ * (Note that these entries can be inherited.)
+ */
+ {
+ pdf_obj *media_box = NULL, *crop_box = NULL, *kids, *tmp;
+ int depth = PDF_OBJ_MAX_DEPTH;
+ long page_idx = page_no-1, kids_length = 1, i = 0;
+
+ while (--depth && i != kids_length) {
+ if ((tmp = pdf_deref_obj(pdf_lookup_dict(page_tree, "MediaBox")))) {
+ if (media_box)
+ pdf_release_obj(media_box);
+ media_box = tmp;
+ }
+
+ if ((tmp = pdf_deref_obj(pdf_lookup_dict(page_tree, "CropBox")))) {
+ if (crop_box)
+ pdf_release_obj(crop_box);
+ crop_box = tmp;
+ }
+
+ if ((tmp = pdf_deref_obj(pdf_lookup_dict(page_tree, "Rotate")))) {
+ if (rotate)
+ pdf_release_obj(rotate);
+ rotate = tmp;
+ }
+
+ if ((tmp = pdf_deref_obj(pdf_lookup_dict(page_tree, "Resources")))) {
+ if (resources)
+ pdf_release_obj(resources);
+ resources = tmp;
+ }
+
+ kids = pdf_deref_obj(pdf_lookup_dict(page_tree, "Kids"));
+ if (!kids)
+ break;
+ else if (!PDF_OBJ_ARRAYTYPE(kids)) {
+ pdf_release_obj(kids);
+ goto error;
+ }
+ kids_length = pdf_array_length(kids);
+
+ for (i = 0; i < kids_length; i++) {
+ long count;
+
+ pdf_release_obj(page_tree);
+ page_tree = pdf_deref_obj(pdf_get_array(kids, i));
+ if (!PDF_OBJ_DICTTYPE(page_tree))
+ goto error;
+
+ tmp = pdf_deref_obj(pdf_lookup_dict(page_tree, "Count"));
+ if (PDF_OBJ_NUMBERTYPE(tmp)) {
+ /* Pages object */
+ count = pdf_number_value(tmp);
+ pdf_release_obj(tmp);
+ } else if (!tmp)
+ /* Page object */
+ count = 1;
+ else {
+ pdf_release_obj(tmp);
+ goto error;
+ }
+
+ if (page_idx < count)
+ break;
+
+ page_idx -= count;
+ }
+
+ pdf_release_obj(kids);
+ }
+
+ if (!depth || kids_length == i) {
+ if (media_box)
+ pdf_release_obj(media_box);
+ if (crop_box)
+ pdf_release_obj(crop_box);
+ goto error;
+ }
+
+ if (crop_box)
+ box = crop_box;
+ else
+ if (!(box = pdf_deref_obj(pdf_lookup_dict(page_tree, "ArtBox"))) &&
+ !(box = pdf_deref_obj(pdf_lookup_dict(page_tree, "TrimBox"))) &&
+ !(box = pdf_deref_obj(pdf_lookup_dict(page_tree, "BleedBox"))) &&
+ media_box) {
+ box = media_box;
+ media_box = NULL;
+ }
+ if (media_box)
+ pdf_release_obj(media_box);
+ }
+
+ if (!PDF_OBJ_ARRAYTYPE(box) || pdf_array_length(box) != 4 ||
+ !PDF_OBJ_DICTTYPE(resources))
+ goto error;
+
+ if (PDF_OBJ_NUMBERTYPE(rotate)) {
+ if (pdf_number_value(rotate))
+ WARN("<< /Rotate %d >> found. (Not supported yet)",
+ (int) pdf_number_value(rotate));
+ pdf_release_obj(rotate);
+ rotate = NULL;
+ } else if (rotate)
+ goto error;
+
+ {
+ int i;
+
+ for (i = 4; i--; ) {
+ double x;
+ pdf_obj *tmp = pdf_deref_obj(pdf_get_array(box, i));
+ if (!PDF_OBJ_NUMBERTYPE(tmp)) {
+ pdf_release_obj(tmp);
+ goto error;
+ }
+ x = pdf_number_value(tmp);
+ switch (i) {
+ case 0: bbox->llx = x; break;
+ case 1: bbox->lly = x; break;
+ case 2: bbox->urx = x; break;
+ case 3: bbox->ury = x; break;
+ }
+ pdf_release_obj(tmp);
+ }
+ }
+
+ pdf_release_obj(box);
+
+ if (resources_p)
+ *resources_p = resources;
+ else if (resources)
+ pdf_release_obj(resources);
+
+ return page_tree;
+
+ error:
+ WARN("Cannot parse document. Broken PDF file?");
+ error_silent:
+ if (box)
+ pdf_release_obj(box);
+ if (rotate)
+ pdf_release_obj(rotate);
+ if (resources)
+ pdf_release_obj(resources);
+ if (page_tree)
+ pdf_release_obj(page_tree);
+
+ return NULL;
+}
#ifndef BOOKMARKS_OPEN_DEFAULT
#define BOOKMARKS_OPEN_DEFAULT 0
diff --git a/Build/source/texk/dvipdfm-x/xsrc/pdfobj.c b/Build/source/texk/dvipdfm-x/xsrc/pdfobj.c
index 6416936e7c8..0861c46278a 100644
--- a/Build/source/texk/dvipdfm-x/xsrc/pdfobj.c
+++ b/Build/source/texk/dvipdfm-x/xsrc/pdfobj.c
@@ -161,6 +161,7 @@ struct pdf_file
FILE *file;
pdf_obj *trailer;
xref_entry *xref_table;
+ pdf_obj *catalog;
long num_obj;
long file_size;
int version;
@@ -588,14 +589,14 @@ void pdf_out_white (FILE *file)
ERROR("typecheck: Invalid object type: %d %d (line %d)", (o) ? (o)->type : -1, (t), __LINE__);\
}
-#define INVALIDOBJ(o) ((o) == NULL || (o)->type <= 0 || (o)->type > PDF_INDIRECT)
+#define INVALIDOBJ(o) ((o) == NULL || (o)->type <= 0 || (o)->type > PDF_UNDEFINED)
-pdf_obj *
+static pdf_obj *
pdf_new_obj(int type)
{
pdf_obj *result;
- if (type > PDF_INDIRECT || type < PDF_UNDEFINED)
+ if (type >= PDF_UNDEFINED || type < 0)
ERROR("Invalid object type: %d", type);
result = NEW(1, pdf_obj);
@@ -741,6 +742,7 @@ write_boolean (pdf_boolean *data, FILE *file)
}
}
+#ifdef XETEX
void
pdf_set_boolean (pdf_obj *object, char value)
{
@@ -751,6 +753,7 @@ pdf_set_boolean (pdf_obj *object, char value)
data = object->data;
data->value = value;
}
+#endif
char
pdf_boolean_value (pdf_obj *object)
@@ -1070,6 +1073,7 @@ release_name (pdf_name *data)
RELEASE(data);
}
+#ifdef XETEX
void
pdf_set_name (pdf_obj *object, const char *name)
{
@@ -1091,6 +1095,7 @@ pdf_set_name (pdf_obj *object, const char *name)
data->name = NULL;
}
}
+#endif
char *
pdf_name_value (pdf_obj *object)
@@ -1268,7 +1273,7 @@ pdf_shift_array (pdf_obj *array)
return result;
}
-#endif /* 0 */
+#endif
/* Prepend an object to an array */
void
@@ -1309,19 +1314,25 @@ pdf_pop_array (pdf_obj *array)
return result;
}
-#endif /* 0 */
+#endif
static void
write_dict (pdf_dict *dict, FILE *file)
{
+#ifdef XETEX
pdf_out (file, "<<\n", 3); /* dropping \n saves few kb. */
+#else
+ pdf_out (file, "<<", 2);
+#endif
while (dict->key != NULL) {
pdf_write_obj(dict->key, file);
if (pdf_need_white(PDF_NAME, (dict->value)->type)) {
pdf_out_white(file);
}
pdf_write_obj(dict->value, file);
+#ifdef XETEX
pdf_out_char (file, '\n'); /* removing this saves few kb. */
+#endif
dict = dict->next;
}
pdf_out(file, ">>", 2);
@@ -1442,7 +1453,7 @@ pdf_put_dict (pdf_obj *dict, const char *key, pdf_obj *value)
data->value = value;
}
}
-#endif /* 0 */
+#endif
/* pdf_merge_dict makes a link for each item in dict2 before stealing it */
void
@@ -1902,7 +1913,7 @@ pdf_stream_get_flags (pdf_obj *stream)
return data->_flags;
}
-#endif /* 0 */
+#endif
static void
pdf_write_obj (pdf_obj *object, FILE *file)
@@ -1912,7 +1923,7 @@ pdf_write_obj (pdf_obj *object, FILE *file)
return;
}
- if (INVALIDOBJ(object))
+ if (INVALIDOBJ(object) || PDF_OBJ_UNDEFINED(object))
ERROR("pdf_write_obj: Invalid object, type = %d\n", object->type);
if (file == stderr)
@@ -2580,7 +2591,7 @@ pdf_deref_obj (pdf_obj *obj)
if (!pf)
ERROR("Tried to deref a non-file object");
pdf_release_obj(obj);
- obj = pdf_get_object(pf, obj_num, obj_gen);
+ obj = pdf_get_object(pf, obj_num, obj_gen);
}
if (PDF_OBJ_NULLTYPE(obj)) {
@@ -2740,7 +2751,7 @@ parse_xrefstm_subsec (pdf_file *pf,
static int
parse_xref_stream (pdf_file *pf, long xref_pos, pdf_obj **trailer)
{
- pdf_obj *xrefstm, *size_obj, *W_obj, *index;
+ pdf_obj *xrefstm, *size_obj, *W_obj, *index_obj;
unsigned long size;
long length;
int W[3], i, wsum = 0;
@@ -2780,17 +2791,17 @@ parse_xref_stream (pdf_file *pf, long xref_pos, pdf_obj **trailer)
p = pdf_stream_dataptr(xrefstm);
- index = pdf_lookup_dict(*trailer, "Index");
- if (index) {
+ index_obj = pdf_lookup_dict(*trailer, "Index");
+ if (index_obj) {
unsigned int index_len;
- if (!PDF_OBJ_ARRAYTYPE(index) ||
- ((index_len = pdf_array_length(index)) % 2 ))
+ if (!PDF_OBJ_ARRAYTYPE(index_obj) ||
+ ((index_len = pdf_array_length(index_obj)) % 2 ))
goto error;
i = 0;
while (i < index_len) {
- pdf_obj *first = pdf_get_array(index, i++);
- size_obj = pdf_get_array(index, i++);
+ pdf_obj *first = pdf_get_array(index_obj, i++);
+ size_obj = pdf_get_array(index_obj, i++);
if (!PDF_OBJ_NUMBERTYPE(first) ||
!PDF_OBJ_NUMBERTYPE(size_obj) ||
parse_xrefstm_subsec(pf, &p, &length, W, wsum,
@@ -2904,6 +2915,7 @@ pdf_file_new (FILE *file)
pf->file = file;
pf->trailer = NULL;
pf->xref_table = NULL;
+ pf->catalog = NULL;
pf->num_obj = 0;
pf->version = 0;
@@ -2942,15 +2954,31 @@ pdf_files_init (void)
ht_init_table(pdf_files, (void (*)(void *)) pdf_file_free);
}
+int
+pdf_file_get_version (pdf_file *pf)
+{
+ ASSERT(pf);
+ return pf->version;
+}
+
+#ifdef XETEX
pdf_obj *
pdf_file_get_trailer (pdf_file *pf)
{
ASSERT(pf);
return pdf_link_obj(pf->trailer);
}
+#endif
+
+pdf_obj *
+pdf_file_get_catalog (pdf_file *pf)
+{
+ ASSERT(pf);
+ return pf->catalog;
+}
pdf_file *
-pdf_open (char *ident, FILE *file)
+pdf_open (const char *ident, FILE *file)
{
pdf_file *pf = NULL;
@@ -3146,25 +3174,17 @@ pdf_import_object (pdf_obj *object)
}
+/* returns 0 if indirect references point to the same object */
int
pdf_compare_reference (pdf_obj *ref1, pdf_obj *ref2)
{
pdf_indirect *data1, *data2;
- if (!PDF_OBJ_INDIRECTTYPE(ref1) ||
- !PDF_OBJ_INDIRECTTYPE(ref2)) {
- ERROR("Not indirect reference...");
- }
+ ASSERT(PDF_OBJ_INDIRECTTYPE(ref1) && PDF_OBJ_INDIRECTTYPE(ref2));
data1 = (pdf_indirect *) ref1->data;
data2 = (pdf_indirect *) ref2->data;
- if (data1->pf != data2->pf)
- return (int) (data1->pf - data2->pf);
- if (data1->label != data2->label)
- return (int) (data1->label - data2->label);
- if (data1->generation != data2->generation)
- return (int) (data1->generation - data2->generation);
-
- return 0;
+ return data1->pf != data2->pf || data1->label != data2->label
+ || data1->generation != data2->generation;
}
diff --git a/Build/source/texk/dvipdfm-x/xsrc/pdfobj.h b/Build/source/texk/dvipdfm-x/xsrc/pdfobj.h
deleted file mode 100644
index 036e9f53ef4..00000000000
--- a/Build/source/texk/dvipdfm-x/xsrc/pdfobj.h
+++ /dev/null
@@ -1,196 +0,0 @@
-/*
-
- This is dvipdfmx, an eXtended version of dvipdfm by Mark A. Wicks.
-
- Copyright (C) 2007-2012 by Jin-Hwan Cho and Shunsaku Hirata,
- the dvipdfmx project team.
-
- Copyright (C) 1998, 1999 by Mark A. Wicks <mwicks@kettering.edu>
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 2 of the License, or
- (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
-*/
-
-#ifndef _PDFOBJ_H_
-#define _PDFOBJ_H_
-
-#include <stdio.h>
-
-/* Here is the complete list of PDF object types */
-
-#define PDF_BOOLEAN 1
-#define PDF_NUMBER 2
-#define PDF_STRING 3
-#define PDF_NAME 4
-#define PDF_ARRAY 5
-#define PDF_DICT 6
-#define PDF_STREAM 7
-#define PDF_NULL 8
-#define PDF_INDIRECT 9
-
-#define PDF_OBJ_INVALID 0
-#define PDF_UNDEFINED PDF_OBJ_INVALID
-
-#define STREAM_COMPRESS (1 << 0)
-
-typedef struct pdf_obj pdf_obj;
-typedef struct pdf_file pdf_file;
-
-/* External interface to pdf routines */
-
-extern int pdf_obj_get_verbose (void);
-extern void pdf_obj_set_verbose (void);
-extern void pdf_error_cleanup (void);
-
-extern void pdf_out_init (const char *filename, int do_encryption);
-extern void pdf_out_flush (void);
-extern void pdf_set_version (unsigned version);
-extern unsigned pdf_get_version (void);
-
-extern pdf_obj *pdf_new_obj (int type);
-extern void pdf_release_obj (pdf_obj *object);
-extern int pdf_obj_typeof (pdf_obj *object);
-
-#define PDF_OBJ_NUMBERTYPE(o) ((o) && pdf_obj_typeof((o)) == PDF_NUMBER)
-#define PDF_OBJ_BOOLEANTYPE(o) ((o) && pdf_obj_typeof((o)) == PDF_BOOLEAN)
-#define PDF_OBJ_STRINGTYPE(o) ((o) && pdf_obj_typeof((o)) == PDF_STRING)
-#define PDF_OBJ_NAMETYPE(o) ((o) && pdf_obj_typeof((o)) == PDF_NAME)
-#define PDF_OBJ_ARRAYTYPE(o) ((o) && pdf_obj_typeof((o)) == PDF_ARRAY)
-#define PDF_OBJ_NULLTYPE(o) ((o) && pdf_obj_typeof((o)) == PDF_NULL)
-#define PDF_OBJ_DICTTYPE(o) ((o) && pdf_obj_typeof((o)) == PDF_DICT)
-#define PDF_OBJ_STREAMTYPE(o) ((o) && pdf_obj_typeof((o)) == PDF_STREAM)
-#define PDF_OBJ_INDIRECTTYPE(o) ((o) && pdf_obj_typeof((o)) == PDF_INDIRECT)
-
-#define PDF_OBJ_TYPEOF(o) pdf_obj_typeof((o))
-
-
-extern pdf_obj *pdf_ref_obj (pdf_obj *object);
-extern pdf_obj *pdf_link_obj (pdf_obj *object);
-
-extern pdf_obj *pdf_new_null (void);
-
-extern pdf_obj *pdf_new_boolean (char value);
-extern void pdf_set_boolean (pdf_obj *object, char value);
-extern char pdf_boolean_value (pdf_obj *object);
-
-extern pdf_obj *pdf_new_number (double value);
-extern void pdf_set_number (pdf_obj *object, double value);
-extern double pdf_number_value (pdf_obj *number);
-
-extern pdf_obj *pdf_new_string (const void *str, unsigned length);
-extern void pdf_set_string (pdf_obj *object, unsigned char *str, unsigned length);
-extern void *pdf_string_value (pdf_obj *object);
-extern unsigned pdf_string_length (pdf_obj *object);
-
-/* Name does not include the / */
-extern pdf_obj *pdf_new_name (const char *name);
-extern void pdf_set_name (pdf_obj *object, const char *name);
-extern char *pdf_name_value (pdf_obj *object);
-
-extern pdf_obj *pdf_new_array (void);
-/* pdf_add_dict requires key but pdf_add_array does not.
- * pdf_add_array always append elements to array.
- * They should be pdf_put_array(array, idx, element) and
- * pdf_put_dict(dict, key, value)
- */
-extern void pdf_add_array (pdf_obj *array, pdf_obj *object);
-#if 0
-extern void pdf_put_array (pdf_obj *array, unsigned idx, pdf_obj *object);
-#endif /* 0 */
-extern pdf_obj *pdf_get_array (pdf_obj *array, long idx);
-extern unsigned pdf_array_length (pdf_obj *array);
-
-extern void pdf_unshift_array (pdf_obj *array, pdf_obj *object);
-#if 0
-extern pdf_obj *pdf_shift_array (pdf_obj *array);
-extern pdf_obj *pdf_pop_array (pdf_obj *array);
-#endif /* 0 */
-
-extern pdf_obj *pdf_new_dict (void);
-extern void pdf_remove_dict (pdf_obj *dict, const char *key);
-extern void pdf_merge_dict (pdf_obj *dict1, pdf_obj *dict2);
-extern pdf_obj *pdf_lookup_dict (pdf_obj *dict, const char *key);
-extern pdf_obj *pdf_dict_keys (pdf_obj *dict);
-
-/* pdf_add_dict() want pdf_obj as key, however, key must always be name
- * object and pdf_lookup_dict() and pdf_remove_dict() uses const char as
- * key. This strange difference seems come from pdfdoc that first allocate
- * name objects frequently used (maybe 1000 times) such as /Type and does
- * pdf_link_obj() it rather than allocate/free-ing them each time. But I
- * already removed that.
- */
-extern int pdf_add_dict (pdf_obj *dict, pdf_obj *key, pdf_obj *value);
-#if 0
-extern void pdf_put_dict (pdf_obj *dict, const char *key, pdf_obj *value);
-#endif /* 0 */
-
-/* Apply proc(key, value, pdata) for each key-value pairs in dict, stop if proc()
- * returned non-zero value (and that value is returned). PDF object is passed for
- * key to allow modification (fix) of key.
- */
-extern int pdf_foreach_dict (pdf_obj *dict,
- int (*proc) (pdf_obj *, pdf_obj *, void *),
- void *pdata);
-
-extern pdf_obj *pdf_new_stream (int flags);
-extern void pdf_add_stream (pdf_obj *stream,
- const void *stream_data_ptr,
- long stream_data_len);
-#if HAVE_ZLIB
-extern int pdf_add_stream_flate (pdf_obj *stream,
- const void *stream_data_ptr,
- long stream_data_len);
-#endif
-extern int pdf_concat_stream (pdf_obj *dst, pdf_obj *src);
-extern pdf_obj *pdf_stream_dict (pdf_obj *stream);
-extern long pdf_stream_length (pdf_obj *stream);
-#if 0
-extern void pdf_stream_set_flags (pdf_obj *stream, int flags);
-extern int pdf_stream_get_flags (pdf_obj *stream);
-#endif /* 0 */
-extern const void *pdf_stream_dataptr (pdf_obj *stream);
-
-#if 0
-extern int pdf_stream_pop_filter (pdf_obj *stream);
-#endif
-
-/* Compare label of two indirect reference object.
- */
-extern int pdf_compare_reference (pdf_obj *ref1, pdf_obj *ref2);
-
-/* The following routines are not appropriate for pdfobj.
- */
-
-extern void pdf_set_compression (int level);
-
-extern void pdf_set_info (pdf_obj *obj);
-extern void pdf_set_root (pdf_obj *obj);
-extern void pdf_set_encrypt (pdf_obj *encrypt, pdf_obj *id);
-
-extern void pdf_files_init (void);
-extern void pdf_files_close (void);
-extern int check_for_pdf (FILE *file);
-extern pdf_file *pdf_open (char *ident, FILE *file);
-extern void pdf_close (pdf_file *pf);
-extern pdf_obj *pdf_file_get_trailer (pdf_file *pf);
-
-extern pdf_obj *pdf_deref_obj (pdf_obj *object);
-extern pdf_obj *pdf_import_object (pdf_obj *object);
-
-extern int pdfobj_escape_str (char *buffer, int size, const unsigned char *s, int len);
-
-extern pdf_obj *pdf_new_indirect (pdf_file *pf, unsigned long label, unsigned short generation);
-extern void pdf_copy_object (pdf_obj *dst, pdf_obj *src);
-
-#endif /* _PDFOBJ_H_ */
diff --git a/Build/source/texk/dvipdfm-x/xsrc/pdfximage.c b/Build/source/texk/dvipdfm-x/xsrc/pdfximage.c
index 9497cf6950e..3774fa14fac 100644
--- a/Build/source/texk/dvipdfm-x/xsrc/pdfximage.c
+++ b/Build/source/texk/dvipdfm-x/xsrc/pdfximage.c
@@ -111,14 +111,17 @@ static struct ic_ _ic = {
};
static void
-pdf_init_ximage_struct (pdf_ximage *I, const char *ident, const char *filename, pdf_obj *dict)
+pdf_init_ximage_struct (pdf_ximage *I,
+ const char *ident, const char *filename,
+ long page_no, pdf_obj *dict)
{
if (ident) {
I->ident = NEW(strlen(ident)+1, char);
strcpy(I->ident, ident);
} else
I ->ident = NULL;
- I->page_no = I->page_count = 0;
+ I->page_no = page_no;
+ I->page_count = 0;
if (filename) {
I->filename = NEW(strlen(filename)+1, char);
strcpy(I->filename, filename);
@@ -161,7 +164,7 @@ pdf_clean_ximage_struct (pdf_ximage *I)
pdf_release_obj(I->resource);
if (I->attr_dict)
pdf_release_obj(I->attr_dict);
- pdf_init_ximage_struct(I, NULL, NULL, NULL);
+ pdf_init_ximage_struct(I, NULL, NULL, 0, NULL);
}
@@ -260,8 +263,7 @@ load_image (const char *ident, const char *fullname, int format, FILE *fp,
}
I = &ic->ximages[id];
- pdf_init_ximage_struct(I, ident, ident, dict);
- pdf_ximage_set_page(I, page_no, 0);
+ pdf_init_ximage_struct(I, ident, fullname, page_no, dict);
switch (format) {
case IMAGE_TYPE_JPEG:
@@ -534,14 +536,6 @@ pdf_ximage_get_page (pdf_ximage *I)
return I->page_no;
}
-void
-pdf_ximage_set_page (pdf_ximage *I, long page_no, long page_count)
-{
- I->page_no = page_no;
- I->page_count = page_count;
-}
-
-
#define CHECK_ID(c,n) do {\
if ((n) < 0 || (n) >= (c)->count) {\
ERROR("Invalid XObject ID: %d", (n));\
@@ -581,7 +575,7 @@ pdf_ximage_defineresource (const char *ident,
I = &ic->ximages[id];
- pdf_init_ximage_struct(I, ident, NULL, NULL);
+ pdf_init_ximage_struct(I, ident, NULL, 0, NULL);
switch (subtype) {
case PDF_XOBJECT_TYPE_IMAGE:
diff --git a/Build/source/texk/dvipdfm-x/xsrc/pngimage.c b/Build/source/texk/dvipdfm-x/xsrc/pngimage.c
deleted file mode 100644
index dedf2c4688c..00000000000
--- a/Build/source/texk/dvipdfm-x/xsrc/pngimage.c
+++ /dev/null
@@ -1,1013 +0,0 @@
-/*
-
- This is dvipdfmx, an eXtended version of dvipdfm by Mark A. Wicks.
-
- Copyright (C) 2002-2012 by Jin-Hwan Cho and Shunsaku Hirata,
- the dvipdfmx project team.
-
- Copyright (C) 1998, 1999 by Mark A. Wicks <mwicks@kettering.edu>
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 2 of the License, or
- (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
-*/
-
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-
-/*
- * PNG SUPPORT
- *
- * All bitdepth less than 16 is supported.
- * Supported color types are: PALETTE, RGB, GRAY, RGB_ALPHA, GRAY_ALPHA.
- * Supported ancillary chunks: tRNS, cHRM + gAMA, (sRGB), (iCCP)
- *
- * gAMA support is available only when cHRM exists. cHRM support is not
- * tested well. CalRGB/CalGray colorspace is used for PNG images that
- * have cHRM chunk (but not sRGB).
- *
- * LIMITATIONS
- *
- * Recent version of PDF (>= 1.5) support 16 bpc, but 16 bit bitdepth PNG
- * images are automatically converted to 8 bit bitpedth image.
- *
- * TODO
- *
- * sBIT ? iTXT, tEXT and tIME as MetaData ?, pHYS (see below)
- * 16 bpc support for PDF-1.5. JBIG compression for monochrome image.
- * Predictor for deflate ?
- */
-
-#include "system.h"
-#include "error.h"
-#include "mem.h"
-
-#include "pdfcolor.h"
-#include "pdfobj.h"
-
-#define PNG_DEBUG_STR "PNG"
-#define PNG_DEBUG 3
-
-#ifdef HAVE_LIBPNG
-
-/*
- * Write, MNG, Progressive not required.
- */
-#define PNG_NO_WRITE_SUPPORTED
-#define PNG_NO_MNG_FEATURES
-#define PNG_NO_PROGRESSIVE_READ
-#if 0
-/* 16_TO_8 required. */
-#define PNG_NO_READ_TRANSFORMS
-#endif
-
-#include <png.h>
-#include "pngimage.h"
-
-#include "pdfximage.h"
-
-#define PDF_TRANS_TYPE_NONE 0
-#define PDF_TRANS_TYPE_BINARY 1
-#define PDF_TRANS_TYPE_ALPHA 2
-
-/* ColorSpace */
-static pdf_obj *create_cspace_Indexed (png_structp png_ptr, png_infop info_ptr);
-
-/* CIE-Based: CalRGB/CalGray
- *
- * We ignore gAMA if cHRM is not found.
- */
-static pdf_obj *create_cspace_CalRGB (png_structp png_ptr, png_infop info_ptr);
-static pdf_obj *create_cspace_CalGray (png_structp png_ptr, png_infop info_ptr);
-static pdf_obj *make_param_Cal (png_byte color_type,
- double G,
- double xw, double yw,
- double xr, double yr,
- double xg, double yg,
- double xb, double yb);
-
-/* sRGB:
- *
- * We (and PDF) do not have direct sRGB support. The sRGB color space can be
- * precisely represented by ICC profile, but we use approximate CalRGB color
- * space.
- */
-static pdf_obj *create_cspace_sRGB (png_structp png_ptr, png_infop info_ptr);
-static pdf_obj *get_rendering_intent (png_structp png_ptr, png_infop info_ptr);
-
-/* ICCBased:
- *
- * Not supported yet.
- * Must check if ICC profile is valid and can be imported to PDF.
- * There are few restrictions (should be applied to PNG too?) in ICC profile
- * support in PDF. Some information should be obtained from profile.
- */
-static pdf_obj *create_cspace_ICCBased (png_structp png_ptr, png_infop info_ptr);
-
-/* Transparency */
-static int check_transparency (png_structp png_ptr, png_infop info_ptr);
-/* Color-Key Mask */
-static pdf_obj *create_ckey_mask (png_structp png_ptr, png_infop info_ptr);
-/* Soft Mask:
- *
- * create_soft_mask() is for PNG_COLOR_TYPE_PALLETE.
- * Images with alpha chunnel use strip_soft_mask().
- * An object representing mask itself is returned.
- */
-static pdf_obj *create_soft_mask (png_structp png_ptr, png_infop info_ptr,
- png_bytep image_data_ptr,
- png_uint_32 width, png_uint_32 height);
-static pdf_obj *strip_soft_mask (png_structp png_ptr, png_infop info_ptr,
- png_bytep image_data_ptr,
- png_uint_32p rowbytes_ptr,
- png_uint_32 width, png_uint_32 height);
-
-/* Read image body */
-static void read_image_data (png_structp png_ptr, png_infop info_ptr,
- png_bytep dest_ptr,
- png_uint_32 height, png_uint_32 rowbytes);
-
-int
-check_for_png (FILE *png_file)
-{
- unsigned char sigbytes[4];
-
- rewind (png_file);
- if (fread (sigbytes, 1, sizeof(sigbytes), png_file) !=
- sizeof(sigbytes) ||
- (png_sig_cmp (sigbytes, 0, sizeof(sigbytes))))
- return 0;
- else
- return 1;
-}
-
-int
-png_include_image (pdf_ximage *ximage, FILE *png_file)
-{
- pdf_obj *stream;
- pdf_obj *stream_dict;
- pdf_obj *colorspace, *mask, *intent;
- png_bytep stream_data_ptr;
- int trans_type;
- ximage_info info;
- /* Libpng stuff */
- png_structp png_ptr;
- png_infop png_info_ptr;
- png_byte bpc, color_type;
- png_uint_32 width, height, rowbytes, xppm, yppm;
-
- pdf_ximage_init_image_info(&info);
-
- stream = NULL;
- stream_dict = NULL;
- colorspace = mask = intent = NULL;
-
- rewind (png_file);
- png_ptr = png_create_read_struct(PNG_LIBPNG_VER_STRING, NULL, NULL, NULL);
- if (png_ptr == NULL ||
- (png_info_ptr = png_create_info_struct (png_ptr)) == NULL) {
- WARN("%s: Creating Libpng read/info struct failed.", PNG_DEBUG_STR);
- if (png_ptr)
- png_destroy_read_struct(&png_ptr, NULL, NULL);
- return -1;
- }
-
- /* Inititializing file IO. */
- png_init_io (png_ptr, png_file);
-
- /* Read PNG info-header and get some info. */
- png_read_info(png_ptr, png_info_ptr);
- color_type = png_get_color_type (png_ptr, png_info_ptr);
- width = png_get_image_width (png_ptr, png_info_ptr);
- height = png_get_image_height(png_ptr, png_info_ptr);
- bpc = png_get_bit_depth (png_ptr, png_info_ptr);
- xppm = png_get_x_pixels_per_meter(png_ptr, png_info_ptr);
- yppm = png_get_y_pixels_per_meter(png_ptr, png_info_ptr);
-
- /* We do not need 16-bpc color. Ask libpng to convert down to 8-bpc. */
- if (bpc > 8) {
- png_set_strip_16(png_ptr);
- bpc = 8;
- }
-
- trans_type = check_transparency(png_ptr, png_info_ptr);
- /* check_transparency() does not do updata_info() */
- png_read_update_info(png_ptr, png_info_ptr);
- rowbytes = png_get_rowbytes(png_ptr, png_info_ptr);
-
- stream = pdf_new_stream (STREAM_COMPRESS);
- stream_dict = pdf_stream_dict(stream);
-
- /* Values listed below will not be modified in the remaining process. */
- info.width = width;
- info.height = height;
- info.bits_per_component = bpc;
- if (xppm > 0)
- info.xdensity = 72.0 / 0.0254 / xppm;
- if (yppm > 0)
- info.ydensity = 72.0 / 0.0254 / yppm;
-
- stream_data_ptr = (png_bytep) NEW(rowbytes*height, png_byte);
- read_image_data(png_ptr, png_info_ptr, stream_data_ptr, height, rowbytes);
-
- /* Non-NULL intent means there is valid sRGB chunk. */
- intent = get_rendering_intent(png_ptr, png_info_ptr);
- if (intent)
- pdf_add_dict(stream_dict, pdf_new_name("Intent"), intent);
-
- switch (color_type) {
- case PNG_COLOR_TYPE_PALETTE:
-
- colorspace = create_cspace_Indexed(png_ptr, png_info_ptr);
-
- switch (trans_type) {
- case PDF_TRANS_TYPE_BINARY:
- /* Color-key masking */
- mask = create_ckey_mask(png_ptr, png_info_ptr);
- break;
- case PDF_TRANS_TYPE_ALPHA:
- /* Soft mask */
- mask = create_soft_mask(png_ptr, png_info_ptr, stream_data_ptr, width, height);
- break;
- default:
- /* Nothing to be done here.
- * No tRNS chunk or image already composited with background color.
- */
- break;
- }
- break;
- case PNG_COLOR_TYPE_RGB:
- case PNG_COLOR_TYPE_RGB_ALPHA:
-
- if (png_get_valid(png_ptr, png_info_ptr, PNG_INFO_iCCP))
- colorspace = create_cspace_ICCBased(png_ptr, png_info_ptr);
- else if (intent) {
- colorspace = create_cspace_sRGB(png_ptr, png_info_ptr);
- } else {
- colorspace = create_cspace_CalRGB(png_ptr, png_info_ptr);
- }
- if (!colorspace)
- colorspace = pdf_new_name("DeviceRGB");
-
- switch (trans_type) {
- case PDF_TRANS_TYPE_BINARY:
- if (color_type != PNG_COLOR_TYPE_RGB)
- ERROR("Unexpected error in png_include_image().");
- mask = create_ckey_mask(png_ptr, png_info_ptr);
- break;
- /* rowbytes changes 4 to 3 at here */
- case PDF_TRANS_TYPE_ALPHA:
- if (color_type != PNG_COLOR_TYPE_RGB_ALPHA)
- ERROR("Unexpected error in png_include_image().");
- mask = strip_soft_mask(png_ptr, png_info_ptr,
- stream_data_ptr, &rowbytes, width, height);
- break;
- default:
- mask = NULL;
- }
- info.num_components = 3;
- break;
-
- case PNG_COLOR_TYPE_GRAY:
- case PNG_COLOR_TYPE_GRAY_ALPHA:
-
- if (png_get_valid(png_ptr, png_info_ptr, PNG_INFO_iCCP))
- colorspace = create_cspace_ICCBased(png_ptr, png_info_ptr);
- else if (intent) {
- colorspace = create_cspace_sRGB(png_ptr, png_info_ptr);
- } else {
- colorspace = create_cspace_CalGray(png_ptr, png_info_ptr);
- }
- if (!colorspace)
- colorspace = pdf_new_name("DeviceGray");
-
- switch (trans_type) {
- case PDF_TRANS_TYPE_BINARY:
- if (color_type != PNG_COLOR_TYPE_GRAY)
- ERROR("Unexpected error in png_include_image().");
- mask = create_ckey_mask(png_ptr, png_info_ptr);
- break;
- case PDF_TRANS_TYPE_ALPHA:
- if (color_type != PNG_COLOR_TYPE_GRAY_ALPHA)
- ERROR("Unexpected error in png_include_image().");
- mask = strip_soft_mask(png_ptr, png_info_ptr,
- stream_data_ptr, &rowbytes, width, height);
- break;
- default:
- mask = NULL;
- }
- info.num_components = 1;
- break;
-
- default:
- WARN("%s: Unknown PNG colortype %d.", PNG_DEBUG_STR, color_type);
- }
- pdf_add_dict(stream_dict, pdf_new_name("ColorSpace"), colorspace);
-
- pdf_add_stream(stream, stream_data_ptr, rowbytes*height);
- RELEASE(stream_data_ptr);
-
- if (mask) {
- if (trans_type == PDF_TRANS_TYPE_BINARY)
- pdf_add_dict(stream_dict, pdf_new_name("Mask"), mask);
- else if (trans_type == PDF_TRANS_TYPE_ALPHA) {
- pdf_add_dict(stream_dict, pdf_new_name("SMask"), pdf_ref_obj(mask));
- pdf_release_obj(mask);
- } else {
- WARN("%s: You found a bug in pngimage.c.", PNG_DEBUG_STR);
- pdf_release_obj(mask);
- }
- }
-
- png_read_end(png_ptr, NULL);
-
- /* Cleanup */
- if (png_info_ptr)
- png_destroy_info_struct(png_ptr, &png_info_ptr);
- if (png_ptr)
- png_destroy_read_struct(&png_ptr, NULL, NULL);
-
- pdf_ximage_set_image(ximage, &info, stream);
-
- return 0;
-}
-
-/*
- * The returned value trans_type is the type of transparency to be used for
- * this image. Possible values are:
- *
- * PDF_TRANS_TYPE_NONE No Masking will be used/required.
- * PDF_TRANS_TYPE_BINARY Pixels are either fully opaque/fully transparent.
- * PDF_TRANS_TYPE_ALPHA Uses alpha channel, requies SMask.(PDF-1.4)
- *
- * check_transparency() must check the current setting of output PDF version
- * and must choose appropriate trans_type value according to PDF version of
- * current output PDF document.
- *
- * If the PDF version is less than 1.3, no transparency is supported for this
- * version of PDF, hence PDF_TRANS_TYPE_NONE must be returned. And when the PDF
- * version is equal to 1.3, possible retrun values are PDF_TRANS_TYPE_BINARY or
- * PDF_TRANS_TYPE_NONE. The latter case arises when PNG file uses alpha channel
- * explicitly (color type PNG_COLOR_TYPE_XXX_ALPHA), or the tRNS chunk for the
- * PNG_COLOR_TYPE_PALETTE image contains intermediate values of opacity.
- *
- * Finally, in the case of PDF version 1.4, all kind of translucent pixels can
- * be represented with Soft-Mask.
- */
-
-static int
-check_transparency (png_structp png_ptr, png_infop info_ptr)
-{
- int trans_type;
- unsigned pdf_version;
- png_byte color_type;
- png_color_16p trans_values;
- png_bytep trans;
- int num_trans;
-
- pdf_version = pdf_get_version();
- color_type = png_get_color_type(png_ptr, info_ptr);
-
- /*
- * First we set trans_type to appropriate value for PNG image.
- */
- if (color_type == PNG_COLOR_TYPE_RGB_ALPHA ||
- color_type == PNG_COLOR_TYPE_GRAY_ALPHA) {
- trans_type = PDF_TRANS_TYPE_ALPHA;
- } else if (png_get_valid(png_ptr, info_ptr, PNG_INFO_tRNS) &&
- png_get_tRNS(png_ptr, info_ptr, &trans, &num_trans, &trans_values)) {
- /* Have valid tRNS chunk. */
- switch (color_type) {
- case PNG_COLOR_TYPE_PALETTE:
- /* Use color-key mask if possible. */
- trans_type = PDF_TRANS_TYPE_BINARY;
- while (num_trans-- > 0) {
- if (trans[num_trans] != 0x00 && trans[num_trans] != 0xff) {
- /* This seems not binary transparency */
- trans_type = PDF_TRANS_TYPE_ALPHA;
- break;
- }
- }
- break;
- case PNG_COLOR_TYPE_GRAY:
- case PNG_COLOR_TYPE_RGB:
- /* RGB or GRAY, single color specified by trans_values is transparent. */
- trans_type = PDF_TRANS_TYPE_BINARY;
- break;
- default:
- /* Else tRNS silently ignored. */
- trans_type = PDF_TRANS_TYPE_NONE;
- }
- } else { /* no transparency */
- trans_type = PDF_TRANS_TYPE_NONE;
- }
-
- /*
- * Now we check PDF version.
- * We can convert alpha cahnnels to explicit mask via user supplied alpha-
- * threshold value. But I will not do that.
- */
- if (( pdf_version < 3 && trans_type != PDF_TRANS_TYPE_NONE ) ||
- ( pdf_version < 4 && trans_type == PDF_TRANS_TYPE_ALPHA )) {
- /*
- * No transparency supported but PNG uses transparency, or Soft-Mask
- * required but no support for it is available in this version of PDF.
- * We must do pre-composition of image with the background image here. But,
- * we cannot do that in general since dvipdfmx is not a rasterizer. What we
- * can do here is to composite image with a rectangle filled with the
- * background color. However, images are stored as an Image XObject which
- * can be referenced anywhere in the PDF document content. Hence, we cannot
- * know the correct background color at this time. So we will choose white
- * as background color, which is most probable color in our cases.
- * We ignore bKGD chunk.
- */
- png_color_16 bg;
- bg.red = 255; bg.green = 255; bg.blue = 255; bg.gray = 255; bg.index = 0;
- png_set_background(png_ptr, &bg, PNG_BACKGROUND_GAMMA_SCREEN, 0, 1.0);
- WARN("%s: Transparency will be ignored. (no support in PDF ver. < 1.3)", PNG_DEBUG_STR);
- if (pdf_version < 3)
- WARN("%s: Please use -V 3 option to enable binary transparency support.", PNG_DEBUG_STR);
- if (pdf_version < 4)
- WARN("%s: Please use -V 4 option to enable full alpha channel support.", PNG_DEBUG_STR);
- trans_type = PDF_TRANS_TYPE_NONE;
- }
-
- return trans_type;
-}
-
-/*
- * sRGB:
- *
- * If sRGB chunk is present, cHRM and gAMA chunk must be ignored.
- *
- */
-static pdf_obj *
-get_rendering_intent (png_structp png_ptr, png_infop info_ptr)
-{
- pdf_obj *intent;
- int srgb_intent;
-
- if (png_get_valid(png_ptr, info_ptr, PNG_INFO_sRGB) &&
- png_get_sRGB (png_ptr, info_ptr, &srgb_intent)) {
- switch (srgb_intent) {
- case PNG_sRGB_INTENT_SATURATION:
- intent = pdf_new_name("Saturation");
- break;
- case PNG_sRGB_INTENT_PERCEPTUAL:
- intent = pdf_new_name("Perceptual");
- break;
- case PNG_sRGB_INTENT_ABSOLUTE:
- intent = pdf_new_name("AbsoluteColorimetric");
- break;
- case PNG_sRGB_INTENT_RELATIVE:
- intent = pdf_new_name("RelativeColorimetric");
- break;
- default:
- WARN("%s: Invalid value in PNG sRGB chunk: %d", PNG_DEBUG_STR, srgb_intent);
- intent = NULL;
- }
- } else
- intent = NULL;
-
- return intent;
-}
-
-/* Approximated sRGB */
-static pdf_obj *
-create_cspace_sRGB (png_structp png_ptr, png_infop info_ptr)
-{
- pdf_obj *colorspace;
- pdf_obj *cal_param;
- png_byte color_type;
-
- color_type = png_get_color_type(png_ptr, info_ptr);
-
- /* Parameters taken from PNG spec. section 4.2.2.3. */
- cal_param = make_param_Cal(color_type,
- 2.2,
- 0.3127, 0.329,
- 0.64, 0.33, 0.3, 0.6, 0.15, 0.06);
- if (!cal_param)
- return NULL;
-
- colorspace = pdf_new_array();
-
- switch (color_type) {
- case PNG_COLOR_TYPE_RGB:
- case PNG_COLOR_TYPE_RGB_ALPHA:
- case PNG_COLOR_TYPE_PALETTE:
- pdf_add_array(colorspace, pdf_new_name("CalRGB"));
- break;
- case PNG_COLOR_TYPE_GRAY:
- case PNG_COLOR_TYPE_GRAY_ALPHA:
- pdf_add_array(colorspace, pdf_new_name("CalGray"));
- break;
- }
- pdf_add_array(colorspace, cal_param);
-
- return colorspace;
-}
-
-static pdf_obj *
-create_cspace_ICCBased (png_structp png_ptr, png_infop info_ptr)
-{
- pdf_obj *colorspace;
- int csp_id, colortype;
- png_byte color_type;
- png_charp name;
- int compression_type; /* Manual page for libpng does not
- * clarify whether profile data is inflated by libpng.
- */
-#if PNG_LIBPNG_VER_MINOR < 5
- png_charp profile;
-#else
- png_bytep profile;
-#endif
- png_uint_32 proflen;
-
- if (!png_get_valid(png_ptr, info_ptr, PNG_INFO_iCCP) ||
- !png_get_iCCP(png_ptr, info_ptr, &name, &compression_type, &profile, &proflen))
- return NULL;
-
- color_type = png_get_color_type(png_ptr, info_ptr);
-
- if (color_type & PNG_COLOR_MASK_COLOR) {
- colortype = PDF_COLORSPACE_TYPE_RGB;
-#if 0
- alternate = create_cspace_CalRGB(png_ptr, info_ptr);
-#endif
- } else {
- colortype = PDF_COLORSPACE_TYPE_GRAY;
-#if 0
- alternate = create_cspace_CalGray(png_ptr, info_ptr);
-#endif
- }
-
-#if 0
- if (alternate)
- pdf_add_dict(dict, pdf_new_name("Alternate"), alternate);
-#endif
-
- if (iccp_check_colorspace(colortype, profile, proflen) < 0)
- colorspace = NULL;
- else {
- csp_id = iccp_load_profile(name, profile, proflen);
- if (csp_id < 0) {
- colorspace = NULL;
- } else {
- colorspace = pdf_get_colorspace_reference(csp_id);
- }
- }
-
- /* Rendering intent ... */
-
- return colorspace;
-}
-
-/*
- * gAMA, cHRM:
- *
- * If cHRM is present, we use CIE-Based color space. gAMA is also used here
- * if available.
- */
-
-#define INVALID_CHRM_VALUE(xw,yw,xr,yr,xg,yg,xb,yb) (\
- (xw) <= 0.0 || (yw) < 1.0e-10 || \
- (xr) < 0.0 || (yr) < 0.0 || (xg) < 0.0 || (yg) < 0.0 || \
- (xb) < 0.0 || (yb) < 0.0)
-
-static pdf_obj *
-create_cspace_CalRGB (png_structp png_ptr, png_infop info_ptr)
-{
- pdf_obj *colorspace;
- pdf_obj *cal_param;
- double xw, yw, xr, yr, xg, yg, xb, yb;
- double G;
-
- if (!png_get_valid(png_ptr, info_ptr, PNG_INFO_cHRM) ||
- !png_get_cHRM(png_ptr, info_ptr, &xw, &yw, &xr, &yr, &xg, &yg, &xb, &yb))
- return NULL;
-
- if (xw <= 0.0 || yw < 1.0e-10 ||
- xr < 0.0 || yr < 0.0 || xg < 0.0 || yg < 0.0 || xb < 0.0 || yb < 0.0) {
- WARN("%s: Invalid cHRM chunk parameters found.", PNG_DEBUG_STR);
- return NULL;
- }
-
- if (png_get_valid(png_ptr, info_ptr, PNG_INFO_gAMA) &&
- png_get_gAMA (png_ptr, info_ptr, &G)) {
- if (G < 1.0e-2) {
- WARN("%s: Unusual Gamma value: %g", PNG_DEBUG_STR, G);
- return NULL;
- }
- G = 1.0 / G; /* Gamma is inverted. */
- } else {
- G = 1.0;
- }
-
- cal_param = make_param_Cal(PNG_COLOR_TYPE_RGB, G, xw, yw, xr, yr, xg, yg, xb, yb);
-
- if (!cal_param)
- return NULL;
-
- colorspace = pdf_new_array();
- pdf_add_array(colorspace, pdf_new_name("CalRGB"));
- pdf_add_array(colorspace, cal_param);
-
- return colorspace;
-}
-
-static pdf_obj *
-create_cspace_CalGray (png_structp png_ptr, png_infop info_ptr)
-{
- pdf_obj *colorspace;
- pdf_obj *cal_param;
- double xw, yw, xr, yr, xg, yg, xb, yb;
- double G;
-
- if (!png_get_valid(png_ptr, info_ptr, PNG_INFO_cHRM) ||
- !png_get_cHRM(png_ptr, info_ptr, &xw, &yw, &xr, &yr, &xg, &yg, &xb, &yb))
- return NULL;
-
- if (xw <= 0.0 || yw < 1.0e-10 ||
- xr < 0.0 || yr < 0.0 || xg < 0.0 || yg < 0.0 || xb < 0.0 || yb < 0.0) {
- WARN("%s: Invalid cHRM chunk parameters found.", PNG_DEBUG_STR);
- return NULL;
- }
-
- if (png_get_valid(png_ptr, info_ptr, PNG_INFO_gAMA) &&
- png_get_gAMA (png_ptr, info_ptr, &G)) {
- if (G < 1.0e-2) {
- WARN("%s: Unusual Gamma value: %g", PNG_DEBUG_STR, G);
- return NULL;
- }
- G = 1.0 / G; /* Gamma is inverted. */
- } else {
- G = 1.0;
- }
-
- cal_param = make_param_Cal(PNG_COLOR_TYPE_GRAY, G, xw, yw, xr, yr, xg, yg, xb, yb);
-
- if (!cal_param)
- return NULL;
-
- colorspace = pdf_new_array();
- pdf_add_array(colorspace, pdf_new_name("CalGray"));
- pdf_add_array(colorspace, cal_param);
-
- return colorspace;
-}
-
-static pdf_obj *
-make_param_Cal (png_byte color_type,
- double G, /* Gamma */
- double xw, double yw,
- double xr, double yr, double xg, double yg, double xb, double yb)
-{
- pdf_obj *cal_param;
- pdf_obj *white_point, *matrix, *dev_gamma;
- double Xw, Yw, Zw; /* Yw = 1.0 */
- double Xr, Xg, Xb, Yr, Yb, Yg, Zr, Zg, Zb;
-
-#ifndef ABS
-#define ABS(x) ((x) < 0 ? -(x) : (x))
-#endif
- /*
- * TODO: Check validity
- *
- * Conversion found in
- *
- * com.sixlegs.image.png - Java package to read and display PNG images
- * Copyright (C) 1998, 1999, 2001 Chris Nokleberg
- *
- * http://www.sixlegs.com/software/png/
- *
- */
- {
- double zw, zr, zg, zb;
- double fr, fg, fb;
- double det;
-
- /* WhitePoint */
- zw = 1 - (xw + yw);
- zr = 1 - (xr + yr); zg = 1 - (xg + yg); zb = 1 - (xb + yb);
- Xw = xw / yw; Yw = 1.0; Zw = zw / yw;
-
- /* Matrix */
- det = xr * (yg * zb - zg * yb) - xg * (yr * zb - zr * yb) + xb * (yr * zg - zr * yg);
- if (ABS(det) < 1.0e-10) {
- WARN("Non invertible matrix: Maybe invalid value(s) specified in cHRM chunk.");
- return NULL;
- }
- fr = (Xw * (yg * zb - zg * yb) - xg * (zb - Zw * yb) + xb * (zg - Zw * yg)) / det;
- fg = (xr * (zb - Zw * yb) - Xw * (yr * zb - zr * yb) + xb * (yr * Zw - zr)) / det;
- fb = (xr * (yg * Zw - zg) - xg * (yr * Zw - zr) + Xw * (yr * zg - zr * yg)) / det;
- Xr = fr * xr; Yr = fr * yr; Zr = fr * zr;
- Xg = fg * xg; Yg = fg * yg; Zg = fg * zg;
- Xb = fb * xb; Yb = fb * yb; Zb = fb * zb;
- }
-
- if (G < 1.0e-2) {
- WARN("Unusual Gamma specified: %g", G);
- return NULL;
- }
-
- cal_param = pdf_new_dict();
-
- /* White point is always required. */
- white_point = pdf_new_array();
- pdf_add_array(white_point, pdf_new_number(ROUND(Xw, 0.00001)));
- pdf_add_array(white_point, pdf_new_number(ROUND(Yw, 0.00001)));
- pdf_add_array(white_point, pdf_new_number(ROUND(Zw, 0.00001)));
- pdf_add_dict(cal_param, pdf_new_name("WhitePoint"), white_point);
-
- /* Matrix - default: Identity */
- if (color_type & PNG_COLOR_MASK_COLOR) {
- if (G != 1.0) {
- dev_gamma = pdf_new_array();
- pdf_add_array(dev_gamma, pdf_new_number(ROUND(G, 0.00001)));
- pdf_add_array(dev_gamma, pdf_new_number(ROUND(G, 0.00001)));
- pdf_add_array(dev_gamma, pdf_new_number(ROUND(G, 0.00001)));
- pdf_add_dict(cal_param, pdf_new_name("Gamma"), dev_gamma);
- }
-
- matrix = pdf_new_array();
- pdf_add_array(matrix, pdf_new_number(ROUND(Xr, 0.00001)));
- pdf_add_array(matrix, pdf_new_number(ROUND(Yr, 0.00001)));
- pdf_add_array(matrix, pdf_new_number(ROUND(Zr, 0.00001)));
- pdf_add_array(matrix, pdf_new_number(ROUND(Xg, 0.00001)));
- pdf_add_array(matrix, pdf_new_number(ROUND(Yg, 0.00001)));
- pdf_add_array(matrix, pdf_new_number(ROUND(Zg, 0.00001)));
- pdf_add_array(matrix, pdf_new_number(ROUND(Xb, 0.00001)));
- pdf_add_array(matrix, pdf_new_number(ROUND(Yb, 0.00001)));
- pdf_add_array(matrix, pdf_new_number(ROUND(Zb, 0.00001)));
- pdf_add_dict (cal_param, pdf_new_name("Matrix"), matrix);
- } else { /* Gray */
- if (G != 1.0)
- pdf_add_dict(cal_param,
- pdf_new_name("Gamma"),
- pdf_new_number(ROUND(G, 0.00001)));
- }
-
- return cal_param;
-}
-
-/*
- * Set up Indexed ColorSpace for color-type PALETTE:
- *
- * PNG allows only RGB color for base color space. If gAMA and/or cHRM
- * chunk is available, we can use CalRGB color space instead of DeviceRGB
- * for base color space.
- *
- */
-static pdf_obj *
-create_cspace_Indexed (png_structp png_ptr, png_infop info_ptr)
-{
- pdf_obj *colorspace;
- pdf_obj *base, *lookup;
- png_byte *data_ptr;
- png_colorp plte;
- int num_plte, i;
-
- if (!png_get_valid(png_ptr, info_ptr, PNG_INFO_PLTE) ||
- !png_get_PLTE(png_ptr, info_ptr, &plte, &num_plte)) {
- WARN("%s: PNG does not have valid PLTE chunk.", PNG_DEBUG_STR);
- return NULL;
- }
-
- /* Order is important. */
- colorspace = pdf_new_array ();
- pdf_add_array(colorspace, pdf_new_name("Indexed"));
-
- if (png_get_valid(png_ptr, info_ptr, PNG_INFO_iCCP))
- base = create_cspace_ICCBased(png_ptr, info_ptr);
- else {
- if (png_get_valid(png_ptr, info_ptr, PNG_INFO_sRGB))
- base = create_cspace_sRGB(png_ptr, info_ptr);
- else
- base = create_cspace_CalRGB(png_ptr, info_ptr);
- }
-
- if (!base)
- base = pdf_new_name("DeviceRGB");
-
- pdf_add_array(colorspace, base);
- pdf_add_array(colorspace, pdf_new_number(num_plte-1));
- data_ptr = NEW(num_plte*3, png_byte);
- for (i = 0; i < num_plte; i++) {
- data_ptr[3*i] = plte[i].red;
- data_ptr[3*i+1] = plte[i].green;
- data_ptr[3*i+2] = plte[i].blue;
- }
- lookup = pdf_new_string(data_ptr, num_plte*3);
- RELEASE(data_ptr);
- pdf_add_array(colorspace, lookup);
-
- return colorspace;
-}
-
-/*
- * pHYs: no support
- *
- * pngimage.c is not responsible for adjusting image size.
- * Higher layer must do something for this.
- */
-
-/*
- * Colorkey Mask: array
- *
- * [component_0_min component_0_max ... component_n_min component_n_max]
- *
- */
-
-static pdf_obj *
-create_ckey_mask (png_structp png_ptr, png_infop info_ptr)
-{
- pdf_obj *colorkeys;
- png_byte color_type;
- png_bytep trans;
- int num_trans, i;
- png_color_16p colors;
-
- if (!png_get_valid(png_ptr, info_ptr, PNG_INFO_tRNS) ||
- !png_get_tRNS(png_ptr, info_ptr, &trans, &num_trans, &colors)) {
- WARN("%s: PNG does not have valid tRNS chunk!", PNG_DEBUG_STR);
- return NULL;
- }
-
- colorkeys = pdf_new_array();
- color_type = png_get_color_type(png_ptr, info_ptr);
-
- switch (color_type) {
- case PNG_COLOR_TYPE_PALETTE:
- for (i = 0; i < num_trans; i++) {
- if (trans[i] == 0x00) {
- pdf_add_array(colorkeys, pdf_new_number(i));
- pdf_add_array(colorkeys, pdf_new_number(i));
- } else if (trans[i] != 0xff) {
- WARN("%s: You found a bug in pngimage.c.", PNG_DEBUG_STR);
- }
- }
- break;
- case PNG_COLOR_TYPE_RGB:
- pdf_add_array(colorkeys, pdf_new_number(colors->red));
- pdf_add_array(colorkeys, pdf_new_number(colors->red));
- pdf_add_array(colorkeys, pdf_new_number(colors->green));
- pdf_add_array(colorkeys, pdf_new_number(colors->green));
- pdf_add_array(colorkeys, pdf_new_number(colors->blue));
- pdf_add_array(colorkeys, pdf_new_number(colors->blue));
- break;
- case PNG_COLOR_TYPE_GRAY:
- pdf_add_array(colorkeys, pdf_new_number(colors->gray));
- pdf_add_array(colorkeys, pdf_new_number(colors->gray));
- break;
- default:
- WARN("%s: You found a bug in pngimage.c.", PNG_DEBUG_STR);
- pdf_release_obj(colorkeys);
- colorkeys = NULL;
- }
-
- return colorkeys;
-}
-
-/*
- * Soft-Mask: stream
- *
- * <<
- * /Type /XObject
- * /Subtype /Image
- * /Width -int-
- * /Height -int-
- * /BitsPerComponent bpc
- * >>
- * stream .... endstream
- *
- * ColorSpace, Mask, SMask must be absent. ImageMask must be false or absent.
- */
-
-static pdf_obj *
-create_soft_mask (png_structp png_ptr, png_infop info_ptr,
- png_bytep image_data_ptr, png_uint_32 width, png_uint_32 height)
-{
- pdf_obj *smask, *dict;
- png_bytep smask_data_ptr;
- png_bytep trans;
- int num_trans;
- png_uint_32 i;
-
- if (!png_get_valid(png_ptr, info_ptr, PNG_INFO_tRNS) ||
- !png_get_tRNS(png_ptr, info_ptr, &trans, &num_trans, NULL)) {
- WARN("%s: PNG does not have valid tRNS chunk but tRNS is requested.", PNG_DEBUG_STR);
- return NULL;
- }
-
- smask = pdf_new_stream(STREAM_COMPRESS);
- dict = pdf_stream_dict(smask);
- smask_data_ptr = (png_bytep) NEW(width*height, png_byte);
- pdf_add_dict(dict, pdf_new_name("Type"), pdf_new_name("XObjcect"));
- pdf_add_dict(dict, pdf_new_name("Subtype"), pdf_new_name("Image"));
- pdf_add_dict(dict, pdf_new_name("Width"), pdf_new_number(width));
- pdf_add_dict(dict, pdf_new_name("Height"), pdf_new_number(height));
- pdf_add_dict(dict, pdf_new_name("ColorSpace"), pdf_new_name("DeviceGray"));
- pdf_add_dict(dict, pdf_new_name("BitsPerComponent"), pdf_new_number(8));
- for (i = 0; i < width*height; i++) {
- png_byte idx = image_data_ptr[i];
- smask_data_ptr[i] = (idx < num_trans) ? trans[idx] : 0xff;
- }
- pdf_add_stream(smask, (char *)smask_data_ptr, width*height);
- RELEASE(smask_data_ptr);
-
- return smask;
-}
-
-/* bitdepth is always 8 (16 is not supported) */
-static pdf_obj *
-strip_soft_mask (png_structp png_ptr, png_infop info_ptr,
- /* next two values will be modified. */
- png_bytep image_data_ptr, png_uint_32p rowbytes_ptr,
- png_uint_32 width, png_uint_32 height)
-{
- pdf_obj *smask, *dict;
- png_byte color_type;
- png_bytep smask_data_ptr;
- png_uint_32 i;
-
- color_type = png_get_color_type(png_ptr, info_ptr);
-
- if (color_type & PNG_COLOR_MASK_COLOR) {
- if (*rowbytes_ptr != 4*width*sizeof(png_byte)) { /* Something wrong */
- WARN("%s: Inconsistent rowbytes value.", PNG_DEBUG_STR);
- return NULL;
- }
- } else {
- if (*rowbytes_ptr != 2*width*sizeof(png_byte)) { /* Something wrong */
- WARN("%s: Inconsistent rowbytes value.", PNG_DEBUG_STR);
- return NULL;
- }
- }
-
- smask = pdf_new_stream(STREAM_COMPRESS);
- dict = pdf_stream_dict(smask);
- pdf_add_dict(dict, pdf_new_name("Type"), pdf_new_name("XObjcect"));
- pdf_add_dict(dict, pdf_new_name("Subtype"), pdf_new_name("Image"));
- pdf_add_dict(dict, pdf_new_name("Width"), pdf_new_number(width));
- pdf_add_dict(dict, pdf_new_name("Height"), pdf_new_number(height));
- pdf_add_dict(dict, pdf_new_name("ColorSpace"), pdf_new_name("DeviceGray"));
- pdf_add_dict(dict, pdf_new_name("BitsPerComponent"), pdf_new_number(8));
-
- smask_data_ptr = (png_bytep) NEW(width*height, png_byte);
-
- switch (color_type) {
- case PNG_COLOR_TYPE_RGB_ALPHA:
- for (i = 0; i < width*height; i++) {
- memmove(image_data_ptr+(3*i), image_data_ptr+(4*i), 3);
- smask_data_ptr[i] = image_data_ptr[4*i+3];
- }
- *rowbytes_ptr = 3*width*sizeof(png_byte);
- break;
- case PNG_COLOR_TYPE_GRAY_ALPHA:
- for (i = 0; i < width*height; i++) {
- image_data_ptr[i] = image_data_ptr[2*i];
- smask_data_ptr[i] = image_data_ptr[2*i+1];
- }
- *rowbytes_ptr = width*sizeof(png_byte);
- break;
- default:
- WARN("You found a bug in pngimage.c!");
- pdf_release_obj(smask);
- RELEASE(smask_data_ptr);
- return NULL;
- }
-
- pdf_add_stream(smask, smask_data_ptr, width*height);
- RELEASE(smask_data_ptr);
-
- return smask;
-}
-
-static void
-read_image_data (png_structp png_ptr, png_infop info_ptr, /* info_ptr unused */
- png_bytep dest_ptr, png_uint_32 height, png_uint_32 rowbytes)
-{
- png_bytepp rows_p;
- png_uint_32 i;
-
- rows_p = (png_bytepp) NEW (height, png_bytep);
- for (i=0; i< height; i++)
- rows_p[i] = dest_ptr + (rowbytes * i);
- png_read_image(png_ptr, rows_p);
- RELEASE(rows_p);
-}
-
-#endif /* HAVE_LIBPNG */
diff --git a/Build/source/texk/dvipdfm-x/xsrc/xbb.c b/Build/source/texk/dvipdfm-x/xsrc/xbb.c
index 6820b3af4c5..a8564b1e042 100644
--- a/Build/source/texk/dvipdfm-x/xsrc/xbb.c
+++ b/Build/source/texk/dvipdfm-x/xsrc/xbb.c
@@ -33,22 +33,19 @@
#include "error.h"
#include "mfileio.h"
#include "pdfobj.h"
+#include "pdfdoc.h"
#include "pdfparse.h"
#include "config.h"
-#ifdef HAVE_LIBPNG
-#include <png.h>
-#endif
+#include "jpegimage.h"
+#include "pngimage.h"
#include "dvipdfmx.h"
-#include "xbb.h"
#define XBB_PROGRAM "extractbb"
#define XBB_VERSION VERSION
-static int xbb_output_mode = XBB_OUTPUT;
-
static void show_version(void)
{
fprintf (stdout, "%s, version %s, Copyright (C) 2008 by Jin-Hwan Cho\n",
@@ -65,7 +62,7 @@ static void show_usage(void)
fprintf (stdout, "\nUsage: %s [-v] [-b] [-m|-x] [files]\n", XBB_PROGRAM);
fprintf (stdout, "\t-v\tBe verbose\n");
fprintf (stdout, "\t-b\tWrite output file in binary mode\n");
- if(xbb_output_mode == EBB_OUTPUT) {
+ if(compat_mode) {
fprintf (stdout, "\t-m\tOutput .bb file used in DVIPDFM (default)\n");
fprintf (stdout, "\t-x\tOutput .xbb file used in DVIPDFMx\n");
} else {
@@ -97,6 +94,8 @@ const char *extensions[] = {
".jpeg", ".JPEG", ".jpg", ".JPG", ".pdf", ".PDF", ".png", ".PNG"
};
+static int xbb_to_file = 1;
+
static char *make_xbb_filename(const char *name)
{
int i;
@@ -116,207 +115,121 @@ static char *make_xbb_filename(const char *name)
strncpy(result, name, strlen(name)-strlen(extensions[i]));
result[strlen(name)-strlen(extensions[i])] = 0;
}
- strcat(result, (xbb_output_mode == XBB_OUTPUT ? ".xbb" : ".bb"));
+ strcat(result, (compat_mode ? ".bb" : ".xbb"));
return result;
}
static const char *xbb_file_mode = FOPEN_W_MODE;
-static void write_xbb(char *fname, int bbllx, int bblly, int bburx, int bbury)
+static void write_xbb(char *fname,
+ double bbllx_f, double bblly_f,
+ double bburx_f, double bbury_f,
+ int pdf_version, long pagecount)
{
- char *outname;
+ char *outname = NULL;
FILE *fp;
- outname = make_xbb_filename(fname);
- if ((fp = MFOPEN(outname, xbb_file_mode)) == NULL) {
- fprintf(stderr, "Unable to open output file: %s\n", outname);
- RELEASE(outname);
- return;
+ long bbllx = ROUND(bbllx_f, 1.0), bblly = ROUND(bblly_f, 1.0);
+ long bburx = ROUND(bburx_f, 1.0), bbury = ROUND(bbury_f, 1.0);
+
+ if (xbb_to_file) {
+ outname = make_xbb_filename(fname);
+ if ((fp = MFOPEN(outname, FOPEN_W_MODE)) == NULL) {
+ ERROR("Unable to open output file: %s\n", outname);
+ }
+ } else {
+ fp = stdout;
+#ifdef WIN32
+ setmode(fileno(fp), _O_BINARY);
+#endif
}
+
if (verbose) {
- MESG("Writing to %s: ", outname);
+ MESG("Writing to %s: ", xbb_to_file ? outname : "stdout");
MESG("Bounding box: %d %d %d %d\n", bbllx, bblly, bburx, bbury);
}
+
fprintf(fp, "%%%%Title: %s\n", fname);
fprintf(fp, "%%%%Creator: %s %s\n", XBB_PROGRAM, XBB_VERSION);
- fprintf(fp, "%%%%BoundingBox: %d %d %d %d\n", bbllx, bblly, bburx, bbury);
- do_time(fp);
- RELEASE(outname);
- MFCLOSE(fp);
-}
-
-typedef enum {
- JM_SOF0 = 0xc0, JM_SOF1 = 0xc1, JM_SOF2 = 0xc2, JM_SOF3 = 0xc3,
- JM_SOF5 = 0xc5, JM_DHT = 0xc4, JM_SOF6 = 0xc6, JM_SOF7 = 0xc7,
- JM_SOF9 = 0xc9, JM_SOF10 = 0xca, JM_SOF11 = 0xcb, JM_DAC = 0xcc,
- JM_SOF13 = 0xcd, JM_SOF14 = 0xce, JM_SOF15 = 0xcf,
-
- JM_RST0 = 0xd0, JM_RST1 = 0xd1, JM_RST2 = 0xd2, JM_RST3 = 0xd3,
- JM_RST4 = 0xd4, JM_RST5 = 0xd5, JM_RST6 = 0xd6, JM_RST7 = 0xd7,
-
- JM_SOI = 0xd8, JM_EOI = 0xd9, JM_SOS = 0xda, JM_DQT = 0xdb,
- JM_DNL = 0xdc, JM_DRI = 0xdd, JM_DHP = 0xde, JM_EXP = 0xdf,
-
- JM_APP0 = 0xe0, JM_APP2 = 0xe2, JM_APP14 = 0xee, JM_APP15 = 0xef,
-
- JM_COM = 0xfe
-} JPEG_marker;
-
-static JPEG_marker JPEG_get_marker (FILE *fp)
-{
- int c = fgetc(fp);
- if (c != 255) return -1;
- for (;;) {
- c = fgetc(fp);
- if (c < 0) return -1;
- else if (c > 0 && c < 255) return c;
+ fprintf(fp, "%%%%BoundingBox: %ld %ld %ld %ld\n", bbllx, bblly, bburx, bbury);
+
+ if (!compat_mode) {
+ /* Note:
+ * According to Adobe Technical Note #5644, the arguments to
+ * "%%HiResBoundingBox:" must be of type real. And according
+ * to the PostScript Language Reference, a real number must
+ * be written with a decimal point (or an exponent). Hence
+ * it seems illegal to replace "0.0" by "0".
+ */
+ fprintf(fp, "%%%%HiResBoundingBox: %f %f %f %f\n",
+ bbllx_f, bblly_f, bburx_f, bbury_f);
+ if (pdf_version >= 0) {
+ fprintf(fp, "%%%%PDFVersion: 1.%d\n", pdf_version);
+ fprintf(fp, "%%%%Pages: %ld\n", pagecount);
+ }
}
- return -1;
-}
-static int check_for_jpeg (FILE *fp)
-{
- unsigned char jpeg_sig[2];
- rewind(fp);
- if (fread(jpeg_sig, sizeof(unsigned char), 2, fp) != 2) return 0;
- else if (jpeg_sig[0] != 0xff || jpeg_sig[1] != JM_SOI) return 0;
- return 1;
-}
+ do_time(fp);
-static int jpeg_get_info (FILE *fp, int *width, int *height)
-{
- JPEG_marker marker;
- unsigned short length;
- int count;
- float xdensity = 1.0, ydensity = 1.0;
- char app_sig[128];
-
- if (!check_for_jpeg(fp)) {
- rewind(fp);
- return -1;
- }
- rewind(fp);
- count = 0;
- while ((marker = JPEG_get_marker(fp)) >= 0) {
- if (marker == JM_SOI || (marker >= JM_RST0 && marker <= JM_RST7)) {
- count++; continue;
- }
- length = get_unsigned_pair(fp) - 2;
- switch (marker) {
- case JM_SOF0: case JM_SOF1: case JM_SOF2: case JM_SOF3:
- case JM_SOF5: case JM_SOF6: case JM_SOF7: case JM_SOF9:
- case JM_SOF10: case JM_SOF11: case JM_SOF13: case JM_SOF14:
- case JM_SOF15:
- get_unsigned_byte(fp);
- if (xbb_output_mode != XBB_OUTPUT) { /* EBB_OUTPUT */
- xdensity = ydensity = 72.0 / 100.0;
- }
- *height = (int)(get_unsigned_pair(fp) * ydensity + 0.5);
- *width = (int)(get_unsigned_pair(fp) * xdensity + 0.5);
- return 0;
- case JM_APP0:
- if (length > 5) {
- if (fread(app_sig, sizeof(char), 5, fp) != 5) return -1;
- length -= 5;
- if (!memcmp(app_sig, "JFIF\000", 5)) {
- int units, xden, yden;
- get_unsigned_pair(fp);
- units = (int)get_unsigned_byte(fp);
- xden = (int)get_unsigned_pair(fp);
- yden = (int)get_unsigned_pair(fp);
- switch (units) {
- case 1: /* pixels per inch */
- xdensity = 72.0 / xden;
- ydensity = 72.0 / yden;
- break;
- case 2: /* pixels per centimeter */
- xdensity = 72.0 / 2.54 / xden;
- ydensity = 72.0 / 2.54 / yden;
- break;
- default:
- break;
- }
- length -= 7;
- }
- }
- seek_relative(fp, length);
- break;
- default:
- seek_relative(fp, length);
- break;
- }
- count++;
+ if (xbb_to_file) {
+ RELEASE(outname);
+ MFCLOSE(fp);
}
- return -1;
}
static void do_jpeg (FILE *fp, char *filename)
{
- int width, height;
+ long width, height;
+ double xdensity, ydensity;
- if (jpeg_get_info(fp, &width, &height) < 0) {
- fprintf (stderr, "%s does not look like a JPEG file...\n", filename);
+ if (jpeg_get_bbox(fp, &width, &height, &xdensity, &ydensity) < 0) {
+ WARN("%s does not look like a JPEG file...\n", filename);
return;
}
- write_xbb(filename, 0, 0, width, height);
+
+ write_xbb(filename, 0, 0, xdensity*width, ydensity*height, -1, -1);
return;
}
#ifdef HAVE_LIBPNG
-static int check_for_png (FILE *png_file)
-{
- unsigned char sigbytes[4];
- rewind (png_file);
- if (fread(sigbytes, 1, sizeof(sigbytes), png_file) != sizeof(sigbytes) ||
- (png_sig_cmp (sigbytes, 0, sizeof(sigbytes)))) return 0;
- else return 1;
-}
-
-static int png_get_info(FILE *png_file, int *width, int *height)
+static void do_png (FILE *fp, char *filename)
{
- png_structp png_ptr;
- png_infop png_info_ptr;
- png_uint_32 xppm, yppm;
+ long width, height;
+ double xdensity, ydensity;
- rewind(png_file);
-
- png_ptr = png_create_read_struct(PNG_LIBPNG_VER_STRING, NULL, NULL, NULL);
- if (png_ptr == NULL || (png_info_ptr = png_create_info_struct(png_ptr)) == NULL) {
- if (png_ptr) png_destroy_read_struct(&png_ptr, NULL, NULL);
- return -1;
- }
- png_init_io(png_ptr, png_file);
- png_read_info(png_ptr, png_info_ptr);
-
- *width = (int)png_get_image_width(png_ptr, png_info_ptr);
- *height = (int)png_get_image_height(png_ptr, png_info_ptr);
-
- if (xbb_output_mode == XBB_OUTPUT) {
- xppm = png_get_x_pixels_per_meter(png_ptr, png_info_ptr);
- yppm = png_get_y_pixels_per_meter(png_ptr, png_info_ptr);
- if (xppm > 0)
- *width = (int)(*width * 72.0 / 0.0254 / xppm + 0.5);
- if (yppm > 0)
- *height = (int)(*height * 72.0 / 0.0254 / yppm + 0.5);
- } else { /* EBB_OUTPUT */
- *width = (int)(*width * 72.0 / 100.0 + 0.5);
- *height = (int)(*height * 72.0 / 100.0 + 0.5);
+ if (png_get_bbox(fp, &width, &height, &xdensity, &ydensity) < 0) {
+ WARN("%s does not look like a PNG file...\n", filename);
+ return;
}
- return 0;
+
+ write_xbb(filename, 0, 0, xdensity*width, ydensity*height, -1, -1);
+ return;
}
+#endif /* HAVE_LIBPNG */
-static void do_png (FILE *fp, char *filename)
+#ifdef XETEX
+static void write_xbb_old(char *fname, int bbllx, int bblly, int bburx, int bbury)
{
- int width, height;
+ char *outname;
+ FILE *fp;
- if (png_get_info(fp, &width, &height) < 0) {
- fprintf (stderr, "%s does not look like a PNG file...\n", filename);
+ outname = make_xbb_filename(fname);
+ if ((fp = MFOPEN(outname, xbb_file_mode)) == NULL) {
+ fprintf(stderr, "Unable to open output file: %s\n", outname);
+ RELEASE(outname);
return;
}
- write_xbb(filename, 0, 0, width, height);
- return;
+ if (verbose) {
+ MESG("Writing to %s: ", outname);
+ MESG("Bounding box: %d %d %d %d\n", bbllx, bblly, bburx, bbury);
+ }
+ fprintf(fp, "%%%%Title: %s\n", fname);
+ fprintf(fp, "%%%%Creator: %s %s\n", XBB_PROGRAM, XBB_VERSION);
+ fprintf(fp, "%%%%BoundingBox: %d %d %d %d\n", bbllx, bblly, bburx, bbury);
+ do_time(fp);
+ RELEASE(outname);
+ MFCLOSE(fp);
}
-#endif /* HAVE_LIBPNG */
static int rect_equal (pdf_obj *rect1, pdf_obj *rect2)
{
@@ -448,20 +361,43 @@ static void do_pdf (FILE *fp, char *filename)
fprintf (stderr, "%s does not look like a PDF file...\n", filename);
return;
}
- write_xbb(filename, llx, lly, urx, ury);
+ write_xbb_old(filename, llx, lly, urx, ury);
return;
}
-
-int extractbb (int argc, char *argv[], int mode)
+#else
+static void do_pdf (FILE *fp, char *filename)
{
- xbb_output_mode = mode;
+ pdf_obj *page;
+ pdf_file *pf;
+ long page_no = 1;
+ long count;
+ pdf_rect bbox;
+
+ pf = pdf_open(filename, fp);
+ if (!pf) {
+ WARN("%s does not look like a PDF file...\n", filename);
+ return;
+ }
+
+ page = pdf_doc_get_page(pf, page_no, &count, &bbox, NULL);
+ pdf_close(pf);
+
+ if (!page)
+ return;
+
+ pdf_release_obj(page);
+ write_xbb(filename, bbox.llx, bbox.lly, bbox.urx, bbox.ury,
+ pdf_file_get_version(pf), count);
+}
+#endif
+
+int extractbb (int argc, char *argv[])
+{
pdf_files_init();
pdf_set_version(5);
- kpse_set_program_name(argv[0], NULL);
-
argc -= 1; argv += 1;
if (argc == 0)
usage();
@@ -473,11 +409,11 @@ int extractbb (int argc, char *argv[], int mode)
argc -= 1; argv += 1;
break;
case 'm':
- xbb_output_mode = EBB_OUTPUT;
+ compat_mode = 1;
argc -= 1; argv += 1;
break;
case 'x':
- xbb_output_mode = XBB_OUTPUT;
+ compat_mode = 0;
argc -= 1; argv += 1;
break;
case 'v':
@@ -485,9 +421,9 @@ int extractbb (int argc, char *argv[], int mode)
argc -= 1; argv += 1;
break;
case 'h':
- usage();
- argc -= 1; argv += 1;
- break;
+ show_version();
+ show_usage();
+ exit (0);
default:
usage();
}