laag-libtiff 4.0.9.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (629) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +57 -0
  3. data/LICENSE.txt +21 -0
  4. data/README.org +34 -0
  5. data/ext/laag/libtiff/extconf.rb +13 -0
  6. data/laag-libtiff.gemspec +20 -0
  7. data/lib/laag/libtiff.rb +29 -0
  8. data/vendor/gitlab.com/libtiff/libtiff/.appveyor.yml +109 -0
  9. data/vendor/gitlab.com/libtiff/libtiff/.cvsignore +4 -0
  10. data/vendor/gitlab.com/libtiff/libtiff/.travis.yml +34 -0
  11. data/vendor/gitlab.com/libtiff/libtiff/CMakeLists.txt +764 -0
  12. data/vendor/gitlab.com/libtiff/libtiff/COMMITTERS +19 -0
  13. data/vendor/gitlab.com/libtiff/libtiff/COPYRIGHT +21 -0
  14. data/vendor/gitlab.com/libtiff/libtiff/ChangeLog +8073 -0
  15. data/vendor/gitlab.com/libtiff/libtiff/HOWTO-RELEASE +119 -0
  16. data/vendor/gitlab.com/libtiff/libtiff/HOWTO-SECURITY-RELEASE +19 -0
  17. data/vendor/gitlab.com/libtiff/libtiff/Makefile.am +91 -0
  18. data/vendor/gitlab.com/libtiff/libtiff/Makefile.in +995 -0
  19. data/vendor/gitlab.com/libtiff/libtiff/Makefile.vc +58 -0
  20. data/vendor/gitlab.com/libtiff/libtiff/README +61 -0
  21. data/vendor/gitlab.com/libtiff/libtiff/README.vms +12 -0
  22. data/vendor/gitlab.com/libtiff/libtiff/RELEASE-DATE +1 -0
  23. data/vendor/gitlab.com/libtiff/libtiff/SConstruct +171 -0
  24. data/vendor/gitlab.com/libtiff/libtiff/TODO +12 -0
  25. data/vendor/gitlab.com/libtiff/libtiff/VERSION +1 -0
  26. data/vendor/gitlab.com/libtiff/libtiff/aclocal.m4 +1194 -0
  27. data/vendor/gitlab.com/libtiff/libtiff/archive/html/man/bmp2tiff.1.html +121 -0
  28. data/vendor/gitlab.com/libtiff/libtiff/archive/html/man/gif2tiff.1.html +141 -0
  29. data/vendor/gitlab.com/libtiff/libtiff/archive/html/man/ras2tiff.1.html +139 -0
  30. data/vendor/gitlab.com/libtiff/libtiff/archive/html/man/sgi2tiff.1.html +147 -0
  31. data/vendor/gitlab.com/libtiff/libtiff/archive/html/man/tiffsv.1.html +207 -0
  32. data/vendor/gitlab.com/libtiff/libtiff/archive/man/bmp2tiff.1 +85 -0
  33. data/vendor/gitlab.com/libtiff/libtiff/archive/man/gif2tiff.1 +81 -0
  34. data/vendor/gitlab.com/libtiff/libtiff/archive/man/ras2tiff.1 +96 -0
  35. data/vendor/gitlab.com/libtiff/libtiff/archive/man/sgi2tiff.1 +93 -0
  36. data/vendor/gitlab.com/libtiff/libtiff/archive/man/tiffsv.1 +142 -0
  37. data/vendor/gitlab.com/libtiff/libtiff/archive/tools/bmp2tiff.c +937 -0
  38. data/vendor/gitlab.com/libtiff/libtiff/archive/tools/gif2tiff.c +591 -0
  39. data/vendor/gitlab.com/libtiff/libtiff/archive/tools/ras2tiff.c +338 -0
  40. data/vendor/gitlab.com/libtiff/libtiff/archive/tools/rasterfile.h +44 -0
  41. data/vendor/gitlab.com/libtiff/libtiff/archive/tools/sgi2tiff.c +337 -0
  42. data/vendor/gitlab.com/libtiff/libtiff/archive/tools/sgisv.c +318 -0
  43. data/vendor/gitlab.com/libtiff/libtiff/archive/tools/ycbcr.c +168 -0
  44. data/vendor/gitlab.com/libtiff/libtiff/autogen.sh +8 -0
  45. data/vendor/gitlab.com/libtiff/libtiff/build/.cvsignore +1 -0
  46. data/vendor/gitlab.com/libtiff/libtiff/build/CMakeLists.txt +25 -0
  47. data/vendor/gitlab.com/libtiff/libtiff/build/Makefile.am +32 -0
  48. data/vendor/gitlab.com/libtiff/libtiff/build/Makefile.in +680 -0
  49. data/vendor/gitlab.com/libtiff/libtiff/build/README +3 -0
  50. data/vendor/gitlab.com/libtiff/libtiff/build/travis-ci +108 -0
  51. data/vendor/gitlab.com/libtiff/libtiff/commit +233 -0
  52. data/vendor/gitlab.com/libtiff/libtiff/config/compile +347 -0
  53. data/vendor/gitlab.com/libtiff/libtiff/config/config.guess +1526 -0
  54. data/vendor/gitlab.com/libtiff/libtiff/config/config.sub +1658 -0
  55. data/vendor/gitlab.com/libtiff/libtiff/config/depcomp +791 -0
  56. data/vendor/gitlab.com/libtiff/libtiff/config/install-sh +507 -0
  57. data/vendor/gitlab.com/libtiff/libtiff/config/ltmain.sh +11156 -0
  58. data/vendor/gitlab.com/libtiff/libtiff/config/missing +215 -0
  59. data/vendor/gitlab.com/libtiff/libtiff/config/mkinstalldirs +161 -0
  60. data/vendor/gitlab.com/libtiff/libtiff/config/test-driver +127 -0
  61. data/vendor/gitlab.com/libtiff/libtiff/configure +23612 -0
  62. data/vendor/gitlab.com/libtiff/libtiff/configure.ac +1112 -0
  63. data/vendor/gitlab.com/libtiff/libtiff/configure.com +1357 -0
  64. data/vendor/gitlab.com/libtiff/libtiff/contrib/.cvsignore +2 -0
  65. data/vendor/gitlab.com/libtiff/libtiff/contrib/CMakeLists.txt +35 -0
  66. data/vendor/gitlab.com/libtiff/libtiff/contrib/Makefile.am +31 -0
  67. data/vendor/gitlab.com/libtiff/libtiff/contrib/Makefile.in +679 -0
  68. data/vendor/gitlab.com/libtiff/libtiff/contrib/README +2 -0
  69. data/vendor/gitlab.com/libtiff/libtiff/contrib/addtiffo/.cvsignore +5 -0
  70. data/vendor/gitlab.com/libtiff/libtiff/contrib/addtiffo/CMakeLists.txt +34 -0
  71. data/vendor/gitlab.com/libtiff/libtiff/contrib/addtiffo/Makefile.am +39 -0
  72. data/vendor/gitlab.com/libtiff/libtiff/contrib/addtiffo/Makefile.in +652 -0
  73. data/vendor/gitlab.com/libtiff/libtiff/contrib/addtiffo/Makefile.vc +28 -0
  74. data/vendor/gitlab.com/libtiff/libtiff/contrib/addtiffo/README +142 -0
  75. data/vendor/gitlab.com/libtiff/libtiff/contrib/addtiffo/addtiffo.c +181 -0
  76. data/vendor/gitlab.com/libtiff/libtiff/contrib/addtiffo/tif_overview.c +916 -0
  77. data/vendor/gitlab.com/libtiff/libtiff/contrib/addtiffo/tif_ovrcache.c +344 -0
  78. data/vendor/gitlab.com/libtiff/libtiff/contrib/addtiffo/tif_ovrcache.h +103 -0
  79. data/vendor/gitlab.com/libtiff/libtiff/contrib/dbs/.cvsignore +8 -0
  80. data/vendor/gitlab.com/libtiff/libtiff/contrib/dbs/CMakeLists.txt +43 -0
  81. data/vendor/gitlab.com/libtiff/libtiff/contrib/dbs/Makefile.am +46 -0
  82. data/vendor/gitlab.com/libtiff/libtiff/contrib/dbs/Makefile.in +798 -0
  83. data/vendor/gitlab.com/libtiff/libtiff/contrib/dbs/README +7 -0
  84. data/vendor/gitlab.com/libtiff/libtiff/contrib/dbs/tiff-bi.c +91 -0
  85. data/vendor/gitlab.com/libtiff/libtiff/contrib/dbs/tiff-grayscale.c +147 -0
  86. data/vendor/gitlab.com/libtiff/libtiff/contrib/dbs/tiff-palette.c +284 -0
  87. data/vendor/gitlab.com/libtiff/libtiff/contrib/dbs/tiff-rgb.c +201 -0
  88. data/vendor/gitlab.com/libtiff/libtiff/contrib/dbs/xtiff/.cvsignore +2 -0
  89. data/vendor/gitlab.com/libtiff/libtiff/contrib/dbs/xtiff/CMakeLists.txt +29 -0
  90. data/vendor/gitlab.com/libtiff/libtiff/contrib/dbs/xtiff/Makefile.am +47 -0
  91. data/vendor/gitlab.com/libtiff/libtiff/contrib/dbs/xtiff/Makefile.in +516 -0
  92. data/vendor/gitlab.com/libtiff/libtiff/contrib/dbs/xtiff/README +6 -0
  93. data/vendor/gitlab.com/libtiff/libtiff/contrib/dbs/xtiff/patchlevel.h +8 -0
  94. data/vendor/gitlab.com/libtiff/libtiff/contrib/dbs/xtiff/xtiff.c +1290 -0
  95. data/vendor/gitlab.com/libtiff/libtiff/contrib/dbs/xtiff/xtifficon.h +21 -0
  96. data/vendor/gitlab.com/libtiff/libtiff/contrib/iptcutil/.cvsignore +5 -0
  97. data/vendor/gitlab.com/libtiff/libtiff/contrib/iptcutil/CMakeLists.txt +35 -0
  98. data/vendor/gitlab.com/libtiff/libtiff/contrib/iptcutil/Makefile.am +40 -0
  99. data/vendor/gitlab.com/libtiff/libtiff/contrib/iptcutil/Makefile.in +650 -0
  100. data/vendor/gitlab.com/libtiff/libtiff/contrib/iptcutil/README +25 -0
  101. data/vendor/gitlab.com/libtiff/libtiff/contrib/iptcutil/iptcutil.c +954 -0
  102. data/vendor/gitlab.com/libtiff/libtiff/contrib/iptcutil/test.iptc +0 -0
  103. data/vendor/gitlab.com/libtiff/libtiff/contrib/iptcutil/test.txt +32 -0
  104. data/vendor/gitlab.com/libtiff/libtiff/contrib/mfs/.cvsignore +2 -0
  105. data/vendor/gitlab.com/libtiff/libtiff/contrib/mfs/CMakeLists.txt +27 -0
  106. data/vendor/gitlab.com/libtiff/libtiff/contrib/mfs/Makefile.am +29 -0
  107. data/vendor/gitlab.com/libtiff/libtiff/contrib/mfs/Makefile.in +499 -0
  108. data/vendor/gitlab.com/libtiff/libtiff/contrib/mfs/README +37 -0
  109. data/vendor/gitlab.com/libtiff/libtiff/contrib/mfs/mfs_file.c +586 -0
  110. data/vendor/gitlab.com/libtiff/libtiff/contrib/pds/.cvsignore +2 -0
  111. data/vendor/gitlab.com/libtiff/libtiff/contrib/pds/CMakeLists.txt +30 -0
  112. data/vendor/gitlab.com/libtiff/libtiff/contrib/pds/Makefile.am +32 -0
  113. data/vendor/gitlab.com/libtiff/libtiff/contrib/pds/Makefile.in +502 -0
  114. data/vendor/gitlab.com/libtiff/libtiff/contrib/pds/README +90 -0
  115. data/vendor/gitlab.com/libtiff/libtiff/contrib/pds/tif_imageiter.c +525 -0
  116. data/vendor/gitlab.com/libtiff/libtiff/contrib/pds/tif_imageiter.h +64 -0
  117. data/vendor/gitlab.com/libtiff/libtiff/contrib/pds/tif_pdsdirread.c +1131 -0
  118. data/vendor/gitlab.com/libtiff/libtiff/contrib/pds/tif_pdsdirwrite.c +971 -0
  119. data/vendor/gitlab.com/libtiff/libtiff/contrib/ras/.cvsignore +2 -0
  120. data/vendor/gitlab.com/libtiff/libtiff/contrib/ras/CMakeLists.txt +28 -0
  121. data/vendor/gitlab.com/libtiff/libtiff/contrib/ras/Makefile.am +30 -0
  122. data/vendor/gitlab.com/libtiff/libtiff/contrib/ras/Makefile.in +500 -0
  123. data/vendor/gitlab.com/libtiff/libtiff/contrib/ras/README +10 -0
  124. data/vendor/gitlab.com/libtiff/libtiff/contrib/ras/ras2tif.c +254 -0
  125. data/vendor/gitlab.com/libtiff/libtiff/contrib/ras/tif2ras.c +344 -0
  126. data/vendor/gitlab.com/libtiff/libtiff/contrib/stream/.cvsignore +2 -0
  127. data/vendor/gitlab.com/libtiff/libtiff/contrib/stream/CMakeLists.txt +28 -0
  128. data/vendor/gitlab.com/libtiff/libtiff/contrib/stream/Makefile.am +30 -0
  129. data/vendor/gitlab.com/libtiff/libtiff/contrib/stream/Makefile.in +500 -0
  130. data/vendor/gitlab.com/libtiff/libtiff/contrib/stream/README +30 -0
  131. data/vendor/gitlab.com/libtiff/libtiff/contrib/stream/tiffstream.cpp +238 -0
  132. data/vendor/gitlab.com/libtiff/libtiff/contrib/stream/tiffstream.h +70 -0
  133. data/vendor/gitlab.com/libtiff/libtiff/contrib/tags/.cvsignore +2 -0
  134. data/vendor/gitlab.com/libtiff/libtiff/contrib/tags/CMakeLists.txt +32 -0
  135. data/vendor/gitlab.com/libtiff/libtiff/contrib/tags/Makefile.am +33 -0
  136. data/vendor/gitlab.com/libtiff/libtiff/contrib/tags/Makefile.in +503 -0
  137. data/vendor/gitlab.com/libtiff/libtiff/contrib/tags/README +132 -0
  138. data/vendor/gitlab.com/libtiff/libtiff/contrib/tags/listtif.c +39 -0
  139. data/vendor/gitlab.com/libtiff/libtiff/contrib/tags/maketif.c +77 -0
  140. data/vendor/gitlab.com/libtiff/libtiff/contrib/tags/xtif_dir.c +350 -0
  141. data/vendor/gitlab.com/libtiff/libtiff/contrib/tags/xtiffio.h +59 -0
  142. data/vendor/gitlab.com/libtiff/libtiff/contrib/tags/xtiffiop.h +72 -0
  143. data/vendor/gitlab.com/libtiff/libtiff/contrib/win_dib/.cvsignore +2 -0
  144. data/vendor/gitlab.com/libtiff/libtiff/contrib/win_dib/CMakeLists.txt +30 -0
  145. data/vendor/gitlab.com/libtiff/libtiff/contrib/win_dib/Makefile.am +32 -0
  146. data/vendor/gitlab.com/libtiff/libtiff/contrib/win_dib/Makefile.in +502 -0
  147. data/vendor/gitlab.com/libtiff/libtiff/contrib/win_dib/Makefile.w95 +134 -0
  148. data/vendor/gitlab.com/libtiff/libtiff/contrib/win_dib/README.Tiffile +31 -0
  149. data/vendor/gitlab.com/libtiff/libtiff/contrib/win_dib/README.tiff2dib +51 -0
  150. data/vendor/gitlab.com/libtiff/libtiff/contrib/win_dib/Tiffile.cpp +449 -0
  151. data/vendor/gitlab.com/libtiff/libtiff/contrib/win_dib/tiff2dib.c +379 -0
  152. data/vendor/gitlab.com/libtiff/libtiff/html/.cvsignore +5 -0
  153. data/vendor/gitlab.com/libtiff/libtiff/html/BigTIFFProposal.html +99 -0
  154. data/vendor/gitlab.com/libtiff/libtiff/html/CMakeLists.txt +87 -0
  155. data/vendor/gitlab.com/libtiff/libtiff/html/Makefile.am +96 -0
  156. data/vendor/gitlab.com/libtiff/libtiff/html/Makefile.in +798 -0
  157. data/vendor/gitlab.com/libtiff/libtiff/html/TIFFTechNote2.html +707 -0
  158. data/vendor/gitlab.com/libtiff/libtiff/html/addingtags.html +292 -0
  159. data/vendor/gitlab.com/libtiff/libtiff/html/bigtiffdesign.html +80 -0
  160. data/vendor/gitlab.com/libtiff/libtiff/html/bigtiffpr.html +77 -0
  161. data/vendor/gitlab.com/libtiff/libtiff/html/bigtiffpr_images/esri.png +0 -0
  162. data/vendor/gitlab.com/libtiff/libtiff/html/bigtiffpr_images/leica.png +0 -0
  163. data/vendor/gitlab.com/libtiff/libtiff/html/bigtiffpr_images/safe.png +0 -0
  164. data/vendor/gitlab.com/libtiff/libtiff/html/bigtiffpr_images/weogeo.png +0 -0
  165. data/vendor/gitlab.com/libtiff/libtiff/html/bugs.html +61 -0
  166. data/vendor/gitlab.com/libtiff/libtiff/html/build.html +737 -0
  167. data/vendor/gitlab.com/libtiff/libtiff/html/contrib.html +209 -0
  168. data/vendor/gitlab.com/libtiff/libtiff/html/document.html +52 -0
  169. data/vendor/gitlab.com/libtiff/libtiff/html/images.html +41 -0
  170. data/vendor/gitlab.com/libtiff/libtiff/html/images/.cvsignore +2 -0
  171. data/vendor/gitlab.com/libtiff/libtiff/html/images/CMakeLists.txt +46 -0
  172. data/vendor/gitlab.com/libtiff/libtiff/html/images/Makefile.am +49 -0
  173. data/vendor/gitlab.com/libtiff/libtiff/html/images/Makefile.in +572 -0
  174. data/vendor/gitlab.com/libtiff/libtiff/html/images/back.gif +0 -0
  175. data/vendor/gitlab.com/libtiff/libtiff/html/images/bali.jpg +0 -0
  176. data/vendor/gitlab.com/libtiff/libtiff/html/images/cat.gif +0 -0
  177. data/vendor/gitlab.com/libtiff/libtiff/html/images/cover.jpg +0 -0
  178. data/vendor/gitlab.com/libtiff/libtiff/html/images/cramps.gif +0 -0
  179. data/vendor/gitlab.com/libtiff/libtiff/html/images/dave.gif +0 -0
  180. data/vendor/gitlab.com/libtiff/libtiff/html/images/info.gif +0 -0
  181. data/vendor/gitlab.com/libtiff/libtiff/html/images/jello.jpg +0 -0
  182. data/vendor/gitlab.com/libtiff/libtiff/html/images/jim.gif +0 -0
  183. data/vendor/gitlab.com/libtiff/libtiff/html/images/note.gif +0 -0
  184. data/vendor/gitlab.com/libtiff/libtiff/html/images/oxford.gif +0 -0
  185. data/vendor/gitlab.com/libtiff/libtiff/html/images/quad.jpg +0 -0
  186. data/vendor/gitlab.com/libtiff/libtiff/html/images/ring.gif +0 -0
  187. data/vendor/gitlab.com/libtiff/libtiff/html/images/smallliz.jpg +0 -0
  188. data/vendor/gitlab.com/libtiff/libtiff/html/images/strike.gif +0 -0
  189. data/vendor/gitlab.com/libtiff/libtiff/html/images/warning.gif +0 -0
  190. data/vendor/gitlab.com/libtiff/libtiff/html/index.html +122 -0
  191. data/vendor/gitlab.com/libtiff/libtiff/html/internals.html +572 -0
  192. data/vendor/gitlab.com/libtiff/libtiff/html/intro.html +68 -0
  193. data/vendor/gitlab.com/libtiff/libtiff/html/libtiff.html +747 -0
  194. data/vendor/gitlab.com/libtiff/libtiff/html/man/.cvsignore +2 -0
  195. data/vendor/gitlab.com/libtiff/libtiff/html/man/CMakeLists.txt +108 -0
  196. data/vendor/gitlab.com/libtiff/libtiff/html/man/HtmlDoc.cmake +50 -0
  197. data/vendor/gitlab.com/libtiff/libtiff/html/man/Makefile.am +122 -0
  198. data/vendor/gitlab.com/libtiff/libtiff/html/man/Makefile.in +642 -0
  199. data/vendor/gitlab.com/libtiff/libtiff/html/man/TIFFClose.3tiff.html +87 -0
  200. data/vendor/gitlab.com/libtiff/libtiff/html/man/TIFFDataWidth.3tiff.html +98 -0
  201. data/vendor/gitlab.com/libtiff/libtiff/html/man/TIFFError.3tiff.html +106 -0
  202. data/vendor/gitlab.com/libtiff/libtiff/html/man/TIFFFieldDataType.3tiff.html +89 -0
  203. data/vendor/gitlab.com/libtiff/libtiff/html/man/TIFFFieldName.3tiff.html +86 -0
  204. data/vendor/gitlab.com/libtiff/libtiff/html/man/TIFFFieldPassCount.3tiff.html +98 -0
  205. data/vendor/gitlab.com/libtiff/libtiff/html/man/TIFFFieldReadCount.3tiff.html +101 -0
  206. data/vendor/gitlab.com/libtiff/libtiff/html/man/TIFFFieldTag.3tiff.html +88 -0
  207. data/vendor/gitlab.com/libtiff/libtiff/html/man/TIFFFieldWriteCount.3tiff.html +108 -0
  208. data/vendor/gitlab.com/libtiff/libtiff/html/man/TIFFFlush.3tiff.html +113 -0
  209. data/vendor/gitlab.com/libtiff/libtiff/html/man/TIFFGetField.3tiff.html +1969 -0
  210. data/vendor/gitlab.com/libtiff/libtiff/html/man/TIFFOpen.3tiff.html +421 -0
  211. data/vendor/gitlab.com/libtiff/libtiff/html/man/TIFFPrintDirectory.3tiff.html +225 -0
  212. data/vendor/gitlab.com/libtiff/libtiff/html/man/TIFFRGBAImage.3tiff.html +319 -0
  213. data/vendor/gitlab.com/libtiff/libtiff/html/man/TIFFReadDirectory.3tiff.html +218 -0
  214. data/vendor/gitlab.com/libtiff/libtiff/html/man/TIFFReadEncodedStrip.3tiff.html +133 -0
  215. data/vendor/gitlab.com/libtiff/libtiff/html/man/TIFFReadEncodedTile.3tiff.html +130 -0
  216. data/vendor/gitlab.com/libtiff/libtiff/html/man/TIFFReadRGBAImage.3tiff.html +301 -0
  217. data/vendor/gitlab.com/libtiff/libtiff/html/man/TIFFReadRGBAStrip.3tiff.html +208 -0
  218. data/vendor/gitlab.com/libtiff/libtiff/html/man/TIFFReadRGBATile.3tiff.html +261 -0
  219. data/vendor/gitlab.com/libtiff/libtiff/html/man/TIFFReadRawStrip.3tiff.html +109 -0
  220. data/vendor/gitlab.com/libtiff/libtiff/html/man/TIFFReadRawTile.3tiff.html +111 -0
  221. data/vendor/gitlab.com/libtiff/libtiff/html/man/TIFFReadScanline.3tiff.html +157 -0
  222. data/vendor/gitlab.com/libtiff/libtiff/html/man/TIFFReadTile.3tiff.html +133 -0
  223. data/vendor/gitlab.com/libtiff/libtiff/html/man/TIFFSetDirectory.3tiff.html +122 -0
  224. data/vendor/gitlab.com/libtiff/libtiff/html/man/TIFFSetField.3tiff.html +1865 -0
  225. data/vendor/gitlab.com/libtiff/libtiff/html/man/TIFFWarning.3tiff.html +108 -0
  226. data/vendor/gitlab.com/libtiff/libtiff/html/man/TIFFWriteDirectory.3tiff.html +176 -0
  227. data/vendor/gitlab.com/libtiff/libtiff/html/man/TIFFWriteEncodedStrip.3tiff.html +153 -0
  228. data/vendor/gitlab.com/libtiff/libtiff/html/man/TIFFWriteEncodedTile.3tiff.html +147 -0
  229. data/vendor/gitlab.com/libtiff/libtiff/html/man/TIFFWriteRawStrip.3tiff.html +144 -0
  230. data/vendor/gitlab.com/libtiff/libtiff/html/man/TIFFWriteRawTile.3tiff.html +128 -0
  231. data/vendor/gitlab.com/libtiff/libtiff/html/man/TIFFWriteScanline.3tiff.html +206 -0
  232. data/vendor/gitlab.com/libtiff/libtiff/html/man/TIFFWriteTile.3tiff.html +115 -0
  233. data/vendor/gitlab.com/libtiff/libtiff/html/man/TIFFbuffer.3tiff.html +116 -0
  234. data/vendor/gitlab.com/libtiff/libtiff/html/man/TIFFcodec.3tiff.html +116 -0
  235. data/vendor/gitlab.com/libtiff/libtiff/html/man/TIFFcolor.3tiff.html +975 -0
  236. data/vendor/gitlab.com/libtiff/libtiff/html/man/TIFFmemory.3tiff.html +110 -0
  237. data/vendor/gitlab.com/libtiff/libtiff/html/man/TIFFquery.3tiff.html +148 -0
  238. data/vendor/gitlab.com/libtiff/libtiff/html/man/TIFFsize.3tiff.html +95 -0
  239. data/vendor/gitlab.com/libtiff/libtiff/html/man/TIFFstrip.3tiff.html +129 -0
  240. data/vendor/gitlab.com/libtiff/libtiff/html/man/TIFFswab.3tiff.html +110 -0
  241. data/vendor/gitlab.com/libtiff/libtiff/html/man/TIFFtile.3tiff.html +141 -0
  242. data/vendor/gitlab.com/libtiff/libtiff/html/man/fax2ps.1.html +252 -0
  243. data/vendor/gitlab.com/libtiff/libtiff/html/man/fax2tiff.1.html +607 -0
  244. data/vendor/gitlab.com/libtiff/libtiff/html/man/index.html +64 -0
  245. data/vendor/gitlab.com/libtiff/libtiff/html/man/libtiff.3tiff.html +1150 -0
  246. data/vendor/gitlab.com/libtiff/libtiff/html/man/pal2rgb.1.html +189 -0
  247. data/vendor/gitlab.com/libtiff/libtiff/html/man/ppm2tiff.1.html +141 -0
  248. data/vendor/gitlab.com/libtiff/libtiff/html/man/raw2tiff.1.html +510 -0
  249. data/vendor/gitlab.com/libtiff/libtiff/html/man/rgb2ycbcr.1.html +155 -0
  250. data/vendor/gitlab.com/libtiff/libtiff/html/man/thumbnail.1.html +148 -0
  251. data/vendor/gitlab.com/libtiff/libtiff/html/man/tiff2bw.1.html +161 -0
  252. data/vendor/gitlab.com/libtiff/libtiff/html/man/tiff2pdf.1.html +609 -0
  253. data/vendor/gitlab.com/libtiff/libtiff/html/man/tiff2ps.1.html +639 -0
  254. data/vendor/gitlab.com/libtiff/libtiff/html/man/tiff2rgba.1.html +162 -0
  255. data/vendor/gitlab.com/libtiff/libtiff/html/man/tiffcmp.1.html +156 -0
  256. data/vendor/gitlab.com/libtiff/libtiff/html/man/tiffcp.1.html +569 -0
  257. data/vendor/gitlab.com/libtiff/libtiff/html/man/tiffcrop.1.html +684 -0
  258. data/vendor/gitlab.com/libtiff/libtiff/html/man/tiffdither.1.html +196 -0
  259. data/vendor/gitlab.com/libtiff/libtiff/html/man/tiffdump.1.html +145 -0
  260. data/vendor/gitlab.com/libtiff/libtiff/html/man/tiffgt.1.html +551 -0
  261. data/vendor/gitlab.com/libtiff/libtiff/html/man/tiffinfo.1.html +196 -0
  262. data/vendor/gitlab.com/libtiff/libtiff/html/man/tiffmedian.1.html +183 -0
  263. data/vendor/gitlab.com/libtiff/libtiff/html/man/tiffset.1.html +176 -0
  264. data/vendor/gitlab.com/libtiff/libtiff/html/man/tiffsplit.1.html +102 -0
  265. data/vendor/gitlab.com/libtiff/libtiff/html/misc.html +117 -0
  266. data/vendor/gitlab.com/libtiff/libtiff/html/support.html +655 -0
  267. data/vendor/gitlab.com/libtiff/libtiff/html/tools.html +137 -0
  268. data/vendor/gitlab.com/libtiff/libtiff/html/v3.4beta007.html +112 -0
  269. data/vendor/gitlab.com/libtiff/libtiff/html/v3.4beta016.html +122 -0
  270. data/vendor/gitlab.com/libtiff/libtiff/html/v3.4beta018.html +84 -0
  271. data/vendor/gitlab.com/libtiff/libtiff/html/v3.4beta024.html +139 -0
  272. data/vendor/gitlab.com/libtiff/libtiff/html/v3.4beta028.html +146 -0
  273. data/vendor/gitlab.com/libtiff/libtiff/html/v3.4beta029.html +86 -0
  274. data/vendor/gitlab.com/libtiff/libtiff/html/v3.4beta031.html +94 -0
  275. data/vendor/gitlab.com/libtiff/libtiff/html/v3.4beta032.html +90 -0
  276. data/vendor/gitlab.com/libtiff/libtiff/html/v3.4beta033.html +82 -0
  277. data/vendor/gitlab.com/libtiff/libtiff/html/v3.4beta034.html +68 -0
  278. data/vendor/gitlab.com/libtiff/libtiff/html/v3.4beta035.html +63 -0
  279. data/vendor/gitlab.com/libtiff/libtiff/html/v3.4beta036.html +117 -0
  280. data/vendor/gitlab.com/libtiff/libtiff/html/v3.5.1.html +75 -0
  281. data/vendor/gitlab.com/libtiff/libtiff/html/v3.5.2.html +108 -0
  282. data/vendor/gitlab.com/libtiff/libtiff/html/v3.5.3.html +132 -0
  283. data/vendor/gitlab.com/libtiff/libtiff/html/v3.5.4.html +88 -0
  284. data/vendor/gitlab.com/libtiff/libtiff/html/v3.5.5.html +155 -0
  285. data/vendor/gitlab.com/libtiff/libtiff/html/v3.5.6-beta.html +185 -0
  286. data/vendor/gitlab.com/libtiff/libtiff/html/v3.5.7.html +259 -0
  287. data/vendor/gitlab.com/libtiff/libtiff/html/v3.6.0.html +434 -0
  288. data/vendor/gitlab.com/libtiff/libtiff/html/v3.6.1.html +199 -0
  289. data/vendor/gitlab.com/libtiff/libtiff/html/v3.7.0.html +144 -0
  290. data/vendor/gitlab.com/libtiff/libtiff/html/v3.7.0alpha.html +249 -0
  291. data/vendor/gitlab.com/libtiff/libtiff/html/v3.7.0beta.html +162 -0
  292. data/vendor/gitlab.com/libtiff/libtiff/html/v3.7.0beta2.html +131 -0
  293. data/vendor/gitlab.com/libtiff/libtiff/html/v3.7.1.html +233 -0
  294. data/vendor/gitlab.com/libtiff/libtiff/html/v3.7.2.html +222 -0
  295. data/vendor/gitlab.com/libtiff/libtiff/html/v3.7.3.html +230 -0
  296. data/vendor/gitlab.com/libtiff/libtiff/html/v3.7.4.html +133 -0
  297. data/vendor/gitlab.com/libtiff/libtiff/html/v3.8.0.html +199 -0
  298. data/vendor/gitlab.com/libtiff/libtiff/html/v3.8.1.html +217 -0
  299. data/vendor/gitlab.com/libtiff/libtiff/html/v3.8.2.html +137 -0
  300. data/vendor/gitlab.com/libtiff/libtiff/html/v3.9.0.html +261 -0
  301. data/vendor/gitlab.com/libtiff/libtiff/html/v3.9.0beta.html +304 -0
  302. data/vendor/gitlab.com/libtiff/libtiff/html/v3.9.1.html +115 -0
  303. data/vendor/gitlab.com/libtiff/libtiff/html/v3.9.2.html +122 -0
  304. data/vendor/gitlab.com/libtiff/libtiff/html/v3.9.3.html +160 -0
  305. data/vendor/gitlab.com/libtiff/libtiff/html/v3.9.4.html +125 -0
  306. data/vendor/gitlab.com/libtiff/libtiff/html/v3.9.5.html +270 -0
  307. data/vendor/gitlab.com/libtiff/libtiff/html/v4.0.0.html +269 -0
  308. data/vendor/gitlab.com/libtiff/libtiff/html/v4.0.1.html +113 -0
  309. data/vendor/gitlab.com/libtiff/libtiff/html/v4.0.2.html +118 -0
  310. data/vendor/gitlab.com/libtiff/libtiff/html/v4.0.3.html +125 -0
  311. data/vendor/gitlab.com/libtiff/libtiff/html/v4.0.4.html +274 -0
  312. data/vendor/gitlab.com/libtiff/libtiff/html/v4.0.4beta.html +291 -0
  313. data/vendor/gitlab.com/libtiff/libtiff/html/v4.0.5.html +148 -0
  314. data/vendor/gitlab.com/libtiff/libtiff/html/v4.0.6.html +139 -0
  315. data/vendor/gitlab.com/libtiff/libtiff/html/v4.0.7.html +411 -0
  316. data/vendor/gitlab.com/libtiff/libtiff/html/v4.0.8.html +445 -0
  317. data/vendor/gitlab.com/libtiff/libtiff/html/v4.0.9.html +373 -0
  318. data/vendor/gitlab.com/libtiff/libtiff/libtiff-4.pc.in +11 -0
  319. data/vendor/gitlab.com/libtiff/libtiff/libtiff/.cvsignore +22 -0
  320. data/vendor/gitlab.com/libtiff/libtiff/libtiff/CMakeLists.txt +165 -0
  321. data/vendor/gitlab.com/libtiff/libtiff/libtiff/Makefile.am +154 -0
  322. data/vendor/gitlab.com/libtiff/libtiff/libtiff/Makefile.in +966 -0
  323. data/vendor/gitlab.com/libtiff/libtiff/libtiff/Makefile.lcc +129 -0
  324. data/vendor/gitlab.com/libtiff/libtiff/libtiff/Makefile.vc +102 -0
  325. data/vendor/gitlab.com/libtiff/libtiff/libtiff/SConstruct +73 -0
  326. data/vendor/gitlab.com/libtiff/libtiff/libtiff/libtiff.def +168 -0
  327. data/vendor/gitlab.com/libtiff/libtiff/libtiff/libtiff.map +4 -0
  328. data/vendor/gitlab.com/libtiff/libtiff/libtiff/libtiffxx.map +4 -0
  329. data/vendor/gitlab.com/libtiff/libtiff/libtiff/mkg3states.c +454 -0
  330. data/vendor/gitlab.com/libtiff/libtiff/libtiff/mkspans.c +82 -0
  331. data/vendor/gitlab.com/libtiff/libtiff/libtiff/t4.h +292 -0
  332. data/vendor/gitlab.com/libtiff/libtiff/libtiff/tif_aux.c +376 -0
  333. data/vendor/gitlab.com/libtiff/libtiff/libtiff/tif_close.c +140 -0
  334. data/vendor/gitlab.com/libtiff/libtiff/libtiff/tif_codec.c +165 -0
  335. data/vendor/gitlab.com/libtiff/libtiff/libtiff/tif_color.c +309 -0
  336. data/vendor/gitlab.com/libtiff/libtiff/libtiff/tif_compress.c +304 -0
  337. data/vendor/gitlab.com/libtiff/libtiff/libtiff/tif_config.h-vms +46 -0
  338. data/vendor/gitlab.com/libtiff/libtiff/libtiff/tif_config.h.cmake.in +261 -0
  339. data/vendor/gitlab.com/libtiff/libtiff/libtiff/tif_config.h.in +410 -0
  340. data/vendor/gitlab.com/libtiff/libtiff/libtiff/tif_config.vc.h +137 -0
  341. data/vendor/gitlab.com/libtiff/libtiff/libtiff/tif_config.wince.h +71 -0
  342. data/vendor/gitlab.com/libtiff/libtiff/libtiff/tif_dir.c +1767 -0
  343. data/vendor/gitlab.com/libtiff/libtiff/libtiff/tif_dir.h +309 -0
  344. data/vendor/gitlab.com/libtiff/libtiff/libtiff/tif_dirinfo.c +1070 -0
  345. data/vendor/gitlab.com/libtiff/libtiff/libtiff/tif_dirread.c +5803 -0
  346. data/vendor/gitlab.com/libtiff/libtiff/libtiff/tif_dirwrite.c +3024 -0
  347. data/vendor/gitlab.com/libtiff/libtiff/libtiff/tif_dumpmode.c +143 -0
  348. data/vendor/gitlab.com/libtiff/libtiff/libtiff/tif_error.c +88 -0
  349. data/vendor/gitlab.com/libtiff/libtiff/libtiff/tif_extension.c +118 -0
  350. data/vendor/gitlab.com/libtiff/libtiff/libtiff/tif_fax3.c +1648 -0
  351. data/vendor/gitlab.com/libtiff/libtiff/libtiff/tif_fax3.h +540 -0
  352. data/vendor/gitlab.com/libtiff/libtiff/libtiff/tif_fax3sm.c +1260 -0
  353. data/vendor/gitlab.com/libtiff/libtiff/libtiff/tif_flush.c +118 -0
  354. data/vendor/gitlab.com/libtiff/libtiff/libtiff/tif_getimage.c +3048 -0
  355. data/vendor/gitlab.com/libtiff/libtiff/libtiff/tif_jbig.c +214 -0
  356. data/vendor/gitlab.com/libtiff/libtiff/libtiff/tif_jpeg.c +2601 -0
  357. data/vendor/gitlab.com/libtiff/libtiff/libtiff/tif_jpeg_12.c +69 -0
  358. data/vendor/gitlab.com/libtiff/libtiff/libtiff/tif_luv.c +1765 -0
  359. data/vendor/gitlab.com/libtiff/libtiff/libtiff/tif_lzma.c +495 -0
  360. data/vendor/gitlab.com/libtiff/libtiff/libtiff/tif_lzw.c +1218 -0
  361. data/vendor/gitlab.com/libtiff/libtiff/libtiff/tif_next.c +189 -0
  362. data/vendor/gitlab.com/libtiff/libtiff/libtiff/tif_ojpeg.c +2563 -0
  363. data/vendor/gitlab.com/libtiff/libtiff/libtiff/tif_open.c +725 -0
  364. data/vendor/gitlab.com/libtiff/libtiff/libtiff/tif_packbits.c +311 -0
  365. data/vendor/gitlab.com/libtiff/libtiff/libtiff/tif_pixarlog.c +1485 -0
  366. data/vendor/gitlab.com/libtiff/libtiff/libtiff/tif_predict.c +881 -0
  367. data/vendor/gitlab.com/libtiff/libtiff/libtiff/tif_predict.h +79 -0
  368. data/vendor/gitlab.com/libtiff/libtiff/libtiff/tif_print.c +722 -0
  369. data/vendor/gitlab.com/libtiff/libtiff/libtiff/tif_read.c +1572 -0
  370. data/vendor/gitlab.com/libtiff/libtiff/libtiff/tif_stream.cxx +430 -0
  371. data/vendor/gitlab.com/libtiff/libtiff/libtiff/tif_strip.c +389 -0
  372. data/vendor/gitlab.com/libtiff/libtiff/libtiff/tif_swab.c +312 -0
  373. data/vendor/gitlab.com/libtiff/libtiff/libtiff/tif_thunder.c +208 -0
  374. data/vendor/gitlab.com/libtiff/libtiff/libtiff/tif_tile.c +322 -0
  375. data/vendor/gitlab.com/libtiff/libtiff/libtiff/tif_unix.c +386 -0
  376. data/vendor/gitlab.com/libtiff/libtiff/libtiff/tif_version.c +40 -0
  377. data/vendor/gitlab.com/libtiff/libtiff/libtiff/tif_vms.c +611 -0
  378. data/vendor/gitlab.com/libtiff/libtiff/libtiff/tif_warning.c +89 -0
  379. data/vendor/gitlab.com/libtiff/libtiff/libtiff/tif_win32.c +476 -0
  380. data/vendor/gitlab.com/libtiff/libtiff/libtiff/tif_wince.c +293 -0
  381. data/vendor/gitlab.com/libtiff/libtiff/libtiff/tif_write.c +834 -0
  382. data/vendor/gitlab.com/libtiff/libtiff/libtiff/tif_zip.c +476 -0
  383. data/vendor/gitlab.com/libtiff/libtiff/libtiff/tiff.h +681 -0
  384. data/vendor/gitlab.com/libtiff/libtiff/libtiff/tiffconf.h-vms +99 -0
  385. data/vendor/gitlab.com/libtiff/libtiff/libtiff/tiffconf.h.cmake.in +130 -0
  386. data/vendor/gitlab.com/libtiff/libtiff/libtiff/tiffconf.h.in +127 -0
  387. data/vendor/gitlab.com/libtiff/libtiff/libtiff/tiffconf.vc.h +161 -0
  388. data/vendor/gitlab.com/libtiff/libtiff/libtiff/tiffconf.wince.h +121 -0
  389. data/vendor/gitlab.com/libtiff/libtiff/libtiff/tiffio.h +560 -0
  390. data/vendor/gitlab.com/libtiff/libtiff/libtiff/tiffio.hxx +49 -0
  391. data/vendor/gitlab.com/libtiff/libtiff/libtiff/tiffiop.h +445 -0
  392. data/vendor/gitlab.com/libtiff/libtiff/libtiff/tiffvers.h +9 -0
  393. data/vendor/gitlab.com/libtiff/libtiff/libtiff/tiffvers.h.in +9 -0
  394. data/vendor/gitlab.com/libtiff/libtiff/libtiff/uvcode.h +180 -0
  395. data/vendor/gitlab.com/libtiff/libtiff/m4/acinclude.m4 +851 -0
  396. data/vendor/gitlab.com/libtiff/libtiff/m4/ice_find_athena.m4 +187 -0
  397. data/vendor/gitlab.com/libtiff/libtiff/m4/libtool.m4 +8388 -0
  398. data/vendor/gitlab.com/libtiff/libtiff/m4/ltoptions.m4 +437 -0
  399. data/vendor/gitlab.com/libtiff/libtiff/m4/ltsugar.m4 +124 -0
  400. data/vendor/gitlab.com/libtiff/libtiff/m4/ltversion.m4 +23 -0
  401. data/vendor/gitlab.com/libtiff/libtiff/m4/lt~obsolete.m4 +99 -0
  402. data/vendor/gitlab.com/libtiff/libtiff/man/.cvsignore +3 -0
  403. data/vendor/gitlab.com/libtiff/libtiff/man/CMakeLists.txt +97 -0
  404. data/vendor/gitlab.com/libtiff/libtiff/man/Makefile.am +94 -0
  405. data/vendor/gitlab.com/libtiff/libtiff/man/Makefile.in +684 -0
  406. data/vendor/gitlab.com/libtiff/libtiff/man/TIFFClose.3tiff +53 -0
  407. data/vendor/gitlab.com/libtiff/libtiff/man/TIFFDataWidth.3tiff +74 -0
  408. data/vendor/gitlab.com/libtiff/libtiff/man/TIFFError.3tiff +69 -0
  409. data/vendor/gitlab.com/libtiff/libtiff/man/TIFFFieldDataType.3tiff +53 -0
  410. data/vendor/gitlab.com/libtiff/libtiff/man/TIFFFieldName.3tiff +52 -0
  411. data/vendor/gitlab.com/libtiff/libtiff/man/TIFFFieldPassCount.3tiff +73 -0
  412. data/vendor/gitlab.com/libtiff/libtiff/man/TIFFFieldReadCount.3tiff +77 -0
  413. data/vendor/gitlab.com/libtiff/libtiff/man/TIFFFieldTag.3tiff +56 -0
  414. data/vendor/gitlab.com/libtiff/libtiff/man/TIFFFieldWriteCount.3tiff +88 -0
  415. data/vendor/gitlab.com/libtiff/libtiff/man/TIFFFlush.3tiff +64 -0
  416. data/vendor/gitlab.com/libtiff/libtiff/man/TIFFGetField.3tiff +229 -0
  417. data/vendor/gitlab.com/libtiff/libtiff/man/TIFFOpen.3tiff +279 -0
  418. data/vendor/gitlab.com/libtiff/libtiff/man/TIFFPrintDirectory.3tiff +70 -0
  419. data/vendor/gitlab.com/libtiff/libtiff/man/TIFFRGBAImage.3tiff +286 -0
  420. data/vendor/gitlab.com/libtiff/libtiff/man/TIFFReadDirectory.3tiff +164 -0
  421. data/vendor/gitlab.com/libtiff/libtiff/man/TIFFReadEncodedStrip.3tiff +78 -0
  422. data/vendor/gitlab.com/libtiff/libtiff/man/TIFFReadEncodedTile.3tiff +76 -0
  423. data/vendor/gitlab.com/libtiff/libtiff/man/TIFFReadRGBAImage.3tiff +218 -0
  424. data/vendor/gitlab.com/libtiff/libtiff/man/TIFFReadRGBAStrip.3tiff +170 -0
  425. data/vendor/gitlab.com/libtiff/libtiff/man/TIFFReadRGBATile.3tiff +171 -0
  426. data/vendor/gitlab.com/libtiff/libtiff/man/TIFFReadRawStrip.3tiff +64 -0
  427. data/vendor/gitlab.com/libtiff/libtiff/man/TIFFReadRawTile.3tiff +65 -0
  428. data/vendor/gitlab.com/libtiff/libtiff/man/TIFFReadScanline.3tiff +94 -0
  429. data/vendor/gitlab.com/libtiff/libtiff/man/TIFFReadTile.3tiff +84 -0
  430. data/vendor/gitlab.com/libtiff/libtiff/man/TIFFSetDirectory.3tiff +79 -0
  431. data/vendor/gitlab.com/libtiff/libtiff/man/TIFFSetField.3tiff +217 -0
  432. data/vendor/gitlab.com/libtiff/libtiff/man/TIFFWarning.3tiff +70 -0
  433. data/vendor/gitlab.com/libtiff/libtiff/man/TIFFWriteDirectory.3tiff +138 -0
  434. data/vendor/gitlab.com/libtiff/libtiff/man/TIFFWriteEncodedStrip.3tiff +102 -0
  435. data/vendor/gitlab.com/libtiff/libtiff/man/TIFFWriteEncodedTile.3tiff +96 -0
  436. data/vendor/gitlab.com/libtiff/libtiff/man/TIFFWriteRawStrip.3tiff +96 -0
  437. data/vendor/gitlab.com/libtiff/libtiff/man/TIFFWriteRawTile.3tiff +84 -0
  438. data/vendor/gitlab.com/libtiff/libtiff/man/TIFFWriteScanline.3tiff +154 -0
  439. data/vendor/gitlab.com/libtiff/libtiff/man/TIFFWriteTile.3tiff +77 -0
  440. data/vendor/gitlab.com/libtiff/libtiff/man/TIFFbuffer.3tiff +77 -0
  441. data/vendor/gitlab.com/libtiff/libtiff/man/TIFFcodec.3tiff +82 -0
  442. data/vendor/gitlab.com/libtiff/libtiff/man/TIFFcolor.3tiff +268 -0
  443. data/vendor/gitlab.com/libtiff/libtiff/man/TIFFmemory.3tiff +90 -0
  444. data/vendor/gitlab.com/libtiff/libtiff/man/TIFFquery.3tiff +142 -0
  445. data/vendor/gitlab.com/libtiff/libtiff/man/TIFFsize.3tiff +59 -0
  446. data/vendor/gitlab.com/libtiff/libtiff/man/TIFFstrip.3tiff +99 -0
  447. data/vendor/gitlab.com/libtiff/libtiff/man/TIFFswab.3tiff +80 -0
  448. data/vendor/gitlab.com/libtiff/libtiff/man/TIFFtile.3tiff +131 -0
  449. data/vendor/gitlab.com/libtiff/libtiff/man/fax2ps.1 +159 -0
  450. data/vendor/gitlab.com/libtiff/libtiff/man/fax2tiff.1 +286 -0
  451. data/vendor/gitlab.com/libtiff/libtiff/man/libtiff.3tiff +545 -0
  452. data/vendor/gitlab.com/libtiff/libtiff/man/pal2rgb.1 +111 -0
  453. data/vendor/gitlab.com/libtiff/libtiff/man/ppm2tiff.1 +105 -0
  454. data/vendor/gitlab.com/libtiff/libtiff/man/raw2tiff.1 +196 -0
  455. data/vendor/gitlab.com/libtiff/libtiff/man/rgb2ycbcr.1 +99 -0
  456. data/vendor/gitlab.com/libtiff/libtiff/man/thumbnail.1 +90 -0
  457. data/vendor/gitlab.com/libtiff/libtiff/man/tiff2bw.1 +94 -0
  458. data/vendor/gitlab.com/libtiff/libtiff/man/tiff2pdf.1 +254 -0
  459. data/vendor/gitlab.com/libtiff/libtiff/man/tiff2ps.1 +294 -0
  460. data/vendor/gitlab.com/libtiff/libtiff/man/tiff2rgba.1 +97 -0
  461. data/vendor/gitlab.com/libtiff/libtiff/man/tiffcmp.1 +87 -0
  462. data/vendor/gitlab.com/libtiff/libtiff/man/tiffcp.1 +317 -0
  463. data/vendor/gitlab.com/libtiff/libtiff/man/tiffcrop.1 +571 -0
  464. data/vendor/gitlab.com/libtiff/libtiff/man/tiffdither.1 +135 -0
  465. data/vendor/gitlab.com/libtiff/libtiff/man/tiffdump.1 +81 -0
  466. data/vendor/gitlab.com/libtiff/libtiff/man/tiffgt.1 +245 -0
  467. data/vendor/gitlab.com/libtiff/libtiff/man/tiffinfo.1 +88 -0
  468. data/vendor/gitlab.com/libtiff/libtiff/man/tiffmedian.1 +112 -0
  469. data/vendor/gitlab.com/libtiff/libtiff/man/tiffset.1 +99 -0
  470. data/vendor/gitlab.com/libtiff/libtiff/man/tiffsplit.1 +69 -0
  471. data/vendor/gitlab.com/libtiff/libtiff/nmake.opt +229 -0
  472. data/vendor/gitlab.com/libtiff/libtiff/port/.cvsignore +7 -0
  473. data/vendor/gitlab.com/libtiff/libtiff/port/CMakeLists.txt +60 -0
  474. data/vendor/gitlab.com/libtiff/libtiff/port/Makefile.am +35 -0
  475. data/vendor/gitlab.com/libtiff/libtiff/port/Makefile.in +656 -0
  476. data/vendor/gitlab.com/libtiff/libtiff/port/Makefile.vc +44 -0
  477. data/vendor/gitlab.com/libtiff/libtiff/port/dummy.c +12 -0
  478. data/vendor/gitlab.com/libtiff/libtiff/port/getopt.c +125 -0
  479. data/vendor/gitlab.com/libtiff/libtiff/port/lfind.c +62 -0
  480. data/vendor/gitlab.com/libtiff/libtiff/port/libport.h +60 -0
  481. data/vendor/gitlab.com/libtiff/libtiff/port/snprintf.c +38 -0
  482. data/vendor/gitlab.com/libtiff/libtiff/port/strcasecmp.c +51 -0
  483. data/vendor/gitlab.com/libtiff/libtiff/port/strtoul.c +109 -0
  484. data/vendor/gitlab.com/libtiff/libtiff/port/strtoull.c +116 -0
  485. data/vendor/gitlab.com/libtiff/libtiff/test/.cvsignore +12 -0
  486. data/vendor/gitlab.com/libtiff/libtiff/test/CMakeLists.txt +382 -0
  487. data/vendor/gitlab.com/libtiff/libtiff/test/Makefile.am +334 -0
  488. data/vendor/gitlab.com/libtiff/libtiff/test/Makefile.in +1987 -0
  489. data/vendor/gitlab.com/libtiff/libtiff/test/TiffSplitTest.cmake +34 -0
  490. data/vendor/gitlab.com/libtiff/libtiff/test/TiffTest.cmake +63 -0
  491. data/vendor/gitlab.com/libtiff/libtiff/test/TiffTestCommon.cmake +108 -0
  492. data/vendor/gitlab.com/libtiff/libtiff/test/ascii_tag.c +177 -0
  493. data/vendor/gitlab.com/libtiff/libtiff/test/check_tag.c +91 -0
  494. data/vendor/gitlab.com/libtiff/libtiff/test/common.sh +122 -0
  495. data/vendor/gitlab.com/libtiff/libtiff/test/custom_dir.c +247 -0
  496. data/vendor/gitlab.com/libtiff/libtiff/test/images/README.txt +29 -0
  497. data/vendor/gitlab.com/libtiff/libtiff/test/images/logluv-3c-16b.tiff +0 -0
  498. data/vendor/gitlab.com/libtiff/libtiff/test/images/minisblack-1c-16b.tiff +0 -0
  499. data/vendor/gitlab.com/libtiff/libtiff/test/images/minisblack-1c-8b.pgm +0 -0
  500. data/vendor/gitlab.com/libtiff/libtiff/test/images/minisblack-1c-8b.tiff +0 -0
  501. data/vendor/gitlab.com/libtiff/libtiff/test/images/minisblack-2c-8b-alpha.tiff +0 -0
  502. data/vendor/gitlab.com/libtiff/libtiff/test/images/miniswhite-1c-1b.pbm +0 -0
  503. data/vendor/gitlab.com/libtiff/libtiff/test/images/miniswhite-1c-1b.tiff +0 -0
  504. data/vendor/gitlab.com/libtiff/libtiff/test/images/palette-1c-1b.tiff +0 -0
  505. data/vendor/gitlab.com/libtiff/libtiff/test/images/palette-1c-4b.tiff +0 -0
  506. data/vendor/gitlab.com/libtiff/libtiff/test/images/palette-1c-8b.tiff +0 -0
  507. data/vendor/gitlab.com/libtiff/libtiff/test/images/quad-lzw-compat.tiff +0 -0
  508. data/vendor/gitlab.com/libtiff/libtiff/test/images/quad-tile.jpg.tiff +0 -0
  509. data/vendor/gitlab.com/libtiff/libtiff/test/images/rgb-3c-16b.tiff +0 -0
  510. data/vendor/gitlab.com/libtiff/libtiff/test/images/rgb-3c-8b.ppm +0 -0
  511. data/vendor/gitlab.com/libtiff/libtiff/test/images/rgb-3c-8b.tiff +0 -0
  512. data/vendor/gitlab.com/libtiff/libtiff/test/long_tag.c +156 -0
  513. data/vendor/gitlab.com/libtiff/libtiff/test/ppm2tiff_pbm.sh +7 -0
  514. data/vendor/gitlab.com/libtiff/libtiff/test/ppm2tiff_pgm.sh +7 -0
  515. data/vendor/gitlab.com/libtiff/libtiff/test/ppm2tiff_ppm.sh +7 -0
  516. data/vendor/gitlab.com/libtiff/libtiff/test/raw_decode.c +304 -0
  517. data/vendor/gitlab.com/libtiff/libtiff/test/rewrite_tag.c +344 -0
  518. data/vendor/gitlab.com/libtiff/libtiff/test/short_tag.c +205 -0
  519. data/vendor/gitlab.com/libtiff/libtiff/test/strip.c +290 -0
  520. data/vendor/gitlab.com/libtiff/libtiff/test/strip_rw.c +157 -0
  521. data/vendor/gitlab.com/libtiff/libtiff/test/test_arrays.c +829 -0
  522. data/vendor/gitlab.com/libtiff/libtiff/test/test_arrays.h +63 -0
  523. data/vendor/gitlab.com/libtiff/libtiff/test/tiff2bw-palette-1c-8b.sh +7 -0
  524. data/vendor/gitlab.com/libtiff/libtiff/test/tiff2bw-quad-lzw-compat.sh +7 -0
  525. data/vendor/gitlab.com/libtiff/libtiff/test/tiff2bw-rgb-3c-8b.sh +7 -0
  526. data/vendor/gitlab.com/libtiff/libtiff/test/tiff2pdf.sh +6 -0
  527. data/vendor/gitlab.com/libtiff/libtiff/test/tiff2ps-EPS1.sh +6 -0
  528. data/vendor/gitlab.com/libtiff/libtiff/test/tiff2ps-PS1.sh +6 -0
  529. data/vendor/gitlab.com/libtiff/libtiff/test/tiff2ps-PS2.sh +6 -0
  530. data/vendor/gitlab.com/libtiff/libtiff/test/tiff2ps-PS3.sh +6 -0
  531. data/vendor/gitlab.com/libtiff/libtiff/test/tiff2rgba-logluv-3c-16b.sh +7 -0
  532. data/vendor/gitlab.com/libtiff/libtiff/test/tiff2rgba-minisblack-1c-16b.sh +7 -0
  533. data/vendor/gitlab.com/libtiff/libtiff/test/tiff2rgba-minisblack-1c-8b.sh +7 -0
  534. data/vendor/gitlab.com/libtiff/libtiff/test/tiff2rgba-minisblack-2c-8b-alpha.sh +7 -0
  535. data/vendor/gitlab.com/libtiff/libtiff/test/tiff2rgba-miniswhite-1c-1b.sh +7 -0
  536. data/vendor/gitlab.com/libtiff/libtiff/test/tiff2rgba-palette-1c-1b.sh +7 -0
  537. data/vendor/gitlab.com/libtiff/libtiff/test/tiff2rgba-palette-1c-4b.sh +7 -0
  538. data/vendor/gitlab.com/libtiff/libtiff/test/tiff2rgba-palette-1c-8b.sh +7 -0
  539. data/vendor/gitlab.com/libtiff/libtiff/test/tiff2rgba-quad-tile.jpg.sh +7 -0
  540. data/vendor/gitlab.com/libtiff/libtiff/test/tiff2rgba-rgb-3c-16b.sh +7 -0
  541. data/vendor/gitlab.com/libtiff/libtiff/test/tiff2rgba-rgb-3c-8b.sh +7 -0
  542. data/vendor/gitlab.com/libtiff/libtiff/test/tiffcp-g3-1d-fill.sh +7 -0
  543. data/vendor/gitlab.com/libtiff/libtiff/test/tiffcp-g3-1d.sh +6 -0
  544. data/vendor/gitlab.com/libtiff/libtiff/test/tiffcp-g3-2d-fill.sh +7 -0
  545. data/vendor/gitlab.com/libtiff/libtiff/test/tiffcp-g3-2d.sh +6 -0
  546. data/vendor/gitlab.com/libtiff/libtiff/test/tiffcp-g3.sh +6 -0
  547. data/vendor/gitlab.com/libtiff/libtiff/test/tiffcp-g4.sh +6 -0
  548. data/vendor/gitlab.com/libtiff/libtiff/test/tiffcp-logluv.sh +7 -0
  549. data/vendor/gitlab.com/libtiff/libtiff/test/tiffcp-lzw-compat.sh +6 -0
  550. data/vendor/gitlab.com/libtiff/libtiff/test/tiffcp-split-join.sh +16 -0
  551. data/vendor/gitlab.com/libtiff/libtiff/test/tiffcp-split.sh +13 -0
  552. data/vendor/gitlab.com/libtiff/libtiff/test/tiffcp-thumbnail.sh +10 -0
  553. data/vendor/gitlab.com/libtiff/libtiff/test/tiffcrop-R90-logluv-3c-16b.sh +7 -0
  554. data/vendor/gitlab.com/libtiff/libtiff/test/tiffcrop-R90-minisblack-1c-16b.sh +7 -0
  555. data/vendor/gitlab.com/libtiff/libtiff/test/tiffcrop-R90-minisblack-1c-8b.sh +7 -0
  556. data/vendor/gitlab.com/libtiff/libtiff/test/tiffcrop-R90-minisblack-2c-8b-alpha.sh +7 -0
  557. data/vendor/gitlab.com/libtiff/libtiff/test/tiffcrop-R90-miniswhite-1c-1b.sh +7 -0
  558. data/vendor/gitlab.com/libtiff/libtiff/test/tiffcrop-R90-palette-1c-1b.sh +7 -0
  559. data/vendor/gitlab.com/libtiff/libtiff/test/tiffcrop-R90-palette-1c-4b.sh +7 -0
  560. data/vendor/gitlab.com/libtiff/libtiff/test/tiffcrop-R90-palette-1c-8b.sh +7 -0
  561. data/vendor/gitlab.com/libtiff/libtiff/test/tiffcrop-R90-quad-tile.jpg.sh +7 -0
  562. data/vendor/gitlab.com/libtiff/libtiff/test/tiffcrop-R90-rgb-3c-16b.sh +7 -0
  563. data/vendor/gitlab.com/libtiff/libtiff/test/tiffcrop-R90-rgb-3c-8b.sh +7 -0
  564. data/vendor/gitlab.com/libtiff/libtiff/test/tiffcrop-doubleflip-logluv-3c-16b.sh +7 -0
  565. data/vendor/gitlab.com/libtiff/libtiff/test/tiffcrop-doubleflip-minisblack-1c-16b.sh +7 -0
  566. data/vendor/gitlab.com/libtiff/libtiff/test/tiffcrop-doubleflip-minisblack-1c-8b.sh +7 -0
  567. data/vendor/gitlab.com/libtiff/libtiff/test/tiffcrop-doubleflip-minisblack-2c-8b-alpha.sh +7 -0
  568. data/vendor/gitlab.com/libtiff/libtiff/test/tiffcrop-doubleflip-miniswhite-1c-1b.sh +7 -0
  569. data/vendor/gitlab.com/libtiff/libtiff/test/tiffcrop-doubleflip-palette-1c-1b.sh +7 -0
  570. data/vendor/gitlab.com/libtiff/libtiff/test/tiffcrop-doubleflip-palette-1c-4b.sh +7 -0
  571. data/vendor/gitlab.com/libtiff/libtiff/test/tiffcrop-doubleflip-palette-1c-8b.sh +7 -0
  572. data/vendor/gitlab.com/libtiff/libtiff/test/tiffcrop-doubleflip-quad-tile.jpg.sh +7 -0
  573. data/vendor/gitlab.com/libtiff/libtiff/test/tiffcrop-doubleflip-rgb-3c-16b.sh +7 -0
  574. data/vendor/gitlab.com/libtiff/libtiff/test/tiffcrop-doubleflip-rgb-3c-8b.sh +7 -0
  575. data/vendor/gitlab.com/libtiff/libtiff/test/tiffcrop-extract-logluv-3c-16b.sh +7 -0
  576. data/vendor/gitlab.com/libtiff/libtiff/test/tiffcrop-extract-minisblack-1c-16b.sh +7 -0
  577. data/vendor/gitlab.com/libtiff/libtiff/test/tiffcrop-extract-minisblack-1c-8b.sh +7 -0
  578. data/vendor/gitlab.com/libtiff/libtiff/test/tiffcrop-extract-minisblack-2c-8b-alpha.sh +7 -0
  579. data/vendor/gitlab.com/libtiff/libtiff/test/tiffcrop-extract-miniswhite-1c-1b.sh +7 -0
  580. data/vendor/gitlab.com/libtiff/libtiff/test/tiffcrop-extract-palette-1c-1b.sh +7 -0
  581. data/vendor/gitlab.com/libtiff/libtiff/test/tiffcrop-extract-palette-1c-4b.sh +7 -0
  582. data/vendor/gitlab.com/libtiff/libtiff/test/tiffcrop-extract-palette-1c-8b.sh +7 -0
  583. data/vendor/gitlab.com/libtiff/libtiff/test/tiffcrop-extract-quad-tile.jpg.sh +7 -0
  584. data/vendor/gitlab.com/libtiff/libtiff/test/tiffcrop-extract-rgb-3c-16b.sh +7 -0
  585. data/vendor/gitlab.com/libtiff/libtiff/test/tiffcrop-extract-rgb-3c-8b.sh +7 -0
  586. data/vendor/gitlab.com/libtiff/libtiff/test/tiffcrop-extractz14-logluv-3c-16b.sh +7 -0
  587. data/vendor/gitlab.com/libtiff/libtiff/test/tiffcrop-extractz14-minisblack-1c-16b.sh +7 -0
  588. data/vendor/gitlab.com/libtiff/libtiff/test/tiffcrop-extractz14-minisblack-1c-8b.sh +7 -0
  589. data/vendor/gitlab.com/libtiff/libtiff/test/tiffcrop-extractz14-minisblack-2c-8b-alpha.sh +7 -0
  590. data/vendor/gitlab.com/libtiff/libtiff/test/tiffcrop-extractz14-miniswhite-1c-1b.sh +7 -0
  591. data/vendor/gitlab.com/libtiff/libtiff/test/tiffcrop-extractz14-palette-1c-1b.sh +7 -0
  592. data/vendor/gitlab.com/libtiff/libtiff/test/tiffcrop-extractz14-palette-1c-4b.sh +7 -0
  593. data/vendor/gitlab.com/libtiff/libtiff/test/tiffcrop-extractz14-palette-1c-8b.sh +7 -0
  594. data/vendor/gitlab.com/libtiff/libtiff/test/tiffcrop-extractz14-quad-tile.jpg.sh +7 -0
  595. data/vendor/gitlab.com/libtiff/libtiff/test/tiffcrop-extractz14-rgb-3c-16b.sh +7 -0
  596. data/vendor/gitlab.com/libtiff/libtiff/test/tiffcrop-extractz14-rgb-3c-8b.sh +7 -0
  597. data/vendor/gitlab.com/libtiff/libtiff/test/tiffdump.sh +6 -0
  598. data/vendor/gitlab.com/libtiff/libtiff/test/tiffinfo.sh +6 -0
  599. data/vendor/gitlab.com/libtiff/libtiff/test/tifftest.h +42 -0
  600. data/vendor/gitlab.com/libtiff/libtiff/tiff.spec +68 -0
  601. data/vendor/gitlab.com/libtiff/libtiff/tools/.cvsignore +27 -0
  602. data/vendor/gitlab.com/libtiff/libtiff/tools/CMakeLists.txt +125 -0
  603. data/vendor/gitlab.com/libtiff/libtiff/tools/Makefile.am +138 -0
  604. data/vendor/gitlab.com/libtiff/libtiff/tools/Makefile.in +955 -0
  605. data/vendor/gitlab.com/libtiff/libtiff/tools/Makefile.lcc +133 -0
  606. data/vendor/gitlab.com/libtiff/libtiff/tools/Makefile.vc +52 -0
  607. data/vendor/gitlab.com/libtiff/libtiff/tools/fax2ps.c +463 -0
  608. data/vendor/gitlab.com/libtiff/libtiff/tools/fax2tiff.c +491 -0
  609. data/vendor/gitlab.com/libtiff/libtiff/tools/pal2rgb.c +438 -0
  610. data/vendor/gitlab.com/libtiff/libtiff/tools/ppm2tiff.c +397 -0
  611. data/vendor/gitlab.com/libtiff/libtiff/tools/raw2tiff.c +690 -0
  612. data/vendor/gitlab.com/libtiff/libtiff/tools/rgb2ycbcr.c +397 -0
  613. data/vendor/gitlab.com/libtiff/libtiff/tools/thumbnail.c +691 -0
  614. data/vendor/gitlab.com/libtiff/libtiff/tools/tiff2bw.c +501 -0
  615. data/vendor/gitlab.com/libtiff/libtiff/tools/tiff2pdf.c +5594 -0
  616. data/vendor/gitlab.com/libtiff/libtiff/tools/tiff2ps.c +3106 -0
  617. data/vendor/gitlab.com/libtiff/libtiff/tools/tiff2rgba.c +569 -0
  618. data/vendor/gitlab.com/libtiff/libtiff/tools/tiffcmp.c +659 -0
  619. data/vendor/gitlab.com/libtiff/libtiff/tools/tiffcp.c +1913 -0
  620. data/vendor/gitlab.com/libtiff/libtiff/tools/tiffcrop.c +9231 -0
  621. data/vendor/gitlab.com/libtiff/libtiff/tools/tiffdither.c +347 -0
  622. data/vendor/gitlab.com/libtiff/libtiff/tools/tiffdump.c +889 -0
  623. data/vendor/gitlab.com/libtiff/libtiff/tools/tiffgt.c +486 -0
  624. data/vendor/gitlab.com/libtiff/libtiff/tools/tiffinfo.c +488 -0
  625. data/vendor/gitlab.com/libtiff/libtiff/tools/tiffinfoce.c +472 -0
  626. data/vendor/gitlab.com/libtiff/libtiff/tools/tiffmedian.c +918 -0
  627. data/vendor/gitlab.com/libtiff/libtiff/tools/tiffset.c +356 -0
  628. data/vendor/gitlab.com/libtiff/libtiff/tools/tiffsplit.c +305 -0
  629. metadata +692 -0
@@ -0,0 +1,3106 @@
1
+ /* $Id: tiff2ps.c,v 1.56 2017-04-27 15:46:22 erouault Exp $ */
2
+
3
+ /*
4
+ * Copyright (c) 1988-1997 Sam Leffler
5
+ * Copyright (c) 1991-1997 Silicon Graphics, Inc.
6
+ *
7
+ * Permission to use, copy, modify, distribute, and sell this software and
8
+ * its documentation for any purpose is hereby granted without fee, provided
9
+ * that (i) the above copyright notices and this permission notice appear in
10
+ * all copies of the software and related documentation, and (ii) the names of
11
+ * Sam Leffler and Silicon Graphics may not be used in any advertising or
12
+ * publicity relating to the software without the specific, prior written
13
+ * permission of Sam Leffler and Silicon Graphics.
14
+ *
15
+ * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND,
16
+ * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY
17
+ * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
18
+ *
19
+ * IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR
20
+ * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND,
21
+ * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
22
+ * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF
23
+ * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
24
+ * OF THIS SOFTWARE.
25
+ */
26
+
27
+ #include "tif_config.h"
28
+
29
+ #include <stdio.h>
30
+ #include <stdlib.h> /* for atof */
31
+ #include <math.h>
32
+ #include <time.h>
33
+ #include <string.h>
34
+
35
+ #ifdef HAVE_UNISTD_H
36
+ # include <unistd.h>
37
+ #endif
38
+
39
+ #ifdef NEED_LIBPORT
40
+ # include "libport.h"
41
+ #endif
42
+
43
+ #include "tiffio.h"
44
+
45
+ /*
46
+ * Revision history
47
+ * 2013-Jan-21
48
+ * Richard Nolde: Fix bug in auto rotate option code. Once a
49
+ * rotation angle was set by the auto rotate check, it was
50
+ * retained for all pages that followed instead of being
51
+ * retested for each page.
52
+ *
53
+ * 2010-Sep-17
54
+ * Richard Nolde: Reinstate code from Feb 2009 that never got
55
+ * accepted into CVS with major modifications to handle -H and -W
56
+ * options. Replaced original PlaceImage function with several
57
+ * new functions that make support for multiple output pages
58
+ * from a single image easier to understand. Added additional
59
+ * warning messages for incompatible command line options.
60
+ * Add new command line options to specify PageOrientation
61
+ * Document Structuring Comment for landscape or portrait
62
+ * and code to determine the values from ouput width and height
63
+ * if not specified on the command line.
64
+ * Add new command line option to specify document creator
65
+ * as an alterntive to the string "tiff2ps" following model
66
+ * of patch submitted by Thomas Jarosch for specifiying a
67
+ * document title which is also supported now.
68
+ *
69
+ * 2009-Feb-11
70
+ * Richard Nolde: Added support for rotations of 90, 180, 270
71
+ * and auto using -r <90|180|270|auto>. Auto picks the best
72
+ * fit for the image on the specified paper size (eg portrait
73
+ * or landscape) if -h or -w is specified. Rotation is in
74
+ * degrees counterclockwise since that is how Postscript does
75
+ * it. The auto opption rotates the image 90 degrees ccw to
76
+ * produce landscape if that is a better fit than portait.
77
+ *
78
+ * Cleaned up code in TIFF2PS and broke into smaller functions
79
+ * to simplify rotations.
80
+ *
81
+ * Identified incompatible options and returned errors, eg
82
+ * -i for imagemask operator is only available for Level2 or
83
+ * Level3 Postscript in the current implmentation since there
84
+ * is a difference in the way the operands are called for Level1
85
+ * and there is no function to provide the Level1 version.
86
+ * -H was not handled properly if -h and/or -w were specified.
87
+ * It should only clip the masked images if the scaled image
88
+ * exceeds the maxPageHeight specified with -H.
89
+ *
90
+ * New design allows for all of the following combinations:
91
+ * Conversion of TIFF to Postscript with optional rotations
92
+ * of 90, 180, 270, or auto degrees counterclockwise
93
+ * Conversion of TIFF to Postscript with entire image scaled
94
+ * to maximum of values spedified with -h or -w while
95
+ * maintaining aspect ratio. Same rotations apply.
96
+ * Conversion of TIFF to Postscript with clipping of output
97
+ * viewport to height specified with -H, producing multiple
98
+ * pages at this height and original width as needed.
99
+ * Same rotations apply.
100
+ * Conversion of TIFF to Postscript with image scaled to
101
+ * maximum specified by -h and -w and the resulting scaled
102
+ * image is presented in an output viewport clipped by -H height.
103
+ * The same rotations apply.
104
+ *
105
+ * Added maxPageWidth option using -W flag. MaxPageHeight and
106
+ * MaxPageWidth are mutually exclusive since the aspect ratio
107
+ * cannot be maintained if you set both.
108
+ * Rewrote PlaceImage to allow maxPageHeight and maxPageWidth
109
+ * options to work with values smaller or larger than the
110
+ * physical paper size and still preserve the aspect ratio.
111
+ * This is accomplished by creating multiple pages across
112
+ * as well as down if need be.
113
+ *
114
+ * 2001-Mar-21
115
+ * I (Bruce A. Mallett) added this revision history comment ;)
116
+ *
117
+ * Fixed PS_Lvl2page() code which outputs non-ASCII85 raw
118
+ * data. Moved test for when to output a line break to
119
+ * *after* the output of a character. This just serves
120
+ * to fix an eye-nuisance where the first line of raw
121
+ * data was one character shorter than subsequent lines.
122
+ *
123
+ * Added an experimental ASCII85 encoder which can be used
124
+ * only when there is a single buffer of bytes to be encoded.
125
+ * This version is much faster at encoding a straight-line
126
+ * buffer of data because it can avoid a lot of the loop
127
+ * overhead of the byte-by-byte version. To use this version
128
+ * you need to define EXP_ASCII85ENCODER (experimental ...).
129
+ *
130
+ * Added bug fix given by Michael Schmidt to PS_Lvl2page()
131
+ * in which an end-of-data marker ('>') was not being output
132
+ * when producing non-ASCII85 encoded PostScript Level 2
133
+ * data.
134
+ *
135
+ * Fixed PS_Lvl2colorspace() so that it no longer assumes that
136
+ * a TIFF having more than 2 planes is a CMYK. This routine
137
+ * no longer looks at the samples per pixel but instead looks
138
+ * at the "photometric" value. This change allows support of
139
+ * CMYK TIFFs.
140
+ *
141
+ * Modified the PostScript L2 imaging loop so as to test if
142
+ * the input stream is still open before attempting to do a
143
+ * flushfile on it. This was done because some RIPs close
144
+ * the stream after doing the image operation.
145
+ *
146
+ * Got rid of the realloc() being done inside a loop in the
147
+ * PSRawDataBW() routine. The code now walks through the
148
+ * byte-size array outside the loop to determine the largest
149
+ * size memory block that will be needed.
150
+ *
151
+ * Added "-m" switch to ask tiff2ps to, where possible, use the
152
+ * "imagemask" operator instead of the "image" operator.
153
+ *
154
+ * Added the "-i #" switch to allow interpolation to be disabled.
155
+ *
156
+ * Unrolled a loop or two to improve performance.
157
+ */
158
+
159
+ /*
160
+ * Define EXP_ASCII85ENCODER if you want to use an experimental
161
+ * version of the ASCII85 encoding routine. The advantage of
162
+ * using this routine is that tiff2ps will convert to ASCII85
163
+ * encoding at between 3 and 4 times the speed as compared to
164
+ * using the old (non-experimental) encoder. The disadvantage
165
+ * is that you will be using a new (and unproven) encoding
166
+ * routine. So user beware, you have been warned!
167
+ */
168
+
169
+ #define EXP_ASCII85ENCODER
170
+
171
+ /*
172
+ * NB: this code assumes uint32 works with printf's %l[ud].
173
+ */
174
+ #ifndef TRUE
175
+ #define TRUE 1
176
+ #define FALSE 0
177
+ #endif
178
+
179
+ int ascii85 = FALSE; /* use ASCII85 encoding */
180
+ int interpolate = TRUE; /* interpolate level2 image */
181
+ int level2 = FALSE; /* generate PostScript level 2 */
182
+ int level3 = FALSE; /* generate PostScript level 3 */
183
+ int printAll = FALSE; /* print all images in file */
184
+ int generateEPSF = TRUE; /* generate Encapsulated PostScript */
185
+ int PSduplex = FALSE; /* enable duplex printing */
186
+ int PStumble = FALSE; /* enable top edge binding */
187
+ int PSavoiddeadzone = TRUE; /* enable avoiding printer deadzone */
188
+ double maxPageHeight = 0; /* maximum height to select from image and print per page */
189
+ double maxPageWidth = 0; /* maximum width to select from image and print per page */
190
+ double splitOverlap = 0; /* amount for split pages to overlag */
191
+ int rotation = 0; /* optional value for rotation angle */
192
+ int auto_rotate = 0; /* rotate image for best fit on the page */
193
+ char *filename = NULL; /* input filename */
194
+ char *title = NULL; /* optional document title string */
195
+ char *creator = NULL; /* optional document creator string */
196
+ char pageOrientation[12]; /* set optional PageOrientation DSC to Landscape or Portrait */
197
+ int useImagemask = FALSE; /* Use imagemask instead of image operator */
198
+ uint16 res_unit = 0; /* Resolution units: 2 - inches, 3 - cm */
199
+
200
+ /*
201
+ * ASCII85 Encoding Support.
202
+ */
203
+ unsigned char ascii85buf[10];
204
+ int ascii85count;
205
+ int ascii85breaklen;
206
+
207
+ int TIFF2PS(FILE*, TIFF*, double, double, double, double, int);
208
+ void PSpage(FILE*, TIFF*, uint32, uint32);
209
+ void PSColorContigPreamble(FILE*, uint32, uint32, int);
210
+ void PSColorSeparatePreamble(FILE*, uint32, uint32, int);
211
+ void PSDataColorContig(FILE*, TIFF*, uint32, uint32, int);
212
+ void PSDataColorSeparate(FILE*, TIFF*, uint32, uint32, int);
213
+ void PSDataPalette(FILE*, TIFF*, uint32, uint32);
214
+ void PSDataBW(FILE*, TIFF*, uint32, uint32);
215
+ void PSRawDataBW(FILE*, TIFF*, uint32, uint32);
216
+ void Ascii85Init(void);
217
+ void Ascii85Put(unsigned char code, FILE* fd);
218
+ void Ascii85Flush(FILE* fd);
219
+ void PSHead(FILE*, double, double, double, double);
220
+ void PSTail(FILE*, int);
221
+ int psStart(FILE *, int, int, int *, double *, double, double, double,
222
+ double, double, double, double, double, double, double);
223
+ int psPageSize(FILE *, int, double, double, double, double, double, double);
224
+ int psRotateImage(FILE *, int, double, double, double, double);
225
+ int psMaskImage(FILE *, TIFF *, int, int, int *, double, double,
226
+ double, double, double, double, double, double, double);
227
+ int psScaleImage(FILE *, double, int, int, double, double, double, double,
228
+ double, double);
229
+ int get_viewport (double, double, double, double, double *, double *, int);
230
+ int exportMaskedImage(FILE *, double, double, double, double, int, int,
231
+ double, double, double, int, int);
232
+
233
+ #if defined( EXP_ASCII85ENCODER)
234
+ tsize_t Ascii85EncodeBlock( uint8 * ascii85_p, unsigned f_eod, const uint8 * raw_p, tsize_t raw_l );
235
+ #endif
236
+
237
+ static void usage(int);
238
+
239
+ int
240
+ main(int argc, char* argv[])
241
+ {
242
+ int dirnum = -1, c, np = 0;
243
+ int centered = 0;
244
+ double bottommargin = 0;
245
+ double leftmargin = 0;
246
+ double pageWidth = 0;
247
+ double pageHeight = 0;
248
+ uint32 diroff = 0;
249
+ #if !HAVE_DECL_OPTARG
250
+ extern char *optarg;
251
+ extern int optind;
252
+ #endif
253
+ FILE* output = stdout;
254
+
255
+ pageOrientation[0] = '\0';
256
+
257
+ while ((c = getopt(argc, argv, "b:d:h:H:W:L:i:w:l:o:O:P:C:r:t:acemxyzps1238DT")) != -1)
258
+ switch (c) {
259
+ case 'b':
260
+ bottommargin = atof(optarg);
261
+ break;
262
+ case 'c':
263
+ centered = 1;
264
+ break;
265
+ case 'C':
266
+ creator = optarg;
267
+ break;
268
+ case 'd': /* without -a, this only processes one image at this IFD */
269
+ dirnum = atoi(optarg);
270
+ break;
271
+ case 'D':
272
+ PSduplex = TRUE;
273
+ break;
274
+ case 'i':
275
+ interpolate = atoi(optarg) ? TRUE:FALSE;
276
+ break;
277
+ case 'T':
278
+ PStumble = TRUE;
279
+ break;
280
+ case 'e':
281
+ PSavoiddeadzone = FALSE;
282
+ generateEPSF = TRUE;
283
+ break;
284
+ case 'h':
285
+ pageHeight = atof(optarg);
286
+ break;
287
+ case 'H':
288
+ maxPageHeight = atof(optarg);
289
+ break;
290
+ case 'W':
291
+ maxPageWidth = atof(optarg);
292
+ break;
293
+ case 'L':
294
+ splitOverlap = atof(optarg);
295
+ break;
296
+ case 'm':
297
+ useImagemask = TRUE;
298
+ break;
299
+ case 'o':
300
+ switch (optarg[0])
301
+ {
302
+ case '0':
303
+ case '1':
304
+ case '2':
305
+ case '3':
306
+ case '4':
307
+ case '5':
308
+ case '6':
309
+ case '7':
310
+ case '8':
311
+ case '9': diroff = (uint32) strtoul(optarg, NULL, 0);
312
+ break;
313
+ default: TIFFError ("-o", "Offset must be a numeric value.");
314
+ exit (1);
315
+ }
316
+ break;
317
+ case 'O': /* XXX too bad -o is already taken */
318
+ output = fopen(optarg, "w");
319
+ if (output == NULL) {
320
+ fprintf(stderr,
321
+ "%s: %s: Cannot open output file.\n",
322
+ argv[0], optarg);
323
+ exit(-2);
324
+ }
325
+ break;
326
+ case 'P':
327
+ switch (optarg[0])
328
+ {
329
+ case 'l':
330
+ case 'L': strcpy (pageOrientation, "Landscape");
331
+ break;
332
+ case 'p':
333
+ case 'P': strcpy (pageOrientation, "Portrait");
334
+ break;
335
+ default: TIFFError ("-P", "Page orientation must be Landscape or Portrait");
336
+ exit (-1);
337
+ }
338
+ break;
339
+ case 'l':
340
+ leftmargin = atof(optarg);
341
+ break;
342
+ case 'a': /* removed fall through to generate warning below, R Nolde 09-01-2010 */
343
+ printAll = TRUE;
344
+ break;
345
+ case 'p':
346
+ generateEPSF = FALSE;
347
+ break;
348
+ case 'r':
349
+ if (strcmp (optarg, "auto") == 0)
350
+ {
351
+ rotation = 0;
352
+ auto_rotate = TRUE;
353
+ }
354
+ else
355
+ {
356
+ rotation = atoi(optarg);
357
+ auto_rotate = FALSE;
358
+ }
359
+ switch (rotation)
360
+ {
361
+ case 0:
362
+ case 90:
363
+ case 180:
364
+ case 270:
365
+ break;
366
+ default:
367
+ fprintf (stderr, "Rotation angle must be 90, 180, 270 (degrees ccw) or auto\n");
368
+ exit (-1);
369
+ }
370
+ break;
371
+ case 's':
372
+ printAll = FALSE;
373
+ break;
374
+ case 't':
375
+ title = optarg;
376
+ break;
377
+ case 'w':
378
+ pageWidth = atof(optarg);
379
+ break;
380
+ case 'z':
381
+ PSavoiddeadzone = FALSE;
382
+ break;
383
+ case '1':
384
+ level2 = FALSE;
385
+ level3 = FALSE;
386
+ ascii85 = FALSE;
387
+ break;
388
+ case '2':
389
+ level2 = TRUE;
390
+ ascii85 = TRUE; /* default to yes */
391
+ break;
392
+ case '3':
393
+ level3 = TRUE;
394
+ ascii85 = TRUE; /* default to yes */
395
+ break;
396
+ case '8':
397
+ ascii85 = FALSE;
398
+ break;
399
+ case 'x':
400
+ res_unit = RESUNIT_CENTIMETER;
401
+ break;
402
+ case 'y':
403
+ res_unit = RESUNIT_INCH;
404
+ break;
405
+ case '?':
406
+ usage(-1);
407
+ }
408
+
409
+ if (useImagemask == TRUE)
410
+ {
411
+ if ((level2 == FALSE) && (level3 == FALSE))
412
+ {
413
+ TIFFError ("-m "," imagemask operator requres Postscript Level2 or Level3");
414
+ exit (1);
415
+ }
416
+ }
417
+
418
+ if (pageWidth && (maxPageWidth > pageWidth))
419
+ {
420
+ TIFFError ("-W", "Max viewport width cannot exceed page width");
421
+ exit (1);
422
+ }
423
+
424
+ /* auto rotate requires a specified page width and height */
425
+ if (auto_rotate == TRUE)
426
+ {
427
+ /*
428
+ if ((pageWidth == 0) || (pageHeight == 0))
429
+ TIFFWarning ("-r auto", " requires page height and width specified with -h and -w");
430
+ */
431
+ if ((maxPageWidth > 0) || (maxPageHeight > 0))
432
+ {
433
+ TIFFError ("-r auto", " is incompatible with maximum page width/height specified by -H or -W");
434
+ exit (1);
435
+ }
436
+ }
437
+ if ((maxPageWidth > 0) && (maxPageHeight > 0))
438
+ {
439
+ TIFFError ("-H and -W", " Use only one of -H or -W to define a viewport");
440
+ exit (1);
441
+ }
442
+
443
+ if ((generateEPSF == TRUE) && (printAll == TRUE))
444
+ {
445
+ TIFFError(" -e and -a", "Warning: Cannot generate Encapsulated Postscript for multiple images");
446
+ generateEPSF = FALSE;
447
+ }
448
+
449
+ if ((generateEPSF == TRUE) && (PSduplex == TRUE))
450
+ {
451
+ TIFFError(" -e and -D", "Warning: Encapsulated Postscript does not support Duplex option");
452
+ PSduplex = FALSE;
453
+ }
454
+
455
+ if ((generateEPSF == TRUE) && (PStumble == TRUE))
456
+ {
457
+ TIFFError(" -e and -T", "Warning: Encapsulated Postscript does not support Top Edge Binding option");
458
+ PStumble = FALSE;
459
+ }
460
+
461
+ if ((generateEPSF == TRUE) && (PSavoiddeadzone == TRUE))
462
+ PSavoiddeadzone = FALSE;
463
+
464
+ for (; argc - optind > 0; optind++) {
465
+ TIFF* tif = TIFFOpen(filename = argv[optind], "r");
466
+ if (tif != NULL) {
467
+ if (dirnum != -1
468
+ && !TIFFSetDirectory(tif, (tdir_t)dirnum))
469
+ {
470
+ TIFFClose(tif);
471
+ return (-1);
472
+ }
473
+ else if (diroff != 0 &&
474
+ !TIFFSetSubDirectory(tif, diroff))
475
+ {
476
+ TIFFClose(tif);
477
+ return (-1);
478
+ }
479
+ np = TIFF2PS(output, tif, pageWidth, pageHeight,
480
+ leftmargin, bottommargin, centered);
481
+ if (np < 0)
482
+ {
483
+ TIFFError("Error", "Unable to process %s", filename);
484
+ }
485
+ TIFFClose(tif);
486
+ }
487
+ }
488
+ if (np)
489
+ PSTail(output, np);
490
+ else
491
+ usage(-1);
492
+ if (output != stdout)
493
+ fclose(output);
494
+ return (0);
495
+ }
496
+
497
+ static uint16 samplesperpixel;
498
+ static uint16 bitspersample;
499
+ static uint16 planarconfiguration;
500
+ static uint16 photometric;
501
+ static uint16 compression;
502
+ static uint16 extrasamples;
503
+ static int alpha;
504
+
505
+ static int
506
+ checkImage(TIFF* tif)
507
+ {
508
+ switch (photometric) {
509
+ case PHOTOMETRIC_YCBCR:
510
+ if ((compression == COMPRESSION_JPEG || compression == COMPRESSION_OJPEG)
511
+ && planarconfiguration == PLANARCONFIG_CONTIG) {
512
+ /* can rely on libjpeg to convert to RGB */
513
+ TIFFSetField(tif, TIFFTAG_JPEGCOLORMODE,
514
+ JPEGCOLORMODE_RGB);
515
+ photometric = PHOTOMETRIC_RGB;
516
+ } else {
517
+ if (level2 || level3)
518
+ break;
519
+ TIFFError(filename, "Can not handle image with %s",
520
+ "PhotometricInterpretation=YCbCr");
521
+ return (0);
522
+ }
523
+ /* fall thru... */
524
+ case PHOTOMETRIC_RGB:
525
+ if (alpha && bitspersample != 8) {
526
+ TIFFError(filename,
527
+ "Can not handle %d-bit/sample RGB image with alpha",
528
+ bitspersample);
529
+ return (0);
530
+ }
531
+ /* fall thru... */
532
+ case PHOTOMETRIC_SEPARATED:
533
+ case PHOTOMETRIC_PALETTE:
534
+ case PHOTOMETRIC_MINISBLACK:
535
+ case PHOTOMETRIC_MINISWHITE:
536
+ break;
537
+ case PHOTOMETRIC_LOGL:
538
+ case PHOTOMETRIC_LOGLUV:
539
+ if (compression != COMPRESSION_SGILOG &&
540
+ compression != COMPRESSION_SGILOG24) {
541
+ TIFFError(filename,
542
+ "Can not handle %s data with compression other than SGILog",
543
+ (photometric == PHOTOMETRIC_LOGL) ?
544
+ "LogL" : "LogLuv"
545
+ );
546
+ return (0);
547
+ }
548
+ /* rely on library to convert to RGB/greyscale */
549
+ TIFFSetField(tif, TIFFTAG_SGILOGDATAFMT, SGILOGDATAFMT_8BIT);
550
+ photometric = (photometric == PHOTOMETRIC_LOGL) ?
551
+ PHOTOMETRIC_MINISBLACK : PHOTOMETRIC_RGB;
552
+ bitspersample = 8;
553
+ break;
554
+ case PHOTOMETRIC_CIELAB:
555
+ /* fall thru... */
556
+ default:
557
+ TIFFError(filename,
558
+ "Can not handle image with PhotometricInterpretation=%d",
559
+ photometric);
560
+ return (0);
561
+ }
562
+ switch (bitspersample) {
563
+ case 1: case 2:
564
+ case 4: case 8:
565
+ case 16:
566
+ break;
567
+ default:
568
+ TIFFError(filename, "Can not handle %d-bit/sample image",
569
+ bitspersample);
570
+ return (0);
571
+ }
572
+ if (planarconfiguration == PLANARCONFIG_SEPARATE && extrasamples > 0)
573
+ TIFFWarning(filename, "Ignoring extra samples");
574
+ return (1);
575
+ }
576
+
577
+ #define PS_UNIT_SIZE 72.0F
578
+ #define PSUNITS(npix,res) ((npix) * (PS_UNIT_SIZE / (res)))
579
+
580
+ static char RGBcolorimage[] = "\
581
+ /bwproc {\n\
582
+ rgbproc\n\
583
+ dup length 3 idiv string 0 3 0\n\
584
+ 5 -1 roll {\n\
585
+ add 2 1 roll 1 sub dup 0 eq {\n\
586
+ pop 3 idiv\n\
587
+ 3 -1 roll\n\
588
+ dup 4 -1 roll\n\
589
+ dup 3 1 roll\n\
590
+ 5 -1 roll put\n\
591
+ 1 add 3 0\n\
592
+ } { 2 1 roll } ifelse\n\
593
+ } forall\n\
594
+ pop pop pop\n\
595
+ } def\n\
596
+ /colorimage where {pop} {\n\
597
+ /colorimage {pop pop /rgbproc exch def {bwproc} image} bind def\n\
598
+ } ifelse\n\
599
+ ";
600
+
601
+ /*
602
+ * Adobe Photoshop requires a comment line of the form:
603
+ *
604
+ * %ImageData: <cols> <rows> <depth> <main channels> <pad channels>
605
+ * <block size> <1 for binary|2 for hex> "data start"
606
+ *
607
+ * It is claimed to be part of some future revision of the EPS spec.
608
+ */
609
+ static void
610
+ PhotoshopBanner(FILE* fd, uint32 w, uint32 h, int bs, int nc, char* startline)
611
+ {
612
+ fprintf(fd, "%%ImageData: %ld %ld %d %d 0 %d 2 \"",
613
+ (long) w, (long) h, bitspersample, nc, bs);
614
+ fprintf(fd, startline, nc);
615
+ fprintf(fd, "\"\n");
616
+ }
617
+
618
+ /* Convert pixel width and height pw, ph, to points pprw, pprh
619
+ * using image resolution and resolution units from TIFF tags.
620
+ * pw : image width in pixels
621
+ * ph : image height in pixels
622
+ * pprw : image width in PS units (72 dpi)
623
+ * pprh : image height in PS units (72 dpi)
624
+ */
625
+ static void
626
+ setupPageState(TIFF* tif, uint32* pw, uint32* ph, double* pprw, double* pprh)
627
+ {
628
+ float xres = 0.0F, yres = 0.0F;
629
+
630
+ TIFFGetField(tif, TIFFTAG_IMAGEWIDTH, pw);
631
+ TIFFGetField(tif, TIFFTAG_IMAGELENGTH, ph);
632
+ if (res_unit == 0) /* Not specified as command line option */
633
+ if (!TIFFGetFieldDefaulted(tif, TIFFTAG_RESOLUTIONUNIT, &res_unit))
634
+ res_unit = RESUNIT_INCH;
635
+ /*
636
+ * Calculate printable area.
637
+ */
638
+ if (!TIFFGetField(tif, TIFFTAG_XRESOLUTION, &xres)
639
+ || fabs(xres) < 0.0000001)
640
+ xres = PS_UNIT_SIZE;
641
+ if (!TIFFGetField(tif, TIFFTAG_YRESOLUTION, &yres)
642
+ || fabs(yres) < 0.0000001)
643
+ yres = PS_UNIT_SIZE;
644
+ switch (res_unit) {
645
+ case RESUNIT_CENTIMETER:
646
+ xres *= 2.54F, yres *= 2.54F;
647
+ break;
648
+ case RESUNIT_INCH:
649
+ break;
650
+ case RESUNIT_NONE: /* Subsequent code assumes we have converted to inches! */
651
+ res_unit = RESUNIT_INCH;
652
+ break;
653
+ default: /* Last ditch guess for unspecified RESUNIT case
654
+ * check that the resolution is not inches before scaling it.
655
+ * Moved to end of function with additional check, RJN, 08-31-2010
656
+ * if (xres != PS_UNIT_SIZE || yres != PS_UNIT_SIZE)
657
+ * xres *= PS_UNIT_SIZE, yres *= PS_UNIT_SIZE;
658
+ */
659
+ break;
660
+ }
661
+ /* This is a hack to deal with images that have no meaningful Resolution Size
662
+ * but may have x and/or y resolutions of 1 pixel per undefined unit.
663
+ */
664
+ if ((xres > 1.0) && (xres != PS_UNIT_SIZE))
665
+ *pprw = PSUNITS(*pw, xres);
666
+ else
667
+ *pprw = PSUNITS(*pw, PS_UNIT_SIZE);
668
+ if ((yres > 1.0) && (yres != PS_UNIT_SIZE))
669
+ *pprh = PSUNITS(*ph, yres);
670
+ else
671
+ *pprh = PSUNITS(*ph, PS_UNIT_SIZE);
672
+ }
673
+
674
+ static int
675
+ isCCITTCompression(TIFF* tif)
676
+ {
677
+ uint16 compress;
678
+ TIFFGetField(tif, TIFFTAG_COMPRESSION, &compress);
679
+ return (compress == COMPRESSION_CCITTFAX3 ||
680
+ compress == COMPRESSION_CCITTFAX4 ||
681
+ compress == COMPRESSION_CCITTRLE ||
682
+ compress == COMPRESSION_CCITTRLEW);
683
+ }
684
+
685
+ static tsize_t tf_bytesperrow;
686
+ static tsize_t ps_bytesperrow;
687
+ static tsize_t tf_rowsperstrip;
688
+ static tsize_t tf_numberstrips;
689
+ static char *hex = "0123456789abcdef";
690
+
691
+ /*
692
+ * Pagewidth and pageheight are the output size in points,
693
+ * may refer to values specified with -h and -w, or to
694
+ * values read from the image if neither -h nor -w are used.
695
+ * Imagewidth and imageheight are image size in points.
696
+ * Ximages and Yimages are number of pages across and down.
697
+ * Only one of maxPageHeight or maxPageWidth can be used.
698
+ * These are global variables unfortunately.
699
+ */
700
+ int get_subimage_count(double pagewidth, double pageheight,
701
+ double imagewidth, double imageheight,
702
+ int *ximages, int *yimages,
703
+ int rotation, double scale)
704
+ {
705
+ int pages = 1;
706
+ double splitheight = 0; /* Requested Max Height in points */
707
+ double splitwidth = 0; /* Requested Max Width in points */
708
+ double overlap = 0; /* Repeated edge width in points */
709
+
710
+ splitheight = maxPageHeight * PS_UNIT_SIZE;
711
+ splitwidth = maxPageWidth * PS_UNIT_SIZE;
712
+ overlap = splitOverlap * PS_UNIT_SIZE;
713
+ pagewidth *= PS_UNIT_SIZE;
714
+ pageheight *= PS_UNIT_SIZE;
715
+
716
+ if ((imagewidth < 1.0) || (imageheight < 1.0))
717
+ {
718
+ TIFFError("get_subimage_count", "Invalid image width or height");
719
+ return (0);
720
+ }
721
+
722
+ switch (rotation)
723
+ {
724
+ case 0:
725
+ case 180: if (splitheight > 0) /* -H maxPageHeight */
726
+ {
727
+ if (imageheight > splitheight) /* More than one vertical image segment */
728
+ {
729
+ if (pagewidth)
730
+ *ximages = (int)ceil((scale * imagewidth) / (pagewidth - overlap));
731
+ else
732
+ *ximages = 1;
733
+ *yimages = (int)ceil((scale * imageheight) / (splitheight - overlap)); /* Max vert pages needed */
734
+ }
735
+ else
736
+ {
737
+ if (pagewidth)
738
+ *ximages = (int)ceil((scale * imagewidth) / (pagewidth - overlap)); /* Max horz pages needed */
739
+ else
740
+ *ximages = 1;
741
+ *yimages = 1; /* Max vert pages needed */
742
+ }
743
+ }
744
+ else
745
+ {
746
+ if (splitwidth > 0) /* -W maxPageWidth */
747
+ {
748
+ if (imagewidth >splitwidth)
749
+ {
750
+ *ximages = (int)ceil((scale * imagewidth) / (splitwidth - overlap)); /* Max horz pages needed */
751
+ if (pageheight)
752
+ *yimages = (int)ceil((scale * imageheight) / (pageheight - overlap)); /* Max vert pages needed */
753
+ else
754
+ *yimages = 1;
755
+ }
756
+ else
757
+ {
758
+ *ximages = 1; /* Max vert pages needed */
759
+ if (pageheight)
760
+ *yimages = (int)ceil((scale * imageheight) / (pageheight - overlap)); /* Max vert pages needed */
761
+ else
762
+ *yimages = 1;
763
+ }
764
+ }
765
+ else
766
+ {
767
+ *ximages = 1;
768
+ *yimages = 1;
769
+ }
770
+ }
771
+ break;
772
+ case 90:
773
+ case 270: if (splitheight > 0) /* -H maxPageHeight */
774
+ {
775
+ if (imagewidth > splitheight) /* More than one vertical image segment */
776
+ {
777
+ *yimages = (int)ceil((scale * imagewidth) / (splitheight - overlap)); /* Max vert pages needed */
778
+ if (pagewidth)
779
+ *ximages = (int)ceil((scale * imageheight) / (pagewidth - overlap)); /* Max horz pages needed */
780
+ else
781
+ *ximages = 1;
782
+ }
783
+ else
784
+ {
785
+ *yimages = 1; /* Max vert pages needed */
786
+ if (pagewidth)
787
+ *ximages = (int)ceil((scale * imageheight) / (pagewidth - overlap)); /* Max horz pages needed */
788
+ else
789
+ *ximages = 1;
790
+ }
791
+ }
792
+ else
793
+ {
794
+ if (splitwidth > 0) /* -W maxPageWidth */
795
+ {
796
+ if (imageheight > splitwidth)
797
+ {
798
+ if (pageheight)
799
+ *yimages = (int)ceil((scale * imagewidth) / (pageheight - overlap)); /* Max vert pages needed */
800
+ else
801
+ *yimages = 1;
802
+ *ximages = (int)ceil((scale * imageheight) / (splitwidth - overlap)); /* Max horz pages needed */
803
+ }
804
+ else
805
+ {
806
+ if (pageheight)
807
+ *yimages = (int)ceil((scale * imagewidth) / (pageheight - overlap)); /* Max horz pages needed */
808
+ else
809
+ *yimages = 1;
810
+ *ximages = 1; /* Max vert pages needed */
811
+ }
812
+ }
813
+ else
814
+ {
815
+ *ximages = 1;
816
+ *yimages = 1;
817
+ }
818
+ }
819
+ break;
820
+ default: *ximages = 1;
821
+ *yimages = 1;
822
+ }
823
+ pages = (*ximages) * (*yimages);
824
+ return (pages);
825
+ }
826
+
827
+ /* New version of PlaceImage that handles only the translation and rotation
828
+ * for a single output page.
829
+ */
830
+ int exportMaskedImage(FILE *fp, double pagewidth, double pageheight,
831
+ double imagewidth, double imageheight,
832
+ int row, int column,
833
+ double left_offset, double bott_offset,
834
+ double scale, int center, int rotation)
835
+ {
836
+ double xtran = 0.0;
837
+ double ytran = 0.0;
838
+
839
+ double xscale = 1.0;
840
+ double yscale = 1.0;
841
+
842
+ double splitheight = 0; /* Requested Max Height in points */
843
+ double splitwidth = 0; /* Requested Max Width in points */
844
+ double overlap = 0; /* Repeated edge width in points */
845
+ double subimage_height = 0.0;
846
+
847
+ splitheight = maxPageHeight * PS_UNIT_SIZE;
848
+ splitwidth = maxPageWidth * PS_UNIT_SIZE;
849
+ overlap = splitOverlap * PS_UNIT_SIZE;
850
+ xscale = scale * imagewidth;
851
+ yscale = scale * imageheight;
852
+
853
+ if ((xscale < 0.0) || (yscale < 0.0))
854
+ {
855
+ TIFFError("exportMaskedImage", "Invalid parameters.");
856
+ return (-1);
857
+ }
858
+
859
+ /* If images are cropped to a vewport with -H or -W, the output pages are shifted to
860
+ * the top of each output page rather than the Postscript default lower edge.
861
+ */
862
+ switch (rotation)
863
+ {
864
+ case 0:
865
+ case 180: if (splitheight > 0) /* -H maxPageHeight */
866
+ {
867
+ if (splitheight < imageheight) /* More than one vertical image segments */
868
+ {
869
+ /* Intra2net: Keep correct apspect ratio */
870
+ xscale = (imagewidth + overlap) * (pageheight / splitheight) * scale;
871
+
872
+ xtran = -1.0 * column * (pagewidth - overlap);
873
+ subimage_height = imageheight - ((splitheight - overlap) * row);
874
+ ytran = pageheight - subimage_height * (pageheight / splitheight);
875
+ }
876
+ else /* Only one page in vertical direction */
877
+ {
878
+ xtran = -1.0 * column * (pagewidth - overlap);
879
+ ytran = splitheight - imageheight;
880
+ }
881
+ }
882
+ else
883
+ {
884
+ if (splitwidth > 0) /* maxPageWidth */
885
+ {
886
+ if (splitwidth < imagewidth)
887
+ {
888
+ xtran = -1.0 * column * splitwidth;
889
+ ytran = -1.0 * row * (pageheight - overlap);
890
+ }
891
+ else /* Only one page in horizontal direction */
892
+ {
893
+ ytran = -1.0 * row * (pageheight - overlap);
894
+ xtran = 0;
895
+ }
896
+ }
897
+ else /* Simple case, no splitting */
898
+ {
899
+ ytran = pageheight - imageheight;
900
+ xtran = 0;
901
+ }
902
+ }
903
+
904
+ if (imagewidth <= pagewidth) {
905
+ /* Intra2net: Crop page at the bottom instead of the top (-> output starts at the top).
906
+ Only do this in non-page-split mode */
907
+ if (imageheight <= splitheight) {
908
+ ytran = pageheight - imageheight; /* Note: Will be negative for images longer than page size */
909
+ }
910
+ }
911
+ bott_offset += ytran / (center ? 2 : 1);
912
+ left_offset += xtran / (center ? 2 : 1);
913
+ break;
914
+ case 90:
915
+ case 270: if (splitheight > 0) /* -H maxPageHeight */
916
+ {
917
+ if (splitheight < imagewidth) /* More than one vertical image segments */
918
+ {
919
+ xtran = -1.0 * column * (pageheight - overlap);
920
+ /* Commented code places image at bottom of page instead of top.
921
+ ytran = -1.0 * row * splitheight;
922
+ */
923
+ if (row == 0)
924
+ ytran = -1.0 * (imagewidth - splitheight);
925
+ else
926
+ ytran = -1.0 * (imagewidth - (splitheight - overlap) * (row + 1));
927
+ }
928
+ else /* Only one page in vertical direction */
929
+ {
930
+ xtran = -1.0 * column * (pageheight - overlap);
931
+ ytran = splitheight - imagewidth;
932
+ }
933
+ }
934
+ else
935
+ {
936
+ if (splitwidth > 0) /* maxPageWidth */
937
+ {
938
+ if (splitwidth < imageheight)
939
+ {
940
+ xtran = -1.0 * column * splitwidth;
941
+ ytran = -1.0 * row * (pagewidth - overlap);
942
+ }
943
+ else /* Only one page in horizontal direction */
944
+ {
945
+ ytran = -1.0 * row * (pagewidth - overlap);
946
+ xtran = 0;
947
+ }
948
+ }
949
+ else /* Simple case, no splitting */
950
+ {
951
+ ytran = pageheight - imageheight;
952
+ xtran = 0; /* pagewidth - imagewidth; */
953
+ }
954
+ }
955
+ bott_offset += ytran / (center ? 2 : 1);
956
+ left_offset += xtran / (center ? 2 : 1);
957
+ break;
958
+ default: xtran = 0;
959
+ ytran = 0;
960
+ }
961
+
962
+ switch (rotation)
963
+ {
964
+ case 0: fprintf(fp, "%f %f translate\n", left_offset, bott_offset);
965
+ fprintf(fp, "%f %f scale\n", xscale, yscale);
966
+ break;
967
+ case 180: fprintf(fp, "%f %f translate\n", left_offset, bott_offset);
968
+ fprintf(fp, "%f %f scale\n1 1 translate 180 rotate\n", xscale, yscale);
969
+ break;
970
+ case 90: fprintf(fp, "%f %f translate\n", left_offset, bott_offset);
971
+ fprintf(fp, "%f %f scale\n1 0 translate 90 rotate\n", yscale, xscale);
972
+ break;
973
+ case 270: fprintf(fp, "%f %f translate\n", left_offset, bott_offset);
974
+ fprintf(fp, "%f %f scale\n0 1 translate 270 rotate\n", yscale, xscale);
975
+ break;
976
+ default: TIFFError ("exportMaskedImage", "Unsupported rotation angle %d. No rotation", rotation);
977
+ fprintf( fp, "%f %f scale\n", xscale, yscale);
978
+ break;
979
+ }
980
+
981
+ return (0);
982
+ }
983
+
984
+ /* Rotate an image without scaling or clipping */
985
+ int psRotateImage (FILE * fd, int rotation, double pswidth, double psheight,
986
+ double left_offset, double bottom_offset)
987
+ {
988
+ if ((left_offset != 0.0) || (bottom_offset != 0))
989
+ fprintf (fd, "%f %f translate\n", left_offset, bottom_offset);
990
+
991
+ /* Exchange width and height for 90/270 rotations */
992
+ switch (rotation)
993
+ {
994
+ case 0: fprintf (fd, "%f %f scale\n", pswidth, psheight);
995
+ break;
996
+ case 90: fprintf (fd, "%f %f scale\n1 0 translate 90 rotate\n", psheight, pswidth);
997
+ break;
998
+ case 180: fprintf (fd, "%f %f scale\n1 1 translate 180 rotate\n", pswidth, psheight);
999
+ break;
1000
+ case 270: fprintf (fd, "%f %f scale\n0 1 translate 270 rotate\n", psheight, pswidth);
1001
+ break;
1002
+ default: TIFFError ("psRotateImage", "Unsupported rotation %d.", rotation);
1003
+ fprintf( fd, "%f %f scale\n", pswidth, psheight);
1004
+ return (1);
1005
+ }
1006
+ return (0);
1007
+ }
1008
+
1009
+ /* Scale and rotate an image to a single output page. */
1010
+ int psScaleImage(FILE * fd, double scale, int rotation, int center,
1011
+ double reqwidth, double reqheight, double pswidth, double psheight,
1012
+ double left_offset, double bottom_offset)
1013
+ {
1014
+ double hcenter = 0.0, vcenter = 0.0;
1015
+
1016
+ /* Adjust offsets for centering */
1017
+ if (center)
1018
+ {
1019
+ switch (rotation)
1020
+ {
1021
+ case 90: vcenter = (reqheight - pswidth * scale) / 2;
1022
+ hcenter = (reqwidth - psheight * scale) / 2;
1023
+ fprintf (fd, "%f %f translate\n", hcenter, vcenter);
1024
+ fprintf (fd, "%f %f scale\n1 0 translate 90 rotate\n", psheight * scale, pswidth * scale);
1025
+ break;
1026
+ case 180: hcenter = (reqwidth - pswidth * scale) / 2;
1027
+ vcenter = (reqheight - psheight * scale) / 2;
1028
+ fprintf (fd, "%f %f translate\n", hcenter, vcenter);
1029
+ fprintf (fd, "%f %f scale\n1 1 translate 180 rotate\n", pswidth * scale, psheight * scale);
1030
+ break;
1031
+ case 270: vcenter = (reqheight - pswidth * scale) / 2;
1032
+ hcenter = (reqwidth - psheight * scale) / 2;
1033
+ fprintf (fd, "%f %f translate\n", hcenter, vcenter);
1034
+ fprintf (fd, "%f %f scale\n0 1 translate 270 rotate\n", psheight * scale, pswidth * scale);
1035
+ break;
1036
+ case 0:
1037
+ default: hcenter = (reqwidth - pswidth * scale) / 2;
1038
+ vcenter = (reqheight - psheight * scale) / 2;
1039
+ fprintf (fd, "%f %f translate\n", hcenter, vcenter);
1040
+ fprintf (fd, "%f %f scale\n", pswidth * scale, psheight * scale);
1041
+ break;
1042
+ }
1043
+ }
1044
+ else /* Not centered */
1045
+ {
1046
+ switch (rotation)
1047
+ {
1048
+ case 0: fprintf (fd, "%f %f translate\n", left_offset ? left_offset : 0.0,
1049
+ bottom_offset ? bottom_offset : reqheight - (psheight * scale));
1050
+ fprintf (fd, "%f %f scale\n", pswidth * scale, psheight * scale);
1051
+ break;
1052
+ case 90: fprintf (fd, "%f %f translate\n", left_offset ? left_offset : 0.0,
1053
+ bottom_offset ? bottom_offset : reqheight - (pswidth * scale));
1054
+ fprintf (fd, "%f %f scale\n1 0 translate 90 rotate\n", psheight * scale, pswidth * scale);
1055
+ break;
1056
+ case 180: fprintf (fd, "%f %f translate\n", left_offset ? left_offset : 0.0,
1057
+ bottom_offset ? bottom_offset : reqheight - (psheight * scale));
1058
+ fprintf (fd, "%f %f scale\n1 1 translate 180 rotate\n", pswidth * scale, psheight * scale);
1059
+ break;
1060
+ case 270: fprintf (fd, "%f %f translate\n", left_offset ? left_offset : 0.0,
1061
+ bottom_offset ? bottom_offset : reqheight - (pswidth * scale));
1062
+ fprintf (fd, "%f %f scale\n0 1 translate 270 rotate\n", psheight * scale, pswidth * scale);
1063
+ break;
1064
+ default: TIFFError ("psScaleImage", "Unsupported rotation %d", rotation);
1065
+ fprintf (fd, "%f %f scale\n", pswidth * scale, psheight * scale);
1066
+ return (1);
1067
+ }
1068
+ }
1069
+
1070
+ return (0);
1071
+ }
1072
+
1073
+ /* This controls the visible portion of the page which is displayed.
1074
+ * N.B. Setting maxPageHeight no longer sets pageheight if not set explicitly
1075
+ */
1076
+ int psPageSize (FILE * fd, int rotation, double pgwidth, double pgheight,
1077
+ double reqwidth, double reqheight, double pswidth, double psheight)
1078
+ {
1079
+ double xscale = 1.0, yscale = 1.0, scale = 1.0;
1080
+ double splitheight;
1081
+ double splitwidth;
1082
+ double new_width;
1083
+ double new_height;
1084
+
1085
+ splitheight = maxPageHeight * PS_UNIT_SIZE;
1086
+ splitwidth = maxPageWidth * PS_UNIT_SIZE;
1087
+
1088
+ switch (rotation)
1089
+ {
1090
+ case 0:
1091
+ case 180: if ((splitheight > 0) || (splitwidth > 0))
1092
+ {
1093
+ if (pgwidth != 0 || pgheight != 0)
1094
+ {
1095
+ xscale = reqwidth / (splitwidth ? splitwidth : pswidth);
1096
+ yscale = reqheight / (splitheight ? splitheight : psheight);
1097
+ scale = (xscale < yscale) ? xscale : yscale;
1098
+ }
1099
+ new_width = splitwidth ? splitwidth : scale * pswidth;
1100
+ new_height = splitheight ? splitheight : scale * psheight;
1101
+ if (strlen(pageOrientation))
1102
+ fprintf (fd, "%%%%PageOrientation: %s\n", pageOrientation);
1103
+ else
1104
+ fprintf (fd, "%%%%PageOrientation: %s\n", (new_width > new_height) ? "Landscape" : "Portrait");
1105
+ fprintf (fd, "%%%%PageBoundingBox: 0 0 %ld %ld\n", (long)new_width, (long)new_height);
1106
+ fprintf (fd, "1 dict begin /PageSize [ %f %f ] def currentdict end setpagedevice\n",
1107
+ new_width, new_height);
1108
+ }
1109
+ else /* No viewport defined with -H or -W */
1110
+ {
1111
+ if ((pgwidth == 0) && (pgheight == 0)) /* Image not scaled */
1112
+ {
1113
+ if (strlen(pageOrientation))
1114
+ fprintf (fd, "%%%%PageOrientation: %s\n", pageOrientation);
1115
+ else
1116
+ fprintf (fd, "%%%%PageOrientation: %s\n", (pswidth > psheight) ? "Landscape" : "Portrait");
1117
+ fprintf (fd, "%%%%PageBoundingBox: 0 0 %ld %ld\n", (long)pswidth, (long)psheight);
1118
+ fprintf(fd, "1 dict begin /PageSize [ %f %f ] def currentdict end setpagedevice\n",
1119
+ pswidth, psheight);
1120
+ }
1121
+ else /* Image scaled */
1122
+ {
1123
+ if (strlen(pageOrientation))
1124
+ fprintf (fd, "%%%%PageOrientation: %s\n", pageOrientation);
1125
+ else
1126
+ fprintf (fd, "%%%%PageOrientation: %s\n", (reqwidth > reqheight) ? "Landscape" : "Portrait");
1127
+ fprintf (fd, "%%%%PageBoundingBox: 0 0 %ld %ld\n", (long)reqwidth, (long)reqheight);
1128
+ fprintf(fd, "1 dict begin /PageSize [ %f %f ] def currentdict end setpagedevice\n",
1129
+ reqwidth, reqheight);
1130
+ }
1131
+ }
1132
+ break;
1133
+ case 90:
1134
+ case 270: if ((splitheight > 0) || (splitwidth > 0))
1135
+ {
1136
+ if (pgwidth != 0 || pgheight != 0)
1137
+ {
1138
+ xscale = reqwidth / (splitwidth ? splitwidth : pswidth);
1139
+ yscale = reqheight / (splitheight ? splitheight : psheight);
1140
+ scale = (xscale < yscale) ? xscale : yscale;
1141
+ }
1142
+ new_width = splitwidth ? splitwidth : scale * psheight;
1143
+ new_height = splitheight ? splitheight : scale * pswidth;
1144
+
1145
+ if (strlen(pageOrientation))
1146
+ fprintf (fd, "%%%%PageOrientation: %s\n", pageOrientation);
1147
+ else
1148
+ fprintf (fd, "%%%%PageOrientation: %s\n", (new_width > new_height) ? "Landscape" : "Portrait");
1149
+ fprintf (fd, "%%%%PageBoundingBox: 0 0 %ld %ld\n", (long)new_width, (long)new_height);
1150
+ fprintf (fd, "1 dict begin /PageSize [ %f %f ] def currentdict end setpagedevice\n",
1151
+ new_width, new_height);
1152
+ }
1153
+ else
1154
+ {
1155
+ if ((pgwidth == 0) && (pgheight == 0)) /* Image not scaled */
1156
+ {
1157
+ if (strlen(pageOrientation))
1158
+ fprintf (fd, "%%%%PageOrientation: %s\n", pageOrientation);
1159
+ else
1160
+ fprintf (fd, "%%%%PageOrientation: %s\n", (psheight > pswidth) ? "Landscape" : "Portrait");
1161
+ fprintf (fd, "%%%%PageBoundingBox: 0 0 %ld %ld\n", (long)psheight, (long)pswidth);
1162
+ fprintf(fd, "1 dict begin /PageSize [ %f %f ] def currentdict end setpagedevice\n",
1163
+ psheight, pswidth);
1164
+ }
1165
+ else /* Image scaled */
1166
+ {
1167
+ if (strlen(pageOrientation))
1168
+ fprintf (fd, "%%%%PageOrientation: %s\n", pageOrientation);
1169
+ else
1170
+ fprintf (fd, "%%%%PageOrientation: %s\n", (reqwidth > reqheight) ? "Landscape" : "Portrait");
1171
+ fprintf (fd, "%%%%PageBoundingBox: 0 0 %ld %ld\n", (long)reqwidth, (long)reqheight);
1172
+ fprintf(fd, "1 dict begin /PageSize [ %f %f ] def currentdict end setpagedevice\n",
1173
+ reqwidth, reqheight);
1174
+ }
1175
+ }
1176
+ break;
1177
+ default: TIFFError ("psPageSize", "Invalid rotation %d", rotation);
1178
+ return (1);
1179
+ }
1180
+ fputs("<<\n /Policies <<\n /PageSize 3\n >>\n>> setpagedevice\n", fd);
1181
+
1182
+ return (0);
1183
+ } /* end psPageSize */
1184
+
1185
+ /* Mask an image as a series of pages, each only showing a section defined
1186
+ * by the maxPageHeight or maxPageWidth options.
1187
+ */
1188
+ int psMaskImage(FILE *fd, TIFF *tif, int rotation, int center,
1189
+ int *npages, double pixwidth, double pixheight,
1190
+ double left_margin, double bottom_margin,
1191
+ double pgwidth, double pgheight,
1192
+ double pswidth, double psheight, double scale)
1193
+ {
1194
+ int i, j;
1195
+ int ximages = 1, yimages = 1;
1196
+ int pages = *npages;
1197
+ double view_width = 0;
1198
+ double view_height = 0;
1199
+
1200
+ if (get_viewport (pgwidth, pgheight, pswidth, psheight, &view_width, &view_height, rotation))
1201
+ {
1202
+ TIFFError ("get_viewport", "Unable to set image viewport");
1203
+ return (-1);
1204
+ }
1205
+
1206
+ if (get_subimage_count(pgwidth, pgheight, pswidth, psheight,
1207
+ &ximages, &yimages, rotation, scale) < 1)
1208
+ {
1209
+ TIFFError("get_subimage_count", "Invalid image count: %d columns, %d rows", ximages, yimages);
1210
+ return (-1);
1211
+ }
1212
+
1213
+ for (i = 0; i < yimages; i++)
1214
+ {
1215
+ for (j = 0; j < ximages; j++)
1216
+ {
1217
+ pages++;
1218
+ *npages = pages;
1219
+ fprintf(fd, "%%%%Page: %d %d\n", pages, pages);
1220
+
1221
+ /* Write out the PageSize info for non EPS files */
1222
+ if (!generateEPSF && ( level2 || level3 ))
1223
+ {
1224
+ if (psPageSize(fd, rotation, pgwidth, pgheight,
1225
+ view_width, view_height, pswidth, psheight))
1226
+ return (-1);
1227
+ }
1228
+ fprintf(fd, "gsave\n");
1229
+ fprintf(fd, "100 dict begin\n");
1230
+ if (exportMaskedImage(fd, view_width, view_height, pswidth, psheight,
1231
+ i, j, left_margin, bottom_margin,
1232
+ scale, center, rotation))
1233
+ {
1234
+ TIFFError("exportMaskedImage", "Invalid image parameters.");
1235
+ return (-1);
1236
+ }
1237
+ PSpage(fd, tif, pixwidth, pixheight);
1238
+ fprintf(fd, "end\n");
1239
+ fprintf(fd, "grestore\n");
1240
+ fprintf(fd, "showpage\n");
1241
+ }
1242
+ }
1243
+
1244
+ return (pages);
1245
+ }
1246
+
1247
+ /* Compute scale factor and write out file header */
1248
+ int psStart(FILE *fd, int npages, int auto_rotate, int *rotation, double *scale,
1249
+ double ox, double oy, double pgwidth, double pgheight,
1250
+ double reqwidth, double reqheight, double pswidth, double psheight,
1251
+ double left_offset, double bottom_offset)
1252
+ {
1253
+ double maxsource = 0.0; /* Used for auto rotations */
1254
+ double maxtarget = 0.0;
1255
+ double xscale = 1.0, yscale = 1.0;
1256
+ double splitheight;
1257
+ double splitwidth;
1258
+ double view_width = 0.0, view_height = 0.0;
1259
+ double page_width = 0.0, page_height = 0.0;
1260
+
1261
+ /* Splitheight and splitwidth are in inches */
1262
+ splitheight = maxPageHeight * PS_UNIT_SIZE;
1263
+ splitwidth = maxPageWidth * PS_UNIT_SIZE;
1264
+
1265
+ page_width = pgwidth * PS_UNIT_SIZE;
1266
+ page_height = pgheight * PS_UNIT_SIZE;
1267
+
1268
+ /* If user has specified a page width and height and requested the
1269
+ * image to be auto-rotated to fit on that media, we match the
1270
+ * longest dimension of the image to the longest dimension of the
1271
+ * target media but we have to ignore auto rotate if user specified
1272
+ * maxPageHeight since this makes life way too complicated. */
1273
+ if (auto_rotate)
1274
+ {
1275
+ if ((splitheight != 0) || (splitwidth != 0))
1276
+ {
1277
+ TIFFError ("psStart", "Auto-rotate is incompatible with page splitting ");
1278
+ return (1);
1279
+ }
1280
+
1281
+ /* Find longest edges in image and output media */
1282
+ maxsource = (pswidth >= psheight) ? pswidth : psheight;
1283
+ maxtarget = (reqwidth >= reqheight) ? reqwidth : reqheight;
1284
+
1285
+ if (((maxsource == pswidth) && (maxtarget != reqwidth)) ||
1286
+ ((maxsource == psheight) && (maxtarget != reqheight)))
1287
+ { /* optimal orientaion does not match input orientation */
1288
+ *rotation = 90;
1289
+ xscale = (reqwidth - left_offset)/psheight;
1290
+ yscale = (reqheight - bottom_offset)/pswidth;
1291
+ }
1292
+ else /* optimal orientaion matches input orientation */
1293
+ {
1294
+ xscale = (reqwidth - left_offset)/pswidth;
1295
+ yscale = (reqheight - bottom_offset)/psheight;
1296
+ }
1297
+ *scale = (xscale < yscale) ? xscale : yscale;
1298
+
1299
+ /* Do not scale image beyound original size */
1300
+ if (*scale > 1.0)
1301
+ *scale = 1.0;
1302
+
1303
+ /* Set the size of the displayed image to requested page size
1304
+ * and optimal orientation.
1305
+ */
1306
+ if (!npages)
1307
+ PSHead(fd, reqwidth, reqheight, ox, oy);
1308
+
1309
+ return (0);
1310
+ }
1311
+
1312
+ /* N.B. If pgwidth or pgheight are set from maxPageHeight/Width,
1313
+ * we have a problem with the tests below under splitheight.
1314
+ */
1315
+
1316
+ switch (*rotation) /* Auto rotate has NOT been specified */
1317
+ {
1318
+ case 0:
1319
+ case 180: if ((splitheight != 0) || (splitwidth != 0))
1320
+ { /* Viewport clipped to maxPageHeight or maxPageWidth */
1321
+ if ((page_width != 0) || (page_height != 0)) /* Image scaled */
1322
+ {
1323
+ xscale = (reqwidth - left_offset) / (page_width ? page_width : pswidth);
1324
+ yscale = (reqheight - bottom_offset) / (page_height ? page_height : psheight);
1325
+ *scale = (xscale < yscale) ? xscale : yscale;
1326
+ /*
1327
+ if (*scale > 1.0)
1328
+ *scale = 1.0;
1329
+ */
1330
+ }
1331
+ else /* Image clipped but not scaled */
1332
+ *scale = 1.0;
1333
+
1334
+ view_width = splitwidth ? splitwidth : *scale * pswidth;
1335
+ view_height = splitheight ? splitheight: *scale * psheight;
1336
+ }
1337
+ else /* Viewport not clipped to maxPageHeight or maxPageWidth */
1338
+ {
1339
+ if ((page_width != 0) || (page_height != 0))
1340
+ { /* Image scaled */
1341
+ xscale = (reqwidth - left_offset) / pswidth;
1342
+ yscale = (reqheight - bottom_offset) / psheight;
1343
+
1344
+ view_width = reqwidth;
1345
+ view_height = reqheight;
1346
+ }
1347
+ else
1348
+ { /* Image not scaled */
1349
+ xscale = (pswidth - left_offset)/pswidth;
1350
+ yscale = (psheight - bottom_offset)/psheight;
1351
+
1352
+ view_width = pswidth;
1353
+ view_height = psheight;
1354
+ }
1355
+ }
1356
+ break;
1357
+ case 90:
1358
+ case 270: if ((splitheight != 0) || (splitwidth != 0))
1359
+ { /* Viewport clipped to maxPageHeight or maxPageWidth */
1360
+ if ((page_width != 0) || (page_height != 0)) /* Image scaled */
1361
+ {
1362
+ xscale = (reqwidth - left_offset)/ psheight;
1363
+ yscale = (reqheight - bottom_offset)/ pswidth;
1364
+ *scale = (xscale < yscale) ? xscale : yscale;
1365
+ /*
1366
+ if (*scale > 1.0)
1367
+ *scale = 1.0;
1368
+ */
1369
+ }
1370
+ else /* Image clipped but not scaled */
1371
+ *scale = 1.0;
1372
+ view_width = splitwidth ? splitwidth : *scale * psheight;
1373
+ view_height = splitheight ? splitheight : *scale * pswidth;
1374
+ }
1375
+ else /* Viewport not clipped to maxPageHeight or maxPageWidth */
1376
+ {
1377
+ if ((page_width != 0) || (page_height != 0)) /* Image scaled */
1378
+ {
1379
+ xscale = (reqwidth - left_offset) / psheight;
1380
+ yscale = (reqheight - bottom_offset) / pswidth;
1381
+
1382
+ view_width = reqwidth;
1383
+ view_height = reqheight;
1384
+ }
1385
+ else
1386
+ {
1387
+ xscale = (pswidth - left_offset)/ psheight;
1388
+ yscale = (psheight - bottom_offset)/ pswidth;
1389
+
1390
+ view_width = psheight;
1391
+ view_height = pswidth;
1392
+ }
1393
+ }
1394
+ break;
1395
+ default: TIFFError ("psPageSize", "Invalid rotation %d", *rotation);
1396
+ return (1);
1397
+ }
1398
+
1399
+ if (!npages)
1400
+ PSHead(fd, (page_width ? page_width : view_width), (page_height ? page_height : view_height), ox, oy);
1401
+
1402
+ *scale = (xscale < yscale) ? xscale : yscale;
1403
+ if (*scale > 1.0)
1404
+ *scale = 1.0;
1405
+
1406
+ return (0);
1407
+ }
1408
+
1409
+ int get_viewport (double pgwidth, double pgheight, double pswidth, double psheight,
1410
+ double *view_width, double *view_height, int rotation)
1411
+ {
1412
+ /* Only one of maxPageHeight or maxPageWidth can be specified */
1413
+ if (maxPageHeight != 0) /* Clip the viewport to maxPageHeight on each page */
1414
+ {
1415
+ if (pgheight != 0 && pgheight < maxPageHeight)
1416
+ *view_height = pgheight * PS_UNIT_SIZE;
1417
+ else
1418
+ *view_height = maxPageHeight * PS_UNIT_SIZE;
1419
+ /*
1420
+ * if (res_unit == RESUNIT_CENTIMETER)
1421
+ * *view_height /= 2.54F;
1422
+ */
1423
+ }
1424
+ else
1425
+ {
1426
+ if (pgheight != 0) /* User has set PageHeight with -h flag */
1427
+ {
1428
+ *view_height = pgheight * PS_UNIT_SIZE; /* Postscript size for Page Height in inches */
1429
+ /* if (res_unit == RESUNIT_CENTIMETER)
1430
+ * *view_height /= 2.54F;
1431
+ */
1432
+ }
1433
+ else /* If no width or height are specified, use the original size from image */
1434
+ switch (rotation)
1435
+ {
1436
+ default:
1437
+ case 0:
1438
+ case 180: *view_height = psheight;
1439
+ break;
1440
+ case 90:
1441
+ case 270: *view_height = pswidth;
1442
+ break;
1443
+ }
1444
+ }
1445
+
1446
+ if (maxPageWidth != 0) /* Clip the viewport to maxPageWidth on each page */
1447
+ {
1448
+ if (pgwidth != 0 && pgwidth < maxPageWidth)
1449
+ *view_width = pgwidth * PS_UNIT_SIZE;
1450
+ else
1451
+ *view_width = maxPageWidth * PS_UNIT_SIZE;
1452
+ /* if (res_unit == RESUNIT_CENTIMETER)
1453
+ * *view_width /= 2.54F;
1454
+ */
1455
+ }
1456
+ else
1457
+ {
1458
+ if (pgwidth != 0) /* User has set PageWidth with -w flag */
1459
+ {
1460
+ *view_width = pgwidth * PS_UNIT_SIZE; /* Postscript size for Page Width in inches */
1461
+ /* if (res_unit == RESUNIT_CENTIMETER)
1462
+ * *view_width /= 2.54F;
1463
+ */
1464
+ }
1465
+ else /* If no width or height are specified, use the original size from image */
1466
+ switch (rotation)
1467
+ {
1468
+ default:
1469
+ case 0:
1470
+ case 180: *view_width = pswidth;
1471
+ break;
1472
+ case 90:
1473
+ case 270: *view_width = psheight; /* (*view_height / psheight) * psheight; */
1474
+ break;
1475
+ }
1476
+ }
1477
+
1478
+ return (0);
1479
+ }
1480
+
1481
+ /* pgwidth and pgheight specify page width and height in inches from -h and -w flags
1482
+ * lm and bm are the LeftMargin and BottomMargin in inches
1483
+ * center causes the image to be centered on the page if the paper size is
1484
+ * larger than the image size
1485
+ * returns the sequence number of the page processed or -1 on error
1486
+ */
1487
+
1488
+ int TIFF2PS(FILE* fd, TIFF* tif, double pgwidth, double pgheight, double lm, double bm, int center)
1489
+ {
1490
+ uint32 pixwidth = 0, pixheight = 0; /* Image width and height in pixels */
1491
+ double ox = 0.0, oy = 0.0; /* Offset from current Postscript origin */
1492
+ double pswidth, psheight; /* Original raw image width and height in points */
1493
+ double view_width, view_height; /* Viewport width and height in points */
1494
+ double scale = 1.0;
1495
+ double left_offset = lm * PS_UNIT_SIZE;
1496
+ double bottom_offset = bm * PS_UNIT_SIZE;
1497
+ uint32 subfiletype;
1498
+ uint16* sampleinfo;
1499
+ static int npages = 0;
1500
+
1501
+ if (!TIFFGetField(tif, TIFFTAG_XPOSITION, &ox))
1502
+ ox = 0;
1503
+ if (!TIFFGetField(tif, TIFFTAG_YPOSITION, &oy))
1504
+ oy = 0;
1505
+
1506
+ /* Consolidated all the tag information into one code segment, Richard Nolde */
1507
+ do {
1508
+ tf_numberstrips = TIFFNumberOfStrips(tif);
1509
+ TIFFGetFieldDefaulted(tif, TIFFTAG_ROWSPERSTRIP, &tf_rowsperstrip);
1510
+ TIFFGetFieldDefaulted(tif, TIFFTAG_BITSPERSAMPLE, &bitspersample);
1511
+ TIFFGetFieldDefaulted(tif, TIFFTAG_SAMPLESPERPIXEL, &samplesperpixel);
1512
+ TIFFGetFieldDefaulted(tif, TIFFTAG_PLANARCONFIG, &planarconfiguration);
1513
+ TIFFGetField(tif, TIFFTAG_COMPRESSION, &compression);
1514
+ TIFFGetFieldDefaulted(tif, TIFFTAG_EXTRASAMPLES, &extrasamples, &sampleinfo);
1515
+ alpha = (extrasamples == 1 && sampleinfo[0] == EXTRASAMPLE_ASSOCALPHA);
1516
+ if (!TIFFGetField(tif, TIFFTAG_PHOTOMETRIC, &photometric))
1517
+ {
1518
+ switch (samplesperpixel - extrasamples)
1519
+ {
1520
+ case 1: if (isCCITTCompression(tif))
1521
+ photometric = PHOTOMETRIC_MINISWHITE;
1522
+ else
1523
+ photometric = PHOTOMETRIC_MINISBLACK;
1524
+ break;
1525
+ case 3: photometric = PHOTOMETRIC_RGB;
1526
+ break;
1527
+ case 4: photometric = PHOTOMETRIC_SEPARATED;
1528
+ break;
1529
+ }
1530
+ }
1531
+
1532
+ /* Read image tags for width and height in pixels pixwidth, pixheight,
1533
+ * and convert to points pswidth, psheight
1534
+ */
1535
+ setupPageState(tif, &pixwidth, &pixheight, &pswidth, &psheight);
1536
+ view_width = pswidth;
1537
+ view_height = psheight;
1538
+
1539
+ if (get_viewport (pgwidth, pgheight, pswidth, psheight, &view_width, &view_height, rotation))
1540
+ {
1541
+ TIFFError("get_viewport", "Unable to set image viewport");
1542
+ return (1);
1543
+ }
1544
+
1545
+ /* Write the Postscript file header with Bounding Box and Page Size definitions */
1546
+ if (psStart(fd, npages, auto_rotate, &rotation, &scale, ox, oy,
1547
+ pgwidth, pgheight, view_width, view_height, pswidth, psheight,
1548
+ left_offset, bottom_offset))
1549
+ return (-1);
1550
+
1551
+ if (checkImage(tif)) /* Aborts if unsupported image parameters */
1552
+ {
1553
+ tf_bytesperrow = TIFFScanlineSize(tif);
1554
+
1555
+ /* Set viewport clipping and scaling options */
1556
+ if ((maxPageHeight) || (maxPageWidth) || (pgwidth != 0) || (pgheight != 0))
1557
+ {
1558
+ if ((maxPageHeight) || (maxPageWidth)) /* used -H or -W option */
1559
+ {
1560
+ if (psMaskImage(fd, tif, rotation, center, &npages, pixwidth, pixheight,
1561
+ left_offset, bottom_offset, pgwidth, pgheight,
1562
+ pswidth, psheight, scale) < 0)
1563
+ return (-1);
1564
+ }
1565
+ else /* N.B. Setting maxPageHeight no longer sets pgheight */
1566
+ {
1567
+ if (pgwidth != 0 || pgheight != 0)
1568
+ {
1569
+ /* User did not specify a maxium page height or width using -H or -W flag
1570
+ * but did use -h or -w flag to scale to a specific size page.
1571
+ */
1572
+ npages++;
1573
+ fprintf(fd, "%%%%Page: %d %d\n", npages, npages);
1574
+
1575
+ if (!generateEPSF && ( level2 || level3 ))
1576
+ {
1577
+ /* Write out the PageSize info for non EPS files */
1578
+ if (psPageSize(fd, rotation, pgwidth, pgheight,
1579
+ view_width, view_height, pswidth, psheight))
1580
+ return (-1);
1581
+ }
1582
+ fprintf(fd, "gsave\n");
1583
+ fprintf(fd, "100 dict begin\n");
1584
+ if (psScaleImage(fd, scale, rotation, center, view_width, view_height,
1585
+ pswidth, psheight, left_offset, bottom_offset))
1586
+ return (-1);
1587
+
1588
+ PSpage(fd, tif, pixwidth, pixheight);
1589
+ fprintf(fd, "end\n");
1590
+ fprintf(fd, "grestore\n");
1591
+ fprintf(fd, "showpage\n");
1592
+ }
1593
+ }
1594
+ }
1595
+ else /* Simple rotation: user did not use -H, -W, -h or -w */
1596
+ {
1597
+ npages++;
1598
+ fprintf(fd, "%%%%Page: %d %d\n", npages, npages);
1599
+
1600
+ if (!generateEPSF && ( level2 || level3 ))
1601
+ {
1602
+ /* Write out the PageSize info for non EPS files */
1603
+ if (psPageSize(fd, rotation, pgwidth, pgheight,
1604
+ view_width, view_height, pswidth, psheight))
1605
+ return (-1);
1606
+ }
1607
+ fprintf(fd, "gsave\n");
1608
+ fprintf(fd, "100 dict begin\n");
1609
+ if (psRotateImage(fd, rotation, pswidth, psheight, left_offset, bottom_offset))
1610
+ return (-1);
1611
+
1612
+ PSpage(fd, tif, pixwidth, pixheight);
1613
+ fprintf(fd, "end\n");
1614
+ fprintf(fd, "grestore\n");
1615
+ fprintf(fd, "showpage\n");
1616
+ }
1617
+ }
1618
+ if (generateEPSF)
1619
+ break;
1620
+ if (auto_rotate)
1621
+ rotation = 0.0;
1622
+ TIFFGetFieldDefaulted(tif, TIFFTAG_SUBFILETYPE, &subfiletype);
1623
+ } while (((subfiletype & FILETYPE_PAGE) || printAll) && TIFFReadDirectory(tif));
1624
+
1625
+ return(npages);
1626
+ }
1627
+
1628
+ static char DuplexPreamble[] = "\
1629
+ %%BeginFeature: *Duplex True\n\
1630
+ systemdict begin\n\
1631
+ /languagelevel where { pop languagelevel } { 1 } ifelse\n\
1632
+ 2 ge { 1 dict dup /Duplex true put setpagedevice }\n\
1633
+ { statusdict /setduplex known { statusdict begin setduplex true end } if\n\
1634
+ } ifelse\n\
1635
+ end\n\
1636
+ %%EndFeature\n\
1637
+ ";
1638
+
1639
+ static char TumblePreamble[] = "\
1640
+ %%BeginFeature: *Tumble True\n\
1641
+ systemdict begin\n\
1642
+ /languagelevel where { pop languagelevel } { 1 } ifelse\n\
1643
+ 2 ge { 1 dict dup /Tumble true put setpagedevice }\n\
1644
+ { statusdict /settumble known { statusdict begin true settumble end } if\n\
1645
+ } ifelse\n\
1646
+ end\n\
1647
+ %%EndFeature\n\
1648
+ ";
1649
+
1650
+ static char AvoidDeadZonePreamble[] = "\
1651
+ gsave newpath clippath pathbbox grestore\n\
1652
+ 4 2 roll 2 copy translate\n\
1653
+ exch 3 1 roll sub 3 1 roll sub exch\n\
1654
+ currentpagedevice /PageSize get aload pop\n\
1655
+ exch 3 1 roll div 3 1 roll div abs exch abs\n\
1656
+ 2 copy gt { exch } if pop\n\
1657
+ dup 1 lt { dup scale } { pop } ifelse\n\
1658
+ ";
1659
+
1660
+ void
1661
+ PSHead(FILE *fd, double pagewidth, double pageheight, double xoff, double yoff)
1662
+ {
1663
+ time_t t;
1664
+
1665
+ t = time(0);
1666
+ fprintf(fd, "%%!PS-Adobe-3.0%s\n", generateEPSF ? " EPSF-3.0" : "");
1667
+ fprintf(fd, "%%%%Creator: %s\n", creator ? creator : "tiff2ps");
1668
+ fprintf(fd, "%%%%Title: %s\n", title ? title : filename);
1669
+ fprintf(fd, "%%%%CreationDate: %s", ctime(&t));
1670
+ fprintf(fd, "%%%%DocumentData: Clean7Bit\n");
1671
+ /* NB: should use PageBoundingBox for each page instead of BoundingBox *
1672
+ * PageBoundingBox DSC added in PSPageSize function, R Nolde 09-01-2010
1673
+ */
1674
+ fprintf(fd, "%%%%Origin: %ld %ld\n", (long) xoff, (long) yoff);
1675
+ fprintf(fd, "%%%%BoundingBox: 0 0 %ld %ld\n",
1676
+ (long) ceil(pagewidth), (long) ceil(pageheight));
1677
+
1678
+ fprintf(fd, "%%%%LanguageLevel: %d\n", (level3 ? 3 : (level2 ? 2 : 1)));
1679
+ if (generateEPSF == TRUE)
1680
+ fprintf(fd, "%%%%Pages: 1 1\n");
1681
+ else
1682
+ fprintf(fd, "%%%%Pages: (atend)\n");
1683
+ fprintf(fd, "%%%%EndComments\n");
1684
+ if (generateEPSF == FALSE)
1685
+ {
1686
+ fprintf(fd, "%%%%BeginSetup\n");
1687
+ if (PSduplex)
1688
+ fprintf(fd, "%s", DuplexPreamble);
1689
+ if (PStumble)
1690
+ fprintf(fd, "%s", TumblePreamble);
1691
+ if (PSavoiddeadzone && (level2 || level3))
1692
+ fprintf(fd, "%s", AvoidDeadZonePreamble);
1693
+ fprintf(fd, "%%%%EndSetup\n");
1694
+ }
1695
+ }
1696
+
1697
+ void
1698
+ PSTail(FILE *fd, int npages)
1699
+ {
1700
+ fprintf(fd, "%%%%Trailer\n");
1701
+ if (generateEPSF == FALSE)
1702
+ fprintf(fd, "%%%%Pages: %d\n", npages);
1703
+ fprintf(fd, "%%%%EOF\n");
1704
+ }
1705
+
1706
+ static int
1707
+ checkcmap(TIFF* tif, int n, uint16* r, uint16* g, uint16* b)
1708
+ {
1709
+ (void) tif;
1710
+ while (n-- > 0)
1711
+ if (*r++ >= 256 || *g++ >= 256 || *b++ >= 256)
1712
+ return (16);
1713
+ TIFFWarning(filename, "Assuming 8-bit colormap");
1714
+ return (8);
1715
+ }
1716
+
1717
+ static void
1718
+ PS_Lvl2colorspace(FILE* fd, TIFF* tif)
1719
+ {
1720
+ uint16 *rmap, *gmap, *bmap;
1721
+ int i, num_colors;
1722
+ const char * colorspace_p;
1723
+
1724
+ switch ( photometric )
1725
+ {
1726
+ case PHOTOMETRIC_SEPARATED:
1727
+ colorspace_p = "CMYK";
1728
+ break;
1729
+
1730
+ case PHOTOMETRIC_RGB:
1731
+ colorspace_p = "RGB";
1732
+ break;
1733
+
1734
+ default:
1735
+ colorspace_p = "Gray";
1736
+ }
1737
+
1738
+ /*
1739
+ * Set up PostScript Level 2 colorspace according to
1740
+ * section 4.8 in the PostScript refenence manual.
1741
+ */
1742
+ fputs("% PostScript Level 2 only.\n", fd);
1743
+ if (photometric != PHOTOMETRIC_PALETTE) {
1744
+ if (photometric == PHOTOMETRIC_YCBCR) {
1745
+ /* MORE CODE HERE */
1746
+ }
1747
+ fprintf(fd, "/Device%s setcolorspace\n", colorspace_p );
1748
+ return;
1749
+ }
1750
+
1751
+ /*
1752
+ * Set up an indexed/palette colorspace
1753
+ */
1754
+ num_colors = (1 << bitspersample);
1755
+ if (!TIFFGetField(tif, TIFFTAG_COLORMAP, &rmap, &gmap, &bmap)) {
1756
+ TIFFError(filename,
1757
+ "Palette image w/o \"Colormap\" tag");
1758
+ return;
1759
+ }
1760
+ if (checkcmap(tif, num_colors, rmap, gmap, bmap) == 16) {
1761
+ /*
1762
+ * Convert colormap to 8-bits values.
1763
+ */
1764
+ #define CVT(x) (((x) * 255) / ((1L<<16)-1))
1765
+ for (i = 0; i < num_colors; i++) {
1766
+ rmap[i] = CVT(rmap[i]);
1767
+ gmap[i] = CVT(gmap[i]);
1768
+ bmap[i] = CVT(bmap[i]);
1769
+ }
1770
+ #undef CVT
1771
+ }
1772
+ fprintf(fd, "[ /Indexed /DeviceRGB %d", num_colors - 1);
1773
+ if (ascii85) {
1774
+ Ascii85Init();
1775
+ fputs("\n<~", fd);
1776
+ ascii85breaklen -= 2;
1777
+ } else
1778
+ fputs(" <", fd);
1779
+ for (i = 0; i < num_colors; i++) {
1780
+ if (ascii85) {
1781
+ Ascii85Put((unsigned char)rmap[i], fd);
1782
+ Ascii85Put((unsigned char)gmap[i], fd);
1783
+ Ascii85Put((unsigned char)bmap[i], fd);
1784
+ } else {
1785
+ fputs((i % 8) ? " " : "\n ", fd);
1786
+ fprintf(fd, "%02x%02x%02x",
1787
+ rmap[i], gmap[i], bmap[i]);
1788
+ }
1789
+ }
1790
+ if (ascii85)
1791
+ Ascii85Flush(fd);
1792
+ else
1793
+ fputs(">\n", fd);
1794
+ fputs("] setcolorspace\n", fd);
1795
+ }
1796
+
1797
+ static int
1798
+ PS_Lvl2ImageDict(FILE* fd, TIFF* tif, uint32 w, uint32 h)
1799
+ {
1800
+ int use_rawdata;
1801
+ uint32 tile_width, tile_height;
1802
+ uint16 predictor, minsamplevalue, maxsamplevalue;
1803
+ int repeat_count;
1804
+ char im_h[64], im_x[64], im_y[64];
1805
+ char * imageOp = "image";
1806
+
1807
+ if ( useImagemask && (bitspersample == 1) )
1808
+ imageOp = "imagemask";
1809
+
1810
+ (void)strcpy(im_x, "0");
1811
+ (void)snprintf(im_y, sizeof(im_y), "%lu", (long) h);
1812
+ (void)snprintf(im_h, sizeof(im_h), "%lu", (long) h);
1813
+ tile_width = w;
1814
+ tile_height = h;
1815
+ if (TIFFIsTiled(tif)) {
1816
+ repeat_count = TIFFNumberOfTiles(tif);
1817
+ TIFFGetField(tif, TIFFTAG_TILEWIDTH, &tile_width);
1818
+ TIFFGetField(tif, TIFFTAG_TILELENGTH, &tile_height);
1819
+ if (tile_width > w || tile_height > h ||
1820
+ (w % tile_width) != 0 || (h % tile_height != 0)) {
1821
+ /*
1822
+ * The tiles does not fit image width and height.
1823
+ * Set up a clip rectangle for the image unit square.
1824
+ */
1825
+ fputs("0 0 1 1 rectclip\n", fd);
1826
+ }
1827
+ if (tile_width < w) {
1828
+ fputs("/im_x 0 def\n", fd);
1829
+ (void)strcpy(im_x, "im_x neg");
1830
+ }
1831
+ if (tile_height < h) {
1832
+ fputs("/im_y 0 def\n", fd);
1833
+ (void)snprintf(im_y, sizeof(im_y), "%lu im_y sub", (unsigned long) h);
1834
+ }
1835
+ } else {
1836
+ repeat_count = tf_numberstrips;
1837
+ tile_height = tf_rowsperstrip;
1838
+ if (tile_height > h)
1839
+ tile_height = h;
1840
+ if (repeat_count > 1) {
1841
+ fputs("/im_y 0 def\n", fd);
1842
+ fprintf(fd, "/im_h %lu def\n",
1843
+ (unsigned long) tile_height);
1844
+ (void)strcpy(im_h, "im_h");
1845
+ (void)snprintf(im_y, sizeof(im_y), "%lu im_y sub", (unsigned long) h);
1846
+ }
1847
+ }
1848
+
1849
+ /*
1850
+ * Output start of exec block
1851
+ */
1852
+ fputs("{ % exec\n", fd);
1853
+
1854
+ if (repeat_count > 1)
1855
+ fprintf(fd, "%d { %% repeat\n", repeat_count);
1856
+
1857
+ /*
1858
+ * Output filter options and image dictionary.
1859
+ */
1860
+ if (ascii85)
1861
+ fputs(" /im_stream currentfile /ASCII85Decode filter def\n",
1862
+ fd);
1863
+ fputs(" <<\n", fd);
1864
+ fputs(" /ImageType 1\n", fd);
1865
+ fprintf(fd, " /Width %lu\n", (unsigned long) tile_width);
1866
+ /*
1867
+ * Workaround for some software that may crash when last strip
1868
+ * of image contains fewer number of scanlines than specified
1869
+ * by the `/Height' variable. So for stripped images with multiple
1870
+ * strips we will set `/Height' as `im_h', because one is
1871
+ * recalculated for each strip - including the (smaller) final strip.
1872
+ * For tiled images and images with only one strip `/Height' will
1873
+ * contain number of scanlines in tile (or image height in case of
1874
+ * one-stripped image).
1875
+ */
1876
+ if (TIFFIsTiled(tif) || tf_numberstrips == 1)
1877
+ fprintf(fd, " /Height %lu\n", (unsigned long) tile_height);
1878
+ else
1879
+ fprintf(fd, " /Height im_h\n");
1880
+
1881
+ if (planarconfiguration == PLANARCONFIG_SEPARATE && samplesperpixel > 1)
1882
+ fputs(" /MultipleDataSources true\n", fd);
1883
+ fprintf(fd, " /ImageMatrix [ %lu 0 0 %ld %s %s ]\n",
1884
+ (unsigned long) w, - (long)h, im_x, im_y);
1885
+ fprintf(fd, " /BitsPerComponent %d\n", bitspersample);
1886
+ fprintf(fd, " /Interpolate %s\n", interpolate ? "true" : "false");
1887
+
1888
+ switch (samplesperpixel - extrasamples) {
1889
+ case 1:
1890
+ switch (photometric) {
1891
+ case PHOTOMETRIC_MINISBLACK:
1892
+ fputs(" /Decode [0 1]\n", fd);
1893
+ break;
1894
+ case PHOTOMETRIC_MINISWHITE:
1895
+ switch (compression) {
1896
+ case COMPRESSION_CCITTRLE:
1897
+ case COMPRESSION_CCITTRLEW:
1898
+ case COMPRESSION_CCITTFAX3:
1899
+ case COMPRESSION_CCITTFAX4:
1900
+ /*
1901
+ * Manage inverting with /Blackis1 flag
1902
+ * since there migth be uncompressed parts
1903
+ */
1904
+ fputs(" /Decode [0 1]\n", fd);
1905
+ break;
1906
+ default:
1907
+ /*
1908
+ * ERROR...
1909
+ */
1910
+ fputs(" /Decode [1 0]\n", fd);
1911
+ break;
1912
+ }
1913
+ break;
1914
+ case PHOTOMETRIC_PALETTE:
1915
+ TIFFGetFieldDefaulted(tif, TIFFTAG_MINSAMPLEVALUE,
1916
+ &minsamplevalue);
1917
+ TIFFGetFieldDefaulted(tif, TIFFTAG_MAXSAMPLEVALUE,
1918
+ &maxsamplevalue);
1919
+ fprintf(fd, " /Decode [%u %u]\n",
1920
+ minsamplevalue, maxsamplevalue);
1921
+ break;
1922
+ default:
1923
+ /*
1924
+ * ERROR ?
1925
+ */
1926
+ fputs(" /Decode [0 1]\n", fd);
1927
+ break;
1928
+ }
1929
+ break;
1930
+ case 3:
1931
+ switch (photometric) {
1932
+ case PHOTOMETRIC_RGB:
1933
+ fputs(" /Decode [0 1 0 1 0 1]\n", fd);
1934
+ break;
1935
+ case PHOTOMETRIC_MINISWHITE:
1936
+ case PHOTOMETRIC_MINISBLACK:
1937
+ default:
1938
+ /*
1939
+ * ERROR??
1940
+ */
1941
+ fputs(" /Decode [0 1 0 1 0 1]\n", fd);
1942
+ break;
1943
+ }
1944
+ break;
1945
+ case 4:
1946
+ /*
1947
+ * ERROR??
1948
+ */
1949
+ fputs(" /Decode [0 1 0 1 0 1 0 1]\n", fd);
1950
+ break;
1951
+ }
1952
+ fputs(" /DataSource", fd);
1953
+ if (planarconfiguration == PLANARCONFIG_SEPARATE &&
1954
+ samplesperpixel > 1)
1955
+ fputs(" [", fd);
1956
+ if (ascii85)
1957
+ fputs(" im_stream", fd);
1958
+ else
1959
+ fputs(" currentfile /ASCIIHexDecode filter", fd);
1960
+
1961
+ use_rawdata = TRUE;
1962
+ switch (compression) {
1963
+ case COMPRESSION_NONE: /* 1: uncompressed */
1964
+ break;
1965
+ case COMPRESSION_CCITTRLE: /* 2: CCITT modified Huffman RLE */
1966
+ case COMPRESSION_CCITTRLEW: /* 32771: #1 w/ word alignment */
1967
+ case COMPRESSION_CCITTFAX3: /* 3: CCITT Group 3 fax encoding */
1968
+ case COMPRESSION_CCITTFAX4: /* 4: CCITT Group 4 fax encoding */
1969
+ fputs("\n\t<<\n", fd);
1970
+ if (compression == COMPRESSION_CCITTFAX3) {
1971
+ uint32 g3_options;
1972
+
1973
+ fputs("\t /EndOfLine true\n", fd);
1974
+ fputs("\t /EndOfBlock false\n", fd);
1975
+ if (!TIFFGetField(tif, TIFFTAG_GROUP3OPTIONS,
1976
+ &g3_options))
1977
+ g3_options = 0;
1978
+ if (g3_options & GROUP3OPT_2DENCODING)
1979
+ fprintf(fd, "\t /K %s\n", im_h);
1980
+ if (g3_options & GROUP3OPT_UNCOMPRESSED)
1981
+ fputs("\t /Uncompressed true\n", fd);
1982
+ if (g3_options & GROUP3OPT_FILLBITS)
1983
+ fputs("\t /EncodedByteAlign true\n", fd);
1984
+ }
1985
+ if (compression == COMPRESSION_CCITTFAX4) {
1986
+ uint32 g4_options;
1987
+
1988
+ fputs("\t /K -1\n", fd);
1989
+ TIFFGetFieldDefaulted(tif, TIFFTAG_GROUP4OPTIONS,
1990
+ &g4_options);
1991
+ if (g4_options & GROUP4OPT_UNCOMPRESSED)
1992
+ fputs("\t /Uncompressed true\n", fd);
1993
+ }
1994
+ if (!(tile_width == w && w == 1728U))
1995
+ fprintf(fd, "\t /Columns %lu\n",
1996
+ (unsigned long) tile_width);
1997
+ fprintf(fd, "\t /Rows %s\n", im_h);
1998
+ if (compression == COMPRESSION_CCITTRLE ||
1999
+ compression == COMPRESSION_CCITTRLEW) {
2000
+ fputs("\t /EncodedByteAlign true\n", fd);
2001
+ fputs("\t /EndOfBlock false\n", fd);
2002
+ }
2003
+ if (photometric == PHOTOMETRIC_MINISBLACK)
2004
+ fputs("\t /BlackIs1 true\n", fd);
2005
+ fprintf(fd, "\t>> /CCITTFaxDecode filter");
2006
+ break;
2007
+ case COMPRESSION_LZW: /* 5: Lempel-Ziv & Welch */
2008
+ TIFFGetFieldDefaulted(tif, TIFFTAG_PREDICTOR, &predictor);
2009
+ if (predictor == 2) {
2010
+ fputs("\n\t<<\n", fd);
2011
+ fprintf(fd, "\t /Predictor %u\n", predictor);
2012
+ fprintf(fd, "\t /Columns %lu\n",
2013
+ (unsigned long) tile_width);
2014
+ fprintf(fd, "\t /Colors %u\n", samplesperpixel);
2015
+ fprintf(fd, "\t /BitsPerComponent %u\n",
2016
+ bitspersample);
2017
+ fputs("\t>>", fd);
2018
+ }
2019
+ fputs(" /LZWDecode filter", fd);
2020
+ break;
2021
+ case COMPRESSION_DEFLATE: /* 5: ZIP */
2022
+ case COMPRESSION_ADOBE_DEFLATE:
2023
+ if ( level3 ) {
2024
+ TIFFGetFieldDefaulted(tif, TIFFTAG_PREDICTOR, &predictor);
2025
+ if (predictor > 1) {
2026
+ fprintf(fd, "\t %% PostScript Level 3 only.");
2027
+ fputs("\n\t<<\n", fd);
2028
+ fprintf(fd, "\t /Predictor %u\n", predictor);
2029
+ fprintf(fd, "\t /Columns %lu\n",
2030
+ (unsigned long) tile_width);
2031
+ fprintf(fd, "\t /Colors %u\n", samplesperpixel);
2032
+ fprintf(fd, "\t /BitsPerComponent %u\n",
2033
+ bitspersample);
2034
+ fputs("\t>>", fd);
2035
+ }
2036
+ fputs(" /FlateDecode filter", fd);
2037
+ } else {
2038
+ use_rawdata = FALSE ;
2039
+ }
2040
+ break;
2041
+ case COMPRESSION_PACKBITS: /* 32773: Macintosh RLE */
2042
+ fputs(" /RunLengthDecode filter", fd);
2043
+ use_rawdata = TRUE;
2044
+ break;
2045
+ case COMPRESSION_OJPEG: /* 6: !6.0 JPEG */
2046
+ case COMPRESSION_JPEG: /* 7: %JPEG DCT compression */
2047
+ #ifdef notdef
2048
+ /*
2049
+ * Code not tested yet
2050
+ */
2051
+ fputs(" /DCTDecode filter", fd);
2052
+ use_rawdata = TRUE;
2053
+ #else
2054
+ use_rawdata = FALSE;
2055
+ #endif
2056
+ break;
2057
+ case COMPRESSION_NEXT: /* 32766: NeXT 2-bit RLE */
2058
+ case COMPRESSION_THUNDERSCAN: /* 32809: ThunderScan RLE */
2059
+ case COMPRESSION_PIXARFILM: /* 32908: Pixar companded 10bit LZW */
2060
+ case COMPRESSION_JBIG: /* 34661: ISO JBIG */
2061
+ use_rawdata = FALSE;
2062
+ break;
2063
+ case COMPRESSION_SGILOG: /* 34676: SGI LogL or LogLuv */
2064
+ case COMPRESSION_SGILOG24: /* 34677: SGI 24-bit LogLuv */
2065
+ use_rawdata = FALSE;
2066
+ break;
2067
+ default:
2068
+ /*
2069
+ * ERROR...
2070
+ */
2071
+ use_rawdata = FALSE;
2072
+ break;
2073
+ }
2074
+ if (planarconfiguration == PLANARCONFIG_SEPARATE &&
2075
+ samplesperpixel > 1) {
2076
+ uint16 i;
2077
+
2078
+ /*
2079
+ * NOTE: This code does not work yet...
2080
+ */
2081
+ for (i = 1; i < samplesperpixel; i++)
2082
+ fputs(" dup", fd);
2083
+ fputs(" ]", fd);
2084
+ }
2085
+
2086
+ fprintf( fd, "\n >> %s\n", imageOp );
2087
+ if (ascii85)
2088
+ fputs(" im_stream status { im_stream flushfile } if\n", fd);
2089
+ if (repeat_count > 1) {
2090
+ if (tile_width < w) {
2091
+ fprintf(fd, " /im_x im_x %lu add def\n",
2092
+ (unsigned long) tile_width);
2093
+ if (tile_height < h) {
2094
+ fprintf(fd, " im_x %lu ge {\n",
2095
+ (unsigned long) w);
2096
+ fputs(" /im_x 0 def\n", fd);
2097
+ fprintf(fd, " /im_y im_y %lu add def\n",
2098
+ (unsigned long) tile_height);
2099
+ fputs(" } if\n", fd);
2100
+ }
2101
+ }
2102
+ if (tile_height < h) {
2103
+ if (tile_width >= w) {
2104
+ fprintf(fd, " /im_y im_y %lu add def\n",
2105
+ (unsigned long) tile_height);
2106
+ if (!TIFFIsTiled(tif)) {
2107
+ fprintf(fd, " /im_h %lu im_y sub",
2108
+ (unsigned long) h);
2109
+ fprintf(fd, " dup %lu gt { pop",
2110
+ (unsigned long) tile_height);
2111
+ fprintf(fd, " %lu } if def\n",
2112
+ (unsigned long) tile_height);
2113
+ }
2114
+ }
2115
+ }
2116
+ fputs("} repeat\n", fd);
2117
+ }
2118
+ /*
2119
+ * End of exec function
2120
+ */
2121
+ fputs("}\n", fd);
2122
+
2123
+ return(use_rawdata);
2124
+ }
2125
+
2126
+ /* Flip the byte order of buffers with 16 bit samples */
2127
+ static void
2128
+ PS_FlipBytes(unsigned char* buf, tsize_t count)
2129
+ {
2130
+ int i;
2131
+ unsigned char temp;
2132
+
2133
+ if (count <= 0 || bitspersample <= 8) {
2134
+ return;
2135
+ }
2136
+
2137
+ count--;
2138
+
2139
+ for (i = 0; i < count; i += 2) {
2140
+ temp = buf[i];
2141
+ buf[i] = buf[i + 1];
2142
+ buf[i + 1] = temp;
2143
+ }
2144
+ }
2145
+
2146
+ #define MAXLINE 36
2147
+
2148
+ int
2149
+ PS_Lvl2page(FILE* fd, TIFF* tif, uint32 w, uint32 h)
2150
+ {
2151
+ uint16 fillorder;
2152
+ int use_rawdata, tiled_image, breaklen = MAXLINE;
2153
+ uint32 chunk_no, num_chunks;
2154
+ uint64 *bc;
2155
+ unsigned char *buf_data, *cp;
2156
+ tsize_t chunk_size, byte_count;
2157
+
2158
+ #if defined( EXP_ASCII85ENCODER )
2159
+ tsize_t ascii85_l; /* Length, in bytes, of ascii85_p[] data */
2160
+ uint8 * ascii85_p = 0; /* Holds ASCII85 encoded data */
2161
+ #endif
2162
+
2163
+ PS_Lvl2colorspace(fd, tif);
2164
+ use_rawdata = PS_Lvl2ImageDict(fd, tif, w, h);
2165
+
2166
+ /* See http://bugzilla.remotesensing.org/show_bug.cgi?id=80 */
2167
+ #ifdef ENABLE_BROKEN_BEGINENDDATA
2168
+ fputs("%%BeginData:\n", fd);
2169
+ #endif
2170
+ fputs("exec\n", fd);
2171
+
2172
+ tiled_image = TIFFIsTiled(tif);
2173
+ if (tiled_image) {
2174
+ num_chunks = TIFFNumberOfTiles(tif);
2175
+ TIFFGetField(tif, TIFFTAG_TILEBYTECOUNTS, &bc);
2176
+ } else {
2177
+ num_chunks = TIFFNumberOfStrips(tif);
2178
+ TIFFGetField(tif, TIFFTAG_STRIPBYTECOUNTS, &bc);
2179
+ }
2180
+
2181
+ if (use_rawdata) {
2182
+ chunk_size = (tsize_t) bc[0];
2183
+ for (chunk_no = 1; chunk_no < num_chunks; chunk_no++)
2184
+ if ((tsize_t) bc[chunk_no] > chunk_size)
2185
+ chunk_size = (tsize_t) bc[chunk_no];
2186
+ } else {
2187
+ if (tiled_image)
2188
+ chunk_size = TIFFTileSize(tif);
2189
+ else
2190
+ chunk_size = TIFFStripSize(tif);
2191
+ }
2192
+ buf_data = (unsigned char *)_TIFFmalloc(chunk_size);
2193
+ if (!buf_data) {
2194
+ TIFFError(filename, "Can't alloc %lu bytes for %s.",
2195
+ (unsigned long) chunk_size, tiled_image ? "tiles" : "strips");
2196
+ return(FALSE);
2197
+ }
2198
+
2199
+ #if defined( EXP_ASCII85ENCODER )
2200
+ if ( ascii85 ) {
2201
+ /*
2202
+ * Allocate a buffer to hold the ASCII85 encoded data. Note
2203
+ * that it is allocated with sufficient room to hold the
2204
+ * encoded data (5*chunk_size/4) plus the EOD marker (+8)
2205
+ * and formatting line breaks. The line breaks are more
2206
+ * than taken care of by using 6*chunk_size/4 rather than
2207
+ * 5*chunk_size/4.
2208
+ */
2209
+
2210
+ ascii85_p = _TIFFmalloc( (chunk_size+(chunk_size/2)) + 8 );
2211
+
2212
+ if ( !ascii85_p ) {
2213
+ _TIFFfree( buf_data );
2214
+
2215
+ TIFFError( filename, "Cannot allocate ASCII85 encoding buffer." );
2216
+ return ( FALSE );
2217
+ }
2218
+ }
2219
+ #endif
2220
+
2221
+ TIFFGetFieldDefaulted(tif, TIFFTAG_FILLORDER, &fillorder);
2222
+ for (chunk_no = 0; chunk_no < num_chunks; chunk_no++) {
2223
+ if (ascii85)
2224
+ Ascii85Init();
2225
+ else
2226
+ breaklen = MAXLINE;
2227
+ if (use_rawdata) {
2228
+ if (tiled_image)
2229
+ byte_count = TIFFReadRawTile(tif, chunk_no,
2230
+ buf_data, chunk_size);
2231
+ else
2232
+ byte_count = TIFFReadRawStrip(tif, chunk_no,
2233
+ buf_data, chunk_size);
2234
+ if (fillorder == FILLORDER_LSB2MSB)
2235
+ TIFFReverseBits(buf_data, byte_count);
2236
+ } else {
2237
+ if (tiled_image)
2238
+ byte_count = TIFFReadEncodedTile(tif,
2239
+ chunk_no, buf_data,
2240
+ chunk_size);
2241
+ else
2242
+ byte_count = TIFFReadEncodedStrip(tif,
2243
+ chunk_no, buf_data,
2244
+ chunk_size);
2245
+ }
2246
+ if (byte_count < 0) {
2247
+ TIFFError(filename, "Can't read %s %d.",
2248
+ tiled_image ? "tile" : "strip", chunk_no);
2249
+ if (ascii85)
2250
+ Ascii85Put('\0', fd);
2251
+ }
2252
+ /*
2253
+ * for 16 bits, the two bytes must be most significant
2254
+ * byte first
2255
+ */
2256
+ if (bitspersample == 16 && !TIFFIsBigEndian(tif)) {
2257
+ PS_FlipBytes(buf_data, byte_count);
2258
+ }
2259
+ /*
2260
+ * For images with alpha, matte against a white background;
2261
+ * i.e. Cback * (1 - Aimage) where Cback = 1. We will fill the
2262
+ * lower part of the buffer with the modified values.
2263
+ *
2264
+ * XXX: needs better solution
2265
+ */
2266
+ if (alpha) {
2267
+ int adjust, i, j = 0;
2268
+ int ncomps = samplesperpixel - extrasamples;
2269
+ for (i = 0; i < byte_count; i+=samplesperpixel) {
2270
+ adjust = 255 - buf_data[i + ncomps];
2271
+ switch (ncomps) {
2272
+ case 1:
2273
+ buf_data[j++] = buf_data[i] + adjust;
2274
+ break;
2275
+ case 2:
2276
+ buf_data[j++] = buf_data[i] + adjust;
2277
+ buf_data[j++] = buf_data[i+1] + adjust;
2278
+ break;
2279
+ case 3:
2280
+ buf_data[j++] = buf_data[i] + adjust;
2281
+ buf_data[j++] = buf_data[i+1] + adjust;
2282
+ buf_data[j++] = buf_data[i+2] + adjust;
2283
+ break;
2284
+ }
2285
+ }
2286
+ byte_count -= j;
2287
+ }
2288
+
2289
+ if (ascii85) {
2290
+ #if defined( EXP_ASCII85ENCODER )
2291
+ ascii85_l = Ascii85EncodeBlock(ascii85_p, 1, buf_data, byte_count );
2292
+
2293
+ if ( ascii85_l > 0 )
2294
+ fwrite( ascii85_p, ascii85_l, 1, fd );
2295
+ #else
2296
+ for (cp = buf_data; byte_count > 0; byte_count--)
2297
+ Ascii85Put(*cp++, fd);
2298
+ #endif
2299
+ }
2300
+ else
2301
+ {
2302
+ for (cp = buf_data; byte_count > 0; byte_count--) {
2303
+ putc(hex[((*cp)>>4)&0xf], fd);
2304
+ putc(hex[(*cp)&0xf], fd);
2305
+ cp++;
2306
+
2307
+ if (--breaklen <= 0) {
2308
+ putc('\n', fd);
2309
+ breaklen = MAXLINE;
2310
+ }
2311
+ }
2312
+ }
2313
+
2314
+ if ( !ascii85 ) {
2315
+ if ( level2 || level3 )
2316
+ putc( '>', fd );
2317
+ putc('\n', fd);
2318
+ }
2319
+ #if !defined( EXP_ASCII85ENCODER )
2320
+ else
2321
+ Ascii85Flush(fd);
2322
+ #endif
2323
+ }
2324
+
2325
+ #if defined( EXP_ASCII85ENCODER )
2326
+ if ( ascii85_p )
2327
+ _TIFFfree( ascii85_p );
2328
+ #endif
2329
+
2330
+ _TIFFfree(buf_data);
2331
+ #ifdef ENABLE_BROKEN_BEGINENDDATA
2332
+ fputs("%%EndData\n", fd);
2333
+ #endif
2334
+ return(TRUE);
2335
+ }
2336
+
2337
+ void
2338
+ PSpage(FILE* fd, TIFF* tif, uint32 w, uint32 h)
2339
+ {
2340
+ char * imageOp = "image";
2341
+
2342
+ if ( useImagemask && (bitspersample == 1) )
2343
+ imageOp = "imagemask";
2344
+
2345
+ if ((level2 || level3) && PS_Lvl2page(fd, tif, w, h))
2346
+ return;
2347
+ ps_bytesperrow = tf_bytesperrow - (extrasamples * bitspersample / 8)*w;
2348
+ switch (photometric) {
2349
+ case PHOTOMETRIC_RGB:
2350
+ if (planarconfiguration == PLANARCONFIG_CONTIG) {
2351
+ fprintf(fd, "%s", RGBcolorimage);
2352
+ PSColorContigPreamble(fd, w, h, 3);
2353
+ PSDataColorContig(fd, tif, w, h, 3);
2354
+ } else {
2355
+ PSColorSeparatePreamble(fd, w, h, 3);
2356
+ PSDataColorSeparate(fd, tif, w, h, 3);
2357
+ }
2358
+ break;
2359
+ case PHOTOMETRIC_SEPARATED:
2360
+ /* XXX should emit CMYKcolorimage */
2361
+ if (planarconfiguration == PLANARCONFIG_CONTIG) {
2362
+ PSColorContigPreamble(fd, w, h, 4);
2363
+ PSDataColorContig(fd, tif, w, h, 4);
2364
+ } else {
2365
+ PSColorSeparatePreamble(fd, w, h, 4);
2366
+ PSDataColorSeparate(fd, tif, w, h, 4);
2367
+ }
2368
+ break;
2369
+ case PHOTOMETRIC_PALETTE:
2370
+ fprintf(fd, "%s", RGBcolorimage);
2371
+ PhotoshopBanner(fd, w, h, 1, 3, "false 3 colorimage");
2372
+ fprintf(fd, "/scanLine %ld string def\n",
2373
+ (long) ps_bytesperrow * 3L);
2374
+ fprintf(fd, "%lu %lu 8\n",
2375
+ (unsigned long) w, (unsigned long) h);
2376
+ fprintf(fd, "[%lu 0 0 -%lu 0 %lu]\n",
2377
+ (unsigned long) w, (unsigned long) h, (unsigned long) h);
2378
+ fprintf(fd, "{currentfile scanLine readhexstring pop} bind\n");
2379
+ fprintf(fd, "false 3 colorimage\n");
2380
+ PSDataPalette(fd, tif, w, h);
2381
+ break;
2382
+ case PHOTOMETRIC_MINISBLACK:
2383
+ case PHOTOMETRIC_MINISWHITE:
2384
+ PhotoshopBanner(fd, w, h, 1, 1, imageOp);
2385
+ fprintf(fd, "/scanLine %ld string def\n",
2386
+ (long) ps_bytesperrow);
2387
+ fprintf(fd, "%lu %lu %d\n",
2388
+ (unsigned long) w, (unsigned long) h, bitspersample);
2389
+ fprintf(fd, "[%lu 0 0 -%lu 0 %lu]\n",
2390
+ (unsigned long) w, (unsigned long) h, (unsigned long) h);
2391
+ fprintf(fd,
2392
+ "{currentfile scanLine readhexstring pop} bind\n");
2393
+ fprintf(fd, "%s\n", imageOp);
2394
+ PSDataBW(fd, tif, w, h);
2395
+ break;
2396
+ }
2397
+ putc('\n', fd);
2398
+ }
2399
+
2400
+ void
2401
+ PSColorContigPreamble(FILE* fd, uint32 w, uint32 h, int nc)
2402
+ {
2403
+ ps_bytesperrow = nc * (tf_bytesperrow / samplesperpixel);
2404
+ PhotoshopBanner(fd, w, h, 1, nc, "false %d colorimage");
2405
+ fprintf(fd, "/line %ld string def\n", (long) ps_bytesperrow);
2406
+ fprintf(fd, "%lu %lu %d\n",
2407
+ (unsigned long) w, (unsigned long) h, bitspersample);
2408
+ fprintf(fd, "[%lu 0 0 -%lu 0 %lu]\n",
2409
+ (unsigned long) w, (unsigned long) h, (unsigned long) h);
2410
+ fprintf(fd, "{currentfile line readhexstring pop} bind\n");
2411
+ fprintf(fd, "false %d colorimage\n", nc);
2412
+ }
2413
+
2414
+ void
2415
+ PSColorSeparatePreamble(FILE* fd, uint32 w, uint32 h, int nc)
2416
+ {
2417
+ int i;
2418
+
2419
+ PhotoshopBanner(fd, w, h, ps_bytesperrow, nc, "true %d colorimage");
2420
+ for (i = 0; i < nc; i++)
2421
+ fprintf(fd, "/line%d %ld string def\n",
2422
+ i, (long) ps_bytesperrow);
2423
+ fprintf(fd, "%lu %lu %d\n",
2424
+ (unsigned long) w, (unsigned long) h, bitspersample);
2425
+ fprintf(fd, "[%lu 0 0 -%lu 0 %lu] \n",
2426
+ (unsigned long) w, (unsigned long) h, (unsigned long) h);
2427
+ for (i = 0; i < nc; i++)
2428
+ fprintf(fd, "{currentfile line%d readhexstring pop}bind\n", i);
2429
+ fprintf(fd, "true %d colorimage\n", nc);
2430
+ }
2431
+
2432
+ #define DOBREAK(len, howmany, fd) \
2433
+ if (((len) -= (howmany)) <= 0) { \
2434
+ putc('\n', fd); \
2435
+ (len) = MAXLINE-(howmany); \
2436
+ }
2437
+ #define PUTHEX(c,fd) putc(hex[((c)>>4)&0xf],fd); putc(hex[(c)&0xf],fd)
2438
+
2439
+ void
2440
+ PSDataColorContig(FILE* fd, TIFF* tif, uint32 w, uint32 h, int nc)
2441
+ {
2442
+ uint32 row;
2443
+ int breaklen = MAXLINE, es = samplesperpixel - nc;
2444
+ tsize_t cc;
2445
+ unsigned char *tf_buf;
2446
+ unsigned char *cp, c;
2447
+
2448
+ (void) w;
2449
+ if( es <= 0 )
2450
+ {
2451
+ TIFFError(filename, "Inconsistent value of es: %d", es);
2452
+ return;
2453
+ }
2454
+ tf_buf = (unsigned char *) _TIFFmalloc(tf_bytesperrow);
2455
+ if (tf_buf == NULL) {
2456
+ TIFFError(filename, "No space for scanline buffer");
2457
+ return;
2458
+ }
2459
+ for (row = 0; row < h; row++) {
2460
+ if (TIFFReadScanline(tif, tf_buf, row, 0) < 0)
2461
+ break;
2462
+ cp = tf_buf;
2463
+ /*
2464
+ * for 16 bits, the two bytes must be most significant
2465
+ * byte first
2466
+ */
2467
+ if (bitspersample == 16 && !HOST_BIGENDIAN) {
2468
+ PS_FlipBytes(cp, tf_bytesperrow);
2469
+ }
2470
+ if (alpha) {
2471
+ int adjust;
2472
+ cc = 0;
2473
+ for (; cc < tf_bytesperrow; cc += samplesperpixel) {
2474
+ DOBREAK(breaklen, nc, fd);
2475
+ /*
2476
+ * For images with alpha, matte against
2477
+ * a white background; i.e.
2478
+ * Cback * (1 - Aimage)
2479
+ * where Cback = 1.
2480
+ */
2481
+ adjust = 255 - cp[nc];
2482
+ switch (nc) {
2483
+ case 4: c = *cp++ + adjust; PUTHEX(c,fd);
2484
+ case 3: c = *cp++ + adjust; PUTHEX(c,fd);
2485
+ case 2: c = *cp++ + adjust; PUTHEX(c,fd);
2486
+ case 1: c = *cp++ + adjust; PUTHEX(c,fd);
2487
+ }
2488
+ cp += es;
2489
+ }
2490
+ } else {
2491
+ cc = 0;
2492
+ for (; cc < tf_bytesperrow; cc += samplesperpixel) {
2493
+ DOBREAK(breaklen, nc, fd);
2494
+ switch (nc) {
2495
+ case 4: c = *cp++; PUTHEX(c,fd);
2496
+ case 3: c = *cp++; PUTHEX(c,fd);
2497
+ case 2: c = *cp++; PUTHEX(c,fd);
2498
+ case 1: c = *cp++; PUTHEX(c,fd);
2499
+ }
2500
+ cp += es;
2501
+ }
2502
+ }
2503
+ }
2504
+ _TIFFfree((char *) tf_buf);
2505
+ }
2506
+
2507
+ void
2508
+ PSDataColorSeparate(FILE* fd, TIFF* tif, uint32 w, uint32 h, int nc)
2509
+ {
2510
+ uint32 row;
2511
+ int breaklen = MAXLINE;
2512
+ tsize_t cc;
2513
+ tsample_t s, maxs;
2514
+ unsigned char *tf_buf;
2515
+ unsigned char *cp, c;
2516
+
2517
+ (void) w;
2518
+ tf_buf = (unsigned char *) _TIFFmalloc(tf_bytesperrow);
2519
+ if (tf_buf == NULL) {
2520
+ TIFFError(filename, "No space for scanline buffer");
2521
+ return;
2522
+ }
2523
+ maxs = (samplesperpixel > nc ? nc : samplesperpixel);
2524
+ for (row = 0; row < h; row++) {
2525
+ for (s = 0; s < maxs; s++) {
2526
+ if (TIFFReadScanline(tif, tf_buf, row, s) < 0)
2527
+ break;
2528
+ for (cp = tf_buf, cc = 0; cc < tf_bytesperrow; cc++) {
2529
+ DOBREAK(breaklen, 1, fd);
2530
+ c = *cp++;
2531
+ PUTHEX(c,fd);
2532
+ }
2533
+ }
2534
+ }
2535
+ _TIFFfree((char *) tf_buf);
2536
+ }
2537
+
2538
+ #define PUTRGBHEX(c,fd) \
2539
+ PUTHEX(rmap[c],fd); PUTHEX(gmap[c],fd); PUTHEX(bmap[c],fd)
2540
+
2541
+ void
2542
+ PSDataPalette(FILE* fd, TIFF* tif, uint32 w, uint32 h)
2543
+ {
2544
+ uint16 *rmap, *gmap, *bmap;
2545
+ uint32 row;
2546
+ int breaklen = MAXLINE, nc;
2547
+ tsize_t cc;
2548
+ unsigned char *tf_buf;
2549
+ unsigned char *cp, c;
2550
+
2551
+ (void) w;
2552
+ if (!TIFFGetField(tif, TIFFTAG_COLORMAP, &rmap, &gmap, &bmap)) {
2553
+ TIFFError(filename, "Palette image w/o \"Colormap\" tag");
2554
+ return;
2555
+ }
2556
+ switch (bitspersample) {
2557
+ case 8: case 4: case 2: case 1:
2558
+ break;
2559
+ default:
2560
+ TIFFError(filename, "Depth %d not supported", bitspersample);
2561
+ return;
2562
+ }
2563
+ nc = 3 * (8 / bitspersample);
2564
+ tf_buf = (unsigned char *) _TIFFmalloc(tf_bytesperrow);
2565
+ if (tf_buf == NULL) {
2566
+ TIFFError(filename, "No space for scanline buffer");
2567
+ return;
2568
+ }
2569
+ if (checkcmap(tif, 1<<bitspersample, rmap, gmap, bmap) == 16) {
2570
+ int i;
2571
+ #define CVT(x) ((unsigned short) (((x) * 255) / ((1U<<16)-1)))
2572
+ for (i = (1<<bitspersample)-1; i >= 0; i--) {
2573
+ rmap[i] = CVT(rmap[i]);
2574
+ gmap[i] = CVT(gmap[i]);
2575
+ bmap[i] = CVT(bmap[i]);
2576
+ }
2577
+ #undef CVT
2578
+ }
2579
+ for (row = 0; row < h; row++) {
2580
+ if (TIFFReadScanline(tif, tf_buf, row, 0) < 0)
2581
+ break;
2582
+ for (cp = tf_buf, cc = 0; cc < tf_bytesperrow; cc++) {
2583
+ DOBREAK(breaklen, nc, fd);
2584
+ switch (bitspersample) {
2585
+ case 8:
2586
+ c = *cp++; PUTRGBHEX(c, fd);
2587
+ break;
2588
+ case 4:
2589
+ c = *cp++; PUTRGBHEX(c&0xf, fd);
2590
+ c >>= 4; PUTRGBHEX(c, fd);
2591
+ break;
2592
+ case 2:
2593
+ c = *cp++; PUTRGBHEX(c&0x3, fd);
2594
+ c >>= 2; PUTRGBHEX(c&0x3, fd);
2595
+ c >>= 2; PUTRGBHEX(c&0x3, fd);
2596
+ c >>= 2; PUTRGBHEX(c, fd);
2597
+ break;
2598
+ case 1:
2599
+ c = *cp++; PUTRGBHEX(c&0x1, fd);
2600
+ c >>= 1; PUTRGBHEX(c&0x1, fd);
2601
+ c >>= 1; PUTRGBHEX(c&0x1, fd);
2602
+ c >>= 1; PUTRGBHEX(c&0x1, fd);
2603
+ c >>= 1; PUTRGBHEX(c&0x1, fd);
2604
+ c >>= 1; PUTRGBHEX(c&0x1, fd);
2605
+ c >>= 1; PUTRGBHEX(c&0x1, fd);
2606
+ c >>= 1; PUTRGBHEX(c, fd);
2607
+ break;
2608
+ }
2609
+ }
2610
+ }
2611
+ _TIFFfree((char *) tf_buf);
2612
+ }
2613
+
2614
+ void
2615
+ PSDataBW(FILE* fd, TIFF* tif, uint32 w, uint32 h)
2616
+ {
2617
+ int breaklen = MAXLINE;
2618
+ unsigned char* tf_buf;
2619
+ unsigned char* cp;
2620
+ tsize_t stripsize = TIFFStripSize(tif);
2621
+ tstrip_t s;
2622
+
2623
+ #if defined( EXP_ASCII85ENCODER )
2624
+ tsize_t ascii85_l; /* Length, in bytes, of ascii85_p[] data */
2625
+ uint8 *ascii85_p = 0; /* Holds ASCII85 encoded data */
2626
+ #endif
2627
+
2628
+ (void) w; (void) h;
2629
+ tf_buf = (unsigned char *) _TIFFmalloc(stripsize);
2630
+ if (tf_buf == NULL) {
2631
+ TIFFError(filename, "No space for scanline buffer");
2632
+ return;
2633
+ }
2634
+
2635
+ // FIXME
2636
+ memset(tf_buf, 0, stripsize);
2637
+
2638
+ #if defined( EXP_ASCII85ENCODER )
2639
+ if ( ascii85 ) {
2640
+ /*
2641
+ * Allocate a buffer to hold the ASCII85 encoded data. Note
2642
+ * that it is allocated with sufficient room to hold the
2643
+ * encoded data (5*stripsize/4) plus the EOD marker (+8)
2644
+ * and formatting line breaks. The line breaks are more
2645
+ * than taken care of by using 6*stripsize/4 rather than
2646
+ * 5*stripsize/4.
2647
+ */
2648
+
2649
+ ascii85_p = _TIFFmalloc( (stripsize+(stripsize/2)) + 8 );
2650
+
2651
+ if ( !ascii85_p ) {
2652
+ _TIFFfree( tf_buf );
2653
+
2654
+ TIFFError( filename, "Cannot allocate ASCII85 encoding buffer." );
2655
+ return;
2656
+ }
2657
+ }
2658
+ #endif
2659
+
2660
+ if (ascii85)
2661
+ Ascii85Init();
2662
+
2663
+ for (s = 0; s < TIFFNumberOfStrips(tif); s++) {
2664
+ tmsize_t cc = TIFFReadEncodedStrip(tif, s, tf_buf, stripsize);
2665
+ if (cc < 0) {
2666
+ TIFFError(filename, "Can't read strip");
2667
+ break;
2668
+ }
2669
+ cp = tf_buf;
2670
+ if (photometric == PHOTOMETRIC_MINISWHITE) {
2671
+ for (cp += cc; --cp >= tf_buf;)
2672
+ *cp = ~*cp;
2673
+ cp++;
2674
+ }
2675
+ /*
2676
+ * for 16 bits, the two bytes must be most significant
2677
+ * byte first
2678
+ */
2679
+ if (bitspersample == 16 && !HOST_BIGENDIAN) {
2680
+ PS_FlipBytes(cp, cc);
2681
+ }
2682
+ if (ascii85) {
2683
+ #if defined( EXP_ASCII85ENCODER )
2684
+ if (alpha) {
2685
+ int adjust, i;
2686
+ for (i = 0; i < cc; i+=2) {
2687
+ adjust = 255 - cp[i + 1];
2688
+ cp[i / 2] = cp[i] + adjust;
2689
+ }
2690
+ cc /= 2;
2691
+ }
2692
+
2693
+ ascii85_l = Ascii85EncodeBlock( ascii85_p, 1, cp, cc );
2694
+
2695
+ if ( ascii85_l > 0 )
2696
+ fwrite( ascii85_p, ascii85_l, 1, fd );
2697
+ #else
2698
+ while (cc-- > 0)
2699
+ Ascii85Put(*cp++, fd);
2700
+ #endif /* EXP_ASCII85_ENCODER */
2701
+ } else {
2702
+ unsigned char c;
2703
+
2704
+ if (alpha) {
2705
+ int adjust;
2706
+ while (cc-- > 1) {
2707
+ DOBREAK(breaklen, 1, fd);
2708
+ /*
2709
+ * For images with alpha, matte against
2710
+ * a white background; i.e.
2711
+ * Cback * (1 - Aimage)
2712
+ * where Cback = 1.
2713
+ */
2714
+ adjust = 255 - cp[1];
2715
+ c = *cp++ + adjust; PUTHEX(c,fd);
2716
+ cp++, cc--;
2717
+ }
2718
+ } else {
2719
+ while (cc-- > 0) {
2720
+ c = *cp++;
2721
+ DOBREAK(breaklen, 1, fd);
2722
+ PUTHEX(c, fd);
2723
+ }
2724
+ }
2725
+ }
2726
+ }
2727
+
2728
+ if ( !ascii85 )
2729
+ {
2730
+ if ( level2 || level3)
2731
+ fputs(">\n", fd);
2732
+ }
2733
+ #if !defined( EXP_ASCII85ENCODER )
2734
+ else
2735
+ Ascii85Flush(fd);
2736
+ #else
2737
+ if ( ascii85_p )
2738
+ _TIFFfree( ascii85_p );
2739
+ #endif
2740
+
2741
+ _TIFFfree(tf_buf);
2742
+ }
2743
+
2744
+ void
2745
+ PSRawDataBW(FILE* fd, TIFF* tif, uint32 w, uint32 h)
2746
+ {
2747
+ uint64 *bc;
2748
+ uint32 bufsize;
2749
+ int breaklen = MAXLINE;
2750
+ tmsize_t cc;
2751
+ uint16 fillorder;
2752
+ unsigned char *tf_buf;
2753
+ unsigned char *cp, c;
2754
+ tstrip_t s;
2755
+
2756
+ #if defined( EXP_ASCII85ENCODER )
2757
+ tsize_t ascii85_l; /* Length, in bytes, of ascii85_p[] data */
2758
+ uint8 * ascii85_p = 0; /* Holds ASCII85 encoded data */
2759
+ #endif
2760
+
2761
+ (void) w; (void) h;
2762
+ TIFFGetFieldDefaulted(tif, TIFFTAG_FILLORDER, &fillorder);
2763
+ TIFFGetField(tif, TIFFTAG_STRIPBYTECOUNTS, &bc);
2764
+
2765
+ /*
2766
+ * Find largest strip:
2767
+ */
2768
+
2769
+ bufsize = (uint32) bc[0];
2770
+
2771
+ for ( s = 0; ++s < (tstrip_t)tf_numberstrips; ) {
2772
+ if ( bc[s] > bufsize )
2773
+ bufsize = (uint32) bc[s];
2774
+ }
2775
+
2776
+ tf_buf = (unsigned char*) _TIFFmalloc(bufsize);
2777
+ if (tf_buf == NULL) {
2778
+ TIFFError(filename, "No space for strip buffer");
2779
+ return;
2780
+ }
2781
+
2782
+ #if defined( EXP_ASCII85ENCODER )
2783
+ if ( ascii85 ) {
2784
+ /*
2785
+ * Allocate a buffer to hold the ASCII85 encoded data. Note
2786
+ * that it is allocated with sufficient room to hold the
2787
+ * encoded data (5*bufsize/4) plus the EOD marker (+8)
2788
+ * and formatting line breaks. The line breaks are more
2789
+ * than taken care of by using 6*bufsize/4 rather than
2790
+ * 5*bufsize/4.
2791
+ */
2792
+
2793
+ ascii85_p = _TIFFmalloc( (bufsize+(bufsize/2)) + 8 );
2794
+
2795
+ if ( !ascii85_p ) {
2796
+ _TIFFfree( tf_buf );
2797
+
2798
+ TIFFError( filename, "Cannot allocate ASCII85 encoding buffer." );
2799
+ return;
2800
+ }
2801
+ }
2802
+ #endif
2803
+
2804
+ for (s = 0; s < (tstrip_t) tf_numberstrips; s++) {
2805
+ cc = TIFFReadRawStrip(tif, s, tf_buf, (tmsize_t) bc[s]);
2806
+ if (cc < 0) {
2807
+ TIFFError(filename, "Can't read strip");
2808
+ break;
2809
+ }
2810
+ if (fillorder == FILLORDER_LSB2MSB)
2811
+ TIFFReverseBits(tf_buf, cc);
2812
+ if (!ascii85) {
2813
+ for (cp = tf_buf; cc > 0; cc--) {
2814
+ DOBREAK(breaklen, 1, fd);
2815
+ c = *cp++;
2816
+ PUTHEX(c, fd);
2817
+ }
2818
+ fputs(">\n", fd);
2819
+ breaklen = MAXLINE;
2820
+ } else {
2821
+ Ascii85Init();
2822
+ #if defined( EXP_ASCII85ENCODER )
2823
+ ascii85_l = Ascii85EncodeBlock( ascii85_p, 1, tf_buf, cc );
2824
+
2825
+ if ( ascii85_l > 0 )
2826
+ fwrite( ascii85_p, ascii85_l, 1, fd );
2827
+ #else
2828
+ for (cp = tf_buf; cc > 0; cc--)
2829
+ Ascii85Put(*cp++, fd);
2830
+ Ascii85Flush(fd);
2831
+ #endif /* EXP_ASCII85ENCODER */
2832
+ }
2833
+ }
2834
+ _TIFFfree((char *) tf_buf);
2835
+
2836
+ #if defined( EXP_ASCII85ENCODER )
2837
+ if ( ascii85_p )
2838
+ _TIFFfree( ascii85_p );
2839
+ #endif
2840
+ }
2841
+
2842
+ void
2843
+ Ascii85Init(void)
2844
+ {
2845
+ ascii85breaklen = 2*MAXLINE;
2846
+ ascii85count = 0;
2847
+ }
2848
+
2849
+ static char*
2850
+ Ascii85Encode(unsigned char* raw)
2851
+ {
2852
+ static char encoded[6];
2853
+ uint32 word;
2854
+
2855
+ word = (((raw[0]<<8)+raw[1])<<16) + (raw[2]<<8) + raw[3];
2856
+ if (word != 0L) {
2857
+ uint32 q;
2858
+ uint16 w1;
2859
+
2860
+ q = word / (85L*85*85*85); /* actually only a byte */
2861
+ encoded[0] = (char) (q + '!');
2862
+
2863
+ word -= q * (85L*85*85*85); q = word / (85L*85*85);
2864
+ encoded[1] = (char) (q + '!');
2865
+
2866
+ word -= q * (85L*85*85); q = word / (85*85);
2867
+ encoded[2] = (char) (q + '!');
2868
+
2869
+ w1 = (uint16) (word - q*(85L*85));
2870
+ encoded[3] = (char) ((w1 / 85) + '!');
2871
+ encoded[4] = (char) ((w1 % 85) + '!');
2872
+ encoded[5] = '\0';
2873
+ } else
2874
+ encoded[0] = 'z', encoded[1] = '\0';
2875
+ return (encoded);
2876
+ }
2877
+
2878
+ void
2879
+ Ascii85Put(unsigned char code, FILE* fd)
2880
+ {
2881
+ ascii85buf[ascii85count++] = code;
2882
+ if (ascii85count >= 4) {
2883
+ unsigned char* p;
2884
+ int n;
2885
+
2886
+ for (n = ascii85count, p = ascii85buf; n >= 4; n -= 4, p += 4) {
2887
+ char* cp;
2888
+ for (cp = Ascii85Encode(p); *cp; cp++) {
2889
+ putc(*cp, fd);
2890
+ if (--ascii85breaklen == 0) {
2891
+ putc('\n', fd);
2892
+ ascii85breaklen = 2*MAXLINE;
2893
+ }
2894
+ }
2895
+ }
2896
+ _TIFFmemcpy(ascii85buf, p, n);
2897
+ ascii85count = n;
2898
+ }
2899
+ }
2900
+
2901
+ void
2902
+ Ascii85Flush(FILE* fd)
2903
+ {
2904
+ if (ascii85count > 0) {
2905
+ char* res;
2906
+ _TIFFmemset(&ascii85buf[ascii85count], 0, 3);
2907
+ res = Ascii85Encode(ascii85buf);
2908
+ fwrite(res[0] == 'z' ? "!!!!" : res, ascii85count + 1, 1, fd);
2909
+ }
2910
+ fputs("~>\n", fd);
2911
+ }
2912
+ #if defined( EXP_ASCII85ENCODER)
2913
+
2914
+ #define A85BREAKCNTR ascii85breaklen
2915
+ #define A85BREAKLEN (2*MAXLINE)
2916
+
2917
+ /*****************************************************************************
2918
+ *
2919
+ * Name: Ascii85EncodeBlock( ascii85_p, f_eod, raw_p, raw_l )
2920
+ *
2921
+ * Description: This routine will encode the raw data in the buffer described
2922
+ * by raw_p and raw_l into ASCII85 format and store the encoding
2923
+ * in the buffer given by ascii85_p.
2924
+ *
2925
+ * Parameters: ascii85_p - A buffer supplied by the caller which will
2926
+ * contain the encoded ASCII85 data.
2927
+ * f_eod - Flag: Nz means to end the encoded buffer with
2928
+ * an End-Of-Data marker.
2929
+ * raw_p - Pointer to the buffer of data to be encoded
2930
+ * raw_l - Number of bytes in raw_p[] to be encoded
2931
+ *
2932
+ * Returns: (int) < 0 Error, see errno
2933
+ * >= 0 Number of bytes written to ascii85_p[].
2934
+ *
2935
+ * Notes: An external variable given by A85BREAKCNTR is used to
2936
+ * determine when to insert newline characters into the
2937
+ * encoded data. As each byte is placed into ascii85_p this
2938
+ * external is decremented. If the variable is decrement to
2939
+ * or past zero then a newline is inserted into ascii85_p
2940
+ * and the A85BREAKCNTR is then reset to A85BREAKLEN.
2941
+ * Note: for efficiency reasons the A85BREAKCNTR variable
2942
+ * is not actually checked on *every* character
2943
+ * placed into ascii85_p but often only for every
2944
+ * 5 characters.
2945
+ *
2946
+ * THE CALLER IS RESPONSIBLE FOR ENSURING THAT ASCII85_P[] IS
2947
+ * SUFFICIENTLY LARGE TO THE ENCODED DATA!
2948
+ * You will need at least 5 * (raw_l/4) bytes plus space for
2949
+ * newline characters and space for an EOD marker (if
2950
+ * requested). A safe calculation is to use 6*(raw_l/4) + 8
2951
+ * to size ascii85_p.
2952
+ *
2953
+ *****************************************************************************/
2954
+
2955
+ tsize_t Ascii85EncodeBlock( uint8 * ascii85_p, unsigned f_eod, const uint8 * raw_p, tsize_t raw_l )
2956
+
2957
+ {
2958
+ char ascii85[5]; /* Encoded 5 tuple */
2959
+ tsize_t ascii85_l; /* Number of bytes written to ascii85_p[] */
2960
+ int rc; /* Return code */
2961
+ uint32 val32; /* Unencoded 4 tuple */
2962
+
2963
+ ascii85_l = 0; /* Nothing written yet */
2964
+
2965
+ if ( raw_p )
2966
+ {
2967
+ --raw_p; /* Prepare for pre-increment fetches */
2968
+
2969
+ for ( ; raw_l > 3; raw_l -= 4 )
2970
+ {
2971
+ val32 = *(++raw_p) << 24;
2972
+ val32 += *(++raw_p) << 16;
2973
+ val32 += *(++raw_p) << 8;
2974
+ val32 += *(++raw_p);
2975
+
2976
+ if ( val32 == 0 ) /* Special case */
2977
+ {
2978
+ ascii85_p[ascii85_l] = 'z';
2979
+ rc = 1;
2980
+ }
2981
+
2982
+ else
2983
+ {
2984
+ ascii85[4] = (char) ((val32 % 85) + 33);
2985
+ val32 /= 85;
2986
+
2987
+ ascii85[3] = (char) ((val32 % 85) + 33);
2988
+ val32 /= 85;
2989
+
2990
+ ascii85[2] = (char) ((val32 % 85) + 33);
2991
+ val32 /= 85;
2992
+
2993
+ ascii85[1] = (char) ((val32 % 85) + 33);
2994
+ ascii85[0] = (char) ((val32 / 85) + 33);
2995
+
2996
+ _TIFFmemcpy( &ascii85_p[ascii85_l], ascii85, sizeof(ascii85) );
2997
+ rc = sizeof(ascii85);
2998
+ }
2999
+
3000
+ ascii85_l += rc;
3001
+
3002
+ if ( (A85BREAKCNTR -= rc) <= 0 )
3003
+ {
3004
+ ascii85_p[ascii85_l] = '\n';
3005
+ ++ascii85_l;
3006
+ A85BREAKCNTR = A85BREAKLEN;
3007
+ }
3008
+ }
3009
+
3010
+ /*
3011
+ * Output any straggler bytes:
3012
+ */
3013
+
3014
+ if ( raw_l > 0 )
3015
+ {
3016
+ tsize_t len; /* Output this many bytes */
3017
+
3018
+ len = raw_l + 1;
3019
+ val32 = *++raw_p << 24; /* Prime the pump */
3020
+
3021
+ if ( --raw_l > 0 ) val32 += *(++raw_p) << 16;
3022
+ if ( --raw_l > 0 ) val32 += *(++raw_p) << 8;
3023
+
3024
+ val32 /= 85;
3025
+
3026
+ ascii85[3] = (char) ((val32 % 85) + 33);
3027
+ val32 /= 85;
3028
+
3029
+ ascii85[2] = (char) ((val32 % 85) + 33);
3030
+ val32 /= 85;
3031
+
3032
+ ascii85[1] = (char) ((val32 % 85) + 33);
3033
+ ascii85[0] = (char) ((val32 / 85) + 33);
3034
+
3035
+ _TIFFmemcpy( &ascii85_p[ascii85_l], ascii85, len );
3036
+ ascii85_l += len;
3037
+ }
3038
+ }
3039
+
3040
+ /*
3041
+ * If requested add an ASCII85 End Of Data marker:
3042
+ */
3043
+
3044
+ if ( f_eod )
3045
+ {
3046
+ ascii85_p[ascii85_l++] = '~';
3047
+ ascii85_p[ascii85_l++] = '>';
3048
+ ascii85_p[ascii85_l++] = '\n';
3049
+ }
3050
+
3051
+ return ( ascii85_l );
3052
+
3053
+ } /* Ascii85EncodeBlock() */
3054
+
3055
+ #endif /* EXP_ASCII85ENCODER */
3056
+
3057
+
3058
+ char* stuff[] = {
3059
+ "usage: tiff2ps [options] input.tif ...",
3060
+ "where options are:",
3061
+ " -1 generate PostScript Level 1 (default)",
3062
+ " -2 generate PostScript Level 2",
3063
+ " -3 generate PostScript Level 3",
3064
+ " -8 disable use of ASCII85 encoding with PostScript Level 2/3",
3065
+ " -a convert all directories in file (default is first), Not EPS",
3066
+ " -b # set the bottom margin to # inches",
3067
+ " -c center image (-b and -l still add to this)",
3068
+ " -C name set postscript document creator name",
3069
+ " -d # set initial directory to # counting from zero",
3070
+ " -D enable duplex printing (two pages per sheet of paper)",
3071
+ " -e generate Encapsulated PostScript (EPS) (implies -z)",
3072
+ " -h # set printed page height to # inches (no default)",
3073
+ " -w # set printed page width to # inches (no default)",
3074
+ " -H # split image if height is more than # inches",
3075
+ " -W # split image if width is more than # inches",
3076
+ " -L # overLap split images by # inches",
3077
+ " -i # enable/disable (Nz/0) pixel interpolation (default: enable)",
3078
+ " -l # set the left margin to # inches",
3079
+ " -m use \"imagemask\" operator instead of \"image\"",
3080
+ " -o # convert directory at file offset # bytes",
3081
+ " -O file write PostScript to file instead of standard output",
3082
+ " -p generate regular (non-encapsulated) PostScript",
3083
+ " -P L or P set optional PageOrientation DSC comment to Landscape or Portrait",
3084
+ " -r # or auto rotate by 90, 180, 270 degrees or auto",
3085
+ " -s generate PostScript for a single image",
3086
+ " -t name set postscript document title. Otherwise the filename is used",
3087
+ " -T print pages for top edge binding",
3088
+ " -x override resolution units as centimeters",
3089
+ " -y override resolution units as inches",
3090
+ " -z enable printing in the deadzone (only for PostScript Level 2/3)",
3091
+ NULL
3092
+ };
3093
+
3094
+ static void
3095
+ usage(int code)
3096
+ {
3097
+ char buf[BUFSIZ];
3098
+ int i;
3099
+
3100
+ setbuf(stderr, buf);
3101
+ fprintf(stderr, "%s\n\n", TIFFGetVersion());
3102
+ for (i = 0; stuff[i] != NULL; i++)
3103
+ fprintf(stderr, "%s\n", stuff[i]);
3104
+ exit(code);
3105
+ }
3106
+