entangledstate-isbn 1.4.0 → 1.4.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (290) hide show
  1. data/README +1 -1
  2. data/Rakefile +0 -18
  3. data/VERSION +1 -0
  4. data/isbn.gemspec +290 -7
  5. data/lib/isbn.rb +6 -6
  6. data/src/gocr-0.48/.cvsignore +6 -0
  7. data/src/gocr-0.48/AUTHORS +7 -0
  8. data/src/gocr-0.48/BUGS +55 -0
  9. data/src/gocr-0.48/CREDITS +17 -0
  10. data/src/gocr-0.48/HISTORY +243 -0
  11. data/src/gocr-0.48/INSTALL +83 -0
  12. data/src/gocr-0.48/Makefile +193 -0
  13. data/src/gocr-0.48/Makefile.in +193 -0
  14. data/src/gocr-0.48/README +165 -0
  15. data/src/gocr-0.48/READMEde.txt +80 -0
  16. data/src/gocr-0.48/REMARK.txt +18 -0
  17. data/src/gocr-0.48/REVIEW +538 -0
  18. data/src/gocr-0.48/TODO +65 -0
  19. data/src/gocr-0.48/bin/.cvsignore +2 -0
  20. data/src/gocr-0.48/bin/create_db +38 -0
  21. data/src/gocr-0.48/bin/gocr.tcl +527 -0
  22. data/src/gocr-0.48/bin/gocr_chk.sh +44 -0
  23. data/src/gocr-0.48/configure +4689 -0
  24. data/src/gocr-0.48/configure.in +71 -0
  25. data/src/gocr-0.48/doc/.#Makefile.1.6 +39 -0
  26. data/src/gocr-0.48/doc/.cvsignore +2 -0
  27. data/src/gocr-0.48/doc/Makefile +39 -0
  28. data/src/gocr-0.48/doc/Makefile.in +39 -0
  29. data/src/gocr-0.48/doc/example.dtd +53 -0
  30. data/src/gocr-0.48/doc/example.xml +21 -0
  31. data/src/gocr-0.48/doc/examples.txt +67 -0
  32. data/src/gocr-0.48/doc/gocr.html +578 -0
  33. data/src/gocr-0.48/doc/unicode.txt +57 -0
  34. data/src/gocr-0.48/examples/.#Makefile.1.22 +166 -0
  35. data/src/gocr-0.48/examples/4x6.png +0 -0
  36. data/src/gocr-0.48/examples/4x6.txt +2 -0
  37. data/src/gocr-0.48/examples/5x7.png +0 -0
  38. data/src/gocr-0.48/examples/5x7.png.txt +2 -0
  39. data/src/gocr-0.48/examples/5x8.png +0 -0
  40. data/src/gocr-0.48/examples/5x8.png.txt +2 -0
  41. data/src/gocr-0.48/examples/Makefile +166 -0
  42. data/src/gocr-0.48/examples/color.fig +20 -0
  43. data/src/gocr-0.48/examples/ex.fig +16 -0
  44. data/src/gocr-0.48/examples/font.tex +22 -0
  45. data/src/gocr-0.48/examples/font1.tex +46 -0
  46. data/src/gocr-0.48/examples/font2.fig +27 -0
  47. data/src/gocr-0.48/examples/font_nw.tex +24 -0
  48. data/src/gocr-0.48/examples/handwrt1.jpg +0 -0
  49. data/src/gocr-0.48/examples/handwrt1.txt +10 -0
  50. data/src/gocr-0.48/examples/inverse.fig +20 -0
  51. data/src/gocr-0.48/examples/matrix.jpg +0 -0
  52. data/src/gocr-0.48/examples/ocr-a-subset.png +0 -0
  53. data/src/gocr-0.48/examples/ocr-a-subset.png.txt +4 -0
  54. data/src/gocr-0.48/examples/ocr-a.png +0 -0
  55. data/src/gocr-0.48/examples/ocr-a.txt +6 -0
  56. data/src/gocr-0.48/examples/ocr-b.png +0 -0
  57. data/src/gocr-0.48/examples/ocr-b.png.txt +4 -0
  58. data/src/gocr-0.48/examples/polish.tex +28 -0
  59. data/src/gocr-0.48/examples/rotate45.fig +14 -0
  60. data/src/gocr-0.48/examples/score +36 -0
  61. data/src/gocr-0.48/examples/text.tex +28 -0
  62. data/src/gocr-0.48/gocr.spec +143 -0
  63. data/src/gocr-0.48/gpl.html +537 -0
  64. data/src/gocr-0.48/include/.cvsignore +2 -0
  65. data/src/gocr-0.48/include/config.h +36 -0
  66. data/src/gocr-0.48/include/config.h.in +36 -0
  67. data/src/gocr-0.48/include/version.h +2 -0
  68. data/src/gocr-0.48/install-sh +3 -0
  69. data/src/gocr-0.48/make.bat +57 -0
  70. data/src/gocr-0.48/man/.cvsignore +2 -0
  71. data/src/gocr-0.48/man/Makefile +29 -0
  72. data/src/gocr-0.48/man/Makefile.in +29 -0
  73. data/src/gocr-0.48/man/man1/gocr.1 +166 -0
  74. data/src/gocr-0.48/src/.cvsignore +4 -0
  75. data/src/gocr-0.48/src/Makefile +132 -0
  76. data/src/gocr-0.48/src/Makefile.in +132 -0
  77. data/src/gocr-0.48/src/amiga.h +31 -0
  78. data/src/gocr-0.48/src/barcode.c +846 -0
  79. data/src/gocr-0.48/src/barcode.c.orig +593 -0
  80. data/src/gocr-0.48/src/barcode.h +11 -0
  81. data/src/gocr-0.48/src/box.c +372 -0
  82. data/src/gocr-0.48/src/database.c +462 -0
  83. data/src/gocr-0.48/src/detect.c +943 -0
  84. data/src/gocr-0.48/src/gocr.c +373 -0
  85. data/src/gocr-0.48/src/gocr.h +288 -0
  86. data/src/gocr-0.48/src/jconv.c +168 -0
  87. data/src/gocr-0.48/src/job.c +84 -0
  88. data/src/gocr-0.48/src/lines.c +350 -0
  89. data/src/gocr-0.48/src/list.c +334 -0
  90. data/src/gocr-0.48/src/list.h +90 -0
  91. data/src/gocr-0.48/src/ocr0.c +6756 -0
  92. data/src/gocr-0.48/src/ocr0.h +63 -0
  93. data/src/gocr-0.48/src/ocr0n.c +1475 -0
  94. data/src/gocr-0.48/src/ocr1.c +85 -0
  95. data/src/gocr-0.48/src/ocr1.h +3 -0
  96. data/src/gocr-0.48/src/otsu.c +289 -0
  97. data/src/gocr-0.48/src/otsu.h +23 -0
  98. data/src/gocr-0.48/src/output.c +289 -0
  99. data/src/gocr-0.48/src/output.h +37 -0
  100. data/src/gocr-0.48/src/pcx.c +153 -0
  101. data/src/gocr-0.48/src/pcx.h +9 -0
  102. data/src/gocr-0.48/src/pgm2asc.c +2893 -0
  103. data/src/gocr-0.48/src/pgm2asc.h +105 -0
  104. data/src/gocr-0.48/src/pixel.c +537 -0
  105. data/src/gocr-0.48/src/pnm.c +533 -0
  106. data/src/gocr-0.48/src/pnm.h +35 -0
  107. data/src/gocr-0.48/src/progress.c +87 -0
  108. data/src/gocr-0.48/src/progress.h +42 -0
  109. data/src/gocr-0.48/src/remove.c +703 -0
  110. data/src/gocr-0.48/src/tga.c +87 -0
  111. data/src/gocr-0.48/src/tga.h +6 -0
  112. data/src/gocr-0.48/src/unicode.c +1314 -0
  113. data/src/gocr-0.48/src/unicode.h +1257 -0
  114. data/src/jpeg-7/Makefile.am +133 -0
  115. data/src/jpeg-7/Makefile.in +1089 -0
  116. data/src/jpeg-7/README +322 -0
  117. data/src/jpeg-7/aclocal.m4 +8990 -0
  118. data/src/jpeg-7/ansi2knr.1 +36 -0
  119. data/src/jpeg-7/ansi2knr.c +739 -0
  120. data/src/jpeg-7/cderror.h +132 -0
  121. data/src/jpeg-7/cdjpeg.c +181 -0
  122. data/src/jpeg-7/cdjpeg.h +187 -0
  123. data/src/jpeg-7/change.log +270 -0
  124. data/src/jpeg-7/cjpeg.1 +325 -0
  125. data/src/jpeg-7/cjpeg.c +616 -0
  126. data/src/jpeg-7/ckconfig.c +402 -0
  127. data/src/jpeg-7/coderules.txt +118 -0
  128. data/src/jpeg-7/config.guess +1561 -0
  129. data/src/jpeg-7/config.sub +1686 -0
  130. data/src/jpeg-7/configure +17139 -0
  131. data/src/jpeg-7/configure.ac +317 -0
  132. data/src/jpeg-7/depcomp +630 -0
  133. data/src/jpeg-7/djpeg.1 +251 -0
  134. data/src/jpeg-7/djpeg.c +617 -0
  135. data/src/jpeg-7/example.c +433 -0
  136. data/src/jpeg-7/filelist.txt +215 -0
  137. data/src/jpeg-7/install-sh +520 -0
  138. data/src/jpeg-7/install.txt +1097 -0
  139. data/src/jpeg-7/jaricom.c +148 -0
  140. data/src/jpeg-7/jcapimin.c +282 -0
  141. data/src/jpeg-7/jcapistd.c +161 -0
  142. data/src/jpeg-7/jcarith.c +921 -0
  143. data/src/jpeg-7/jccoefct.c +453 -0
  144. data/src/jpeg-7/jccolor.c +459 -0
  145. data/src/jpeg-7/jcdctmgr.c +482 -0
  146. data/src/jpeg-7/jchuff.c +1612 -0
  147. data/src/jpeg-7/jcinit.c +65 -0
  148. data/src/jpeg-7/jcmainct.c +293 -0
  149. data/src/jpeg-7/jcmarker.c +667 -0
  150. data/src/jpeg-7/jcmaster.c +770 -0
  151. data/src/jpeg-7/jcomapi.c +106 -0
  152. data/src/jpeg-7/jconfig.bcc +48 -0
  153. data/src/jpeg-7/jconfig.cfg +45 -0
  154. data/src/jpeg-7/jconfig.dj +38 -0
  155. data/src/jpeg-7/jconfig.mac +43 -0
  156. data/src/jpeg-7/jconfig.manx +43 -0
  157. data/src/jpeg-7/jconfig.mc6 +52 -0
  158. data/src/jpeg-7/jconfig.sas +43 -0
  159. data/src/jpeg-7/jconfig.st +42 -0
  160. data/src/jpeg-7/jconfig.txt +155 -0
  161. data/src/jpeg-7/jconfig.vc +45 -0
  162. data/src/jpeg-7/jconfig.vms +37 -0
  163. data/src/jpeg-7/jconfig.wat +38 -0
  164. data/src/jpeg-7/jcparam.c +632 -0
  165. data/src/jpeg-7/jcprepct.c +358 -0
  166. data/src/jpeg-7/jcsample.c +545 -0
  167. data/src/jpeg-7/jctrans.c +381 -0
  168. data/src/jpeg-7/jdapimin.c +396 -0
  169. data/src/jpeg-7/jdapistd.c +275 -0
  170. data/src/jpeg-7/jdarith.c +762 -0
  171. data/src/jpeg-7/jdatadst.c +151 -0
  172. data/src/jpeg-7/jdatasrc.c +212 -0
  173. data/src/jpeg-7/jdcoefct.c +736 -0
  174. data/src/jpeg-7/jdcolor.c +396 -0
  175. data/src/jpeg-7/jdct.h +393 -0
  176. data/src/jpeg-7/jddctmgr.c +382 -0
  177. data/src/jpeg-7/jdhuff.c +1309 -0
  178. data/src/jpeg-7/jdinput.c +384 -0
  179. data/src/jpeg-7/jdmainct.c +512 -0
  180. data/src/jpeg-7/jdmarker.c +1360 -0
  181. data/src/jpeg-7/jdmaster.c +663 -0
  182. data/src/jpeg-7/jdmerge.c +400 -0
  183. data/src/jpeg-7/jdpostct.c +290 -0
  184. data/src/jpeg-7/jdsample.c +361 -0
  185. data/src/jpeg-7/jdtrans.c +136 -0
  186. data/src/jpeg-7/jerror.c +252 -0
  187. data/src/jpeg-7/jerror.h +304 -0
  188. data/src/jpeg-7/jfdctflt.c +174 -0
  189. data/src/jpeg-7/jfdctfst.c +230 -0
  190. data/src/jpeg-7/jfdctint.c +4348 -0
  191. data/src/jpeg-7/jidctflt.c +242 -0
  192. data/src/jpeg-7/jidctfst.c +368 -0
  193. data/src/jpeg-7/jidctint.c +5137 -0
  194. data/src/jpeg-7/jinclude.h +91 -0
  195. data/src/jpeg-7/jmemansi.c +167 -0
  196. data/src/jpeg-7/jmemdos.c +638 -0
  197. data/src/jpeg-7/jmemdosa.asm +379 -0
  198. data/src/jpeg-7/jmemmac.c +289 -0
  199. data/src/jpeg-7/jmemmgr.c +1118 -0
  200. data/src/jpeg-7/jmemname.c +276 -0
  201. data/src/jpeg-7/jmemnobs.c +109 -0
  202. data/src/jpeg-7/jmemsys.h +198 -0
  203. data/src/jpeg-7/jmorecfg.h +369 -0
  204. data/src/jpeg-7/jpegint.h +395 -0
  205. data/src/jpeg-7/jpeglib.h +1135 -0
  206. data/src/jpeg-7/jpegtran.1 +272 -0
  207. data/src/jpeg-7/jpegtran.c +546 -0
  208. data/src/jpeg-7/jquant1.c +856 -0
  209. data/src/jpeg-7/jquant2.c +1310 -0
  210. data/src/jpeg-7/jutils.c +179 -0
  211. data/src/jpeg-7/jversion.h +14 -0
  212. data/src/jpeg-7/libjpeg.map +4 -0
  213. data/src/jpeg-7/libjpeg.txt +3067 -0
  214. data/src/jpeg-7/ltmain.sh +8406 -0
  215. data/src/jpeg-7/makcjpeg.st +36 -0
  216. data/src/jpeg-7/makdjpeg.st +36 -0
  217. data/src/jpeg-7/makeadsw.vc6 +77 -0
  218. data/src/jpeg-7/makeasln.vc9 +33 -0
  219. data/src/jpeg-7/makecdep.vc6 +82 -0
  220. data/src/jpeg-7/makecdsp.vc6 +130 -0
  221. data/src/jpeg-7/makecmak.vc6 +159 -0
  222. data/src/jpeg-7/makecvcp.vc9 +186 -0
  223. data/src/jpeg-7/makeddep.vc6 +82 -0
  224. data/src/jpeg-7/makeddsp.vc6 +130 -0
  225. data/src/jpeg-7/makedmak.vc6 +159 -0
  226. data/src/jpeg-7/makedvcp.vc9 +186 -0
  227. data/src/jpeg-7/makefile.ansi +220 -0
  228. data/src/jpeg-7/makefile.bcc +291 -0
  229. data/src/jpeg-7/makefile.dj +226 -0
  230. data/src/jpeg-7/makefile.manx +220 -0
  231. data/src/jpeg-7/makefile.mc6 +255 -0
  232. data/src/jpeg-7/makefile.mms +224 -0
  233. data/src/jpeg-7/makefile.sas +258 -0
  234. data/src/jpeg-7/makefile.unix +234 -0
  235. data/src/jpeg-7/makefile.vc +217 -0
  236. data/src/jpeg-7/makefile.vms +142 -0
  237. data/src/jpeg-7/makefile.wat +239 -0
  238. data/src/jpeg-7/makejdep.vc6 +423 -0
  239. data/src/jpeg-7/makejdsp.vc6 +285 -0
  240. data/src/jpeg-7/makejdsw.vc6 +29 -0
  241. data/src/jpeg-7/makejmak.vc6 +425 -0
  242. data/src/jpeg-7/makejsln.vc9 +17 -0
  243. data/src/jpeg-7/makejvcp.vc9 +328 -0
  244. data/src/jpeg-7/makeproj.mac +213 -0
  245. data/src/jpeg-7/makerdep.vc6 +6 -0
  246. data/src/jpeg-7/makerdsp.vc6 +78 -0
  247. data/src/jpeg-7/makermak.vc6 +110 -0
  248. data/src/jpeg-7/makervcp.vc9 +133 -0
  249. data/src/jpeg-7/maketdep.vc6 +43 -0
  250. data/src/jpeg-7/maketdsp.vc6 +122 -0
  251. data/src/jpeg-7/maketmak.vc6 +131 -0
  252. data/src/jpeg-7/maketvcp.vc9 +178 -0
  253. data/src/jpeg-7/makewdep.vc6 +6 -0
  254. data/src/jpeg-7/makewdsp.vc6 +78 -0
  255. data/src/jpeg-7/makewmak.vc6 +110 -0
  256. data/src/jpeg-7/makewvcp.vc9 +133 -0
  257. data/src/jpeg-7/makljpeg.st +68 -0
  258. data/src/jpeg-7/maktjpeg.st +30 -0
  259. data/src/jpeg-7/makvms.opt +4 -0
  260. data/src/jpeg-7/missing +376 -0
  261. data/src/jpeg-7/rdbmp.c +439 -0
  262. data/src/jpeg-7/rdcolmap.c +253 -0
  263. data/src/jpeg-7/rdgif.c +38 -0
  264. data/src/jpeg-7/rdjpgcom.1 +63 -0
  265. data/src/jpeg-7/rdjpgcom.c +515 -0
  266. data/src/jpeg-7/rdppm.c +459 -0
  267. data/src/jpeg-7/rdrle.c +387 -0
  268. data/src/jpeg-7/rdswitch.c +365 -0
  269. data/src/jpeg-7/rdtarga.c +500 -0
  270. data/src/jpeg-7/structure.txt +945 -0
  271. data/src/jpeg-7/testimg.bmp +0 -0
  272. data/src/jpeg-7/testimg.jpg +0 -0
  273. data/src/jpeg-7/testimg.ppm +4 -0
  274. data/src/jpeg-7/testimgp.jpg +0 -0
  275. data/src/jpeg-7/testorig.jpg +0 -0
  276. data/src/jpeg-7/testprog.jpg +0 -0
  277. data/src/jpeg-7/transupp.c +1533 -0
  278. data/src/jpeg-7/transupp.h +205 -0
  279. data/src/jpeg-7/usage.txt +605 -0
  280. data/src/jpeg-7/wizard.txt +211 -0
  281. data/src/jpeg-7/wrbmp.c +442 -0
  282. data/src/jpeg-7/wrgif.c +399 -0
  283. data/src/jpeg-7/wrjpgcom.1 +103 -0
  284. data/src/jpeg-7/wrjpgcom.c +583 -0
  285. data/src/jpeg-7/wrppm.c +269 -0
  286. data/src/jpeg-7/wrrle.c +305 -0
  287. data/src/jpeg-7/wrtarga.c +253 -0
  288. metadata +287 -6
  289. data/LICENSE +0 -20
  290. data/VERSION.yml +0 -4
@@ -0,0 +1,269 @@
1
+ /*
2
+ * wrppm.c
3
+ *
4
+ * Copyright (C) 1991-1996, Thomas G. Lane.
5
+ * Modified 2009 by Guido Vollbeding.
6
+ * This file is part of the Independent JPEG Group's software.
7
+ * For conditions of distribution and use, see the accompanying README file.
8
+ *
9
+ * This file contains routines to write output images in PPM/PGM format.
10
+ * The extended 2-byte-per-sample raw PPM/PGM formats are supported.
11
+ * The PBMPLUS library is NOT required to compile this software
12
+ * (but it is highly useful as a set of PPM image manipulation programs).
13
+ *
14
+ * These routines may need modification for non-Unix environments or
15
+ * specialized applications. As they stand, they assume output to
16
+ * an ordinary stdio stream.
17
+ */
18
+
19
+ #include "cdjpeg.h" /* Common decls for cjpeg/djpeg applications */
20
+
21
+ #ifdef PPM_SUPPORTED
22
+
23
+
24
+ /*
25
+ * For 12-bit JPEG data, we either downscale the values to 8 bits
26
+ * (to write standard byte-per-sample PPM/PGM files), or output
27
+ * nonstandard word-per-sample PPM/PGM files. Downscaling is done
28
+ * if PPM_NORAWWORD is defined (this can be done in the Makefile
29
+ * or in jconfig.h).
30
+ * (When the core library supports data precision reduction, a cleaner
31
+ * implementation will be to ask for that instead.)
32
+ */
33
+
34
+ #if BITS_IN_JSAMPLE == 8
35
+ #define PUTPPMSAMPLE(ptr,v) *ptr++ = (char) (v)
36
+ #define BYTESPERSAMPLE 1
37
+ #define PPM_MAXVAL 255
38
+ #else
39
+ #ifdef PPM_NORAWWORD
40
+ #define PUTPPMSAMPLE(ptr,v) *ptr++ = (char) ((v) >> (BITS_IN_JSAMPLE-8))
41
+ #define BYTESPERSAMPLE 1
42
+ #define PPM_MAXVAL 255
43
+ #else
44
+ /* The word-per-sample format always puts the MSB first. */
45
+ #define PUTPPMSAMPLE(ptr,v) \
46
+ { register int val_ = v; \
47
+ *ptr++ = (char) ((val_ >> 8) & 0xFF); \
48
+ *ptr++ = (char) (val_ & 0xFF); \
49
+ }
50
+ #define BYTESPERSAMPLE 2
51
+ #define PPM_MAXVAL ((1<<BITS_IN_JSAMPLE)-1)
52
+ #endif
53
+ #endif
54
+
55
+
56
+ /*
57
+ * When JSAMPLE is the same size as char, we can just fwrite() the
58
+ * decompressed data to the PPM or PGM file. On PCs, in order to make this
59
+ * work the output buffer must be allocated in near data space, because we are
60
+ * assuming small-data memory model wherein fwrite() can't reach far memory.
61
+ * If you need to process very wide images on a PC, you might have to compile
62
+ * in large-memory model, or else replace fwrite() with a putc() loop ---
63
+ * which will be much slower.
64
+ */
65
+
66
+
67
+ /* Private version of data destination object */
68
+
69
+ typedef struct {
70
+ struct djpeg_dest_struct pub; /* public fields */
71
+
72
+ /* Usually these two pointers point to the same place: */
73
+ char *iobuffer; /* fwrite's I/O buffer */
74
+ JSAMPROW pixrow; /* decompressor output buffer */
75
+ size_t buffer_width; /* width of I/O buffer */
76
+ JDIMENSION samples_per_row; /* JSAMPLEs per output row */
77
+ } ppm_dest_struct;
78
+
79
+ typedef ppm_dest_struct * ppm_dest_ptr;
80
+
81
+
82
+ /*
83
+ * Write some pixel data.
84
+ * In this module rows_supplied will always be 1.
85
+ *
86
+ * put_pixel_rows handles the "normal" 8-bit case where the decompressor
87
+ * output buffer is physically the same as the fwrite buffer.
88
+ */
89
+
90
+ METHODDEF(void)
91
+ put_pixel_rows (j_decompress_ptr cinfo, djpeg_dest_ptr dinfo,
92
+ JDIMENSION rows_supplied)
93
+ {
94
+ ppm_dest_ptr dest = (ppm_dest_ptr) dinfo;
95
+
96
+ (void) JFWRITE(dest->pub.output_file, dest->iobuffer, dest->buffer_width);
97
+ }
98
+
99
+
100
+ /*
101
+ * This code is used when we have to copy the data and apply a pixel
102
+ * format translation. Typically this only happens in 12-bit mode.
103
+ */
104
+
105
+ METHODDEF(void)
106
+ copy_pixel_rows (j_decompress_ptr cinfo, djpeg_dest_ptr dinfo,
107
+ JDIMENSION rows_supplied)
108
+ {
109
+ ppm_dest_ptr dest = (ppm_dest_ptr) dinfo;
110
+ register char * bufferptr;
111
+ register JSAMPROW ptr;
112
+ register JDIMENSION col;
113
+
114
+ ptr = dest->pub.buffer[0];
115
+ bufferptr = dest->iobuffer;
116
+ for (col = dest->samples_per_row; col > 0; col--) {
117
+ PUTPPMSAMPLE(bufferptr, GETJSAMPLE(*ptr++));
118
+ }
119
+ (void) JFWRITE(dest->pub.output_file, dest->iobuffer, dest->buffer_width);
120
+ }
121
+
122
+
123
+ /*
124
+ * Write some pixel data when color quantization is in effect.
125
+ * We have to demap the color index values to straight data.
126
+ */
127
+
128
+ METHODDEF(void)
129
+ put_demapped_rgb (j_decompress_ptr cinfo, djpeg_dest_ptr dinfo,
130
+ JDIMENSION rows_supplied)
131
+ {
132
+ ppm_dest_ptr dest = (ppm_dest_ptr) dinfo;
133
+ register char * bufferptr;
134
+ register int pixval;
135
+ register JSAMPROW ptr;
136
+ register JSAMPROW color_map0 = cinfo->colormap[0];
137
+ register JSAMPROW color_map1 = cinfo->colormap[1];
138
+ register JSAMPROW color_map2 = cinfo->colormap[2];
139
+ register JDIMENSION col;
140
+
141
+ ptr = dest->pub.buffer[0];
142
+ bufferptr = dest->iobuffer;
143
+ for (col = cinfo->output_width; col > 0; col--) {
144
+ pixval = GETJSAMPLE(*ptr++);
145
+ PUTPPMSAMPLE(bufferptr, GETJSAMPLE(color_map0[pixval]));
146
+ PUTPPMSAMPLE(bufferptr, GETJSAMPLE(color_map1[pixval]));
147
+ PUTPPMSAMPLE(bufferptr, GETJSAMPLE(color_map2[pixval]));
148
+ }
149
+ (void) JFWRITE(dest->pub.output_file, dest->iobuffer, dest->buffer_width);
150
+ }
151
+
152
+
153
+ METHODDEF(void)
154
+ put_demapped_gray (j_decompress_ptr cinfo, djpeg_dest_ptr dinfo,
155
+ JDIMENSION rows_supplied)
156
+ {
157
+ ppm_dest_ptr dest = (ppm_dest_ptr) dinfo;
158
+ register char * bufferptr;
159
+ register JSAMPROW ptr;
160
+ register JSAMPROW color_map = cinfo->colormap[0];
161
+ register JDIMENSION col;
162
+
163
+ ptr = dest->pub.buffer[0];
164
+ bufferptr = dest->iobuffer;
165
+ for (col = cinfo->output_width; col > 0; col--) {
166
+ PUTPPMSAMPLE(bufferptr, GETJSAMPLE(color_map[GETJSAMPLE(*ptr++)]));
167
+ }
168
+ (void) JFWRITE(dest->pub.output_file, dest->iobuffer, dest->buffer_width);
169
+ }
170
+
171
+
172
+ /*
173
+ * Startup: write the file header.
174
+ */
175
+
176
+ METHODDEF(void)
177
+ start_output_ppm (j_decompress_ptr cinfo, djpeg_dest_ptr dinfo)
178
+ {
179
+ ppm_dest_ptr dest = (ppm_dest_ptr) dinfo;
180
+
181
+ /* Emit file header */
182
+ switch (cinfo->out_color_space) {
183
+ case JCS_GRAYSCALE:
184
+ /* emit header for raw PGM format */
185
+ fprintf(dest->pub.output_file, "P5\n%ld %ld\n%d\n",
186
+ (long) cinfo->output_width, (long) cinfo->output_height,
187
+ PPM_MAXVAL);
188
+ break;
189
+ case JCS_RGB:
190
+ /* emit header for raw PPM format */
191
+ fprintf(dest->pub.output_file, "P6\n%ld %ld\n%d\n",
192
+ (long) cinfo->output_width, (long) cinfo->output_height,
193
+ PPM_MAXVAL);
194
+ break;
195
+ default:
196
+ ERREXIT(cinfo, JERR_PPM_COLORSPACE);
197
+ }
198
+ }
199
+
200
+
201
+ /*
202
+ * Finish up at the end of the file.
203
+ */
204
+
205
+ METHODDEF(void)
206
+ finish_output_ppm (j_decompress_ptr cinfo, djpeg_dest_ptr dinfo)
207
+ {
208
+ /* Make sure we wrote the output file OK */
209
+ fflush(dinfo->output_file);
210
+ if (ferror(dinfo->output_file))
211
+ ERREXIT(cinfo, JERR_FILE_WRITE);
212
+ }
213
+
214
+
215
+ /*
216
+ * The module selection routine for PPM format output.
217
+ */
218
+
219
+ GLOBAL(djpeg_dest_ptr)
220
+ jinit_write_ppm (j_decompress_ptr cinfo)
221
+ {
222
+ ppm_dest_ptr dest;
223
+
224
+ /* Create module interface object, fill in method pointers */
225
+ dest = (ppm_dest_ptr)
226
+ (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE,
227
+ SIZEOF(ppm_dest_struct));
228
+ dest->pub.start_output = start_output_ppm;
229
+ dest->pub.finish_output = finish_output_ppm;
230
+
231
+ /* Calculate output image dimensions so we can allocate space */
232
+ jpeg_calc_output_dimensions(cinfo);
233
+
234
+ /* Create physical I/O buffer. Note we make this near on a PC. */
235
+ dest->samples_per_row = cinfo->output_width * cinfo->out_color_components;
236
+ dest->buffer_width = dest->samples_per_row * (BYTESPERSAMPLE * SIZEOF(char));
237
+ dest->iobuffer = (char *) (*cinfo->mem->alloc_small)
238
+ ((j_common_ptr) cinfo, JPOOL_IMAGE, dest->buffer_width);
239
+
240
+ if (cinfo->quantize_colors || BITS_IN_JSAMPLE != 8 ||
241
+ SIZEOF(JSAMPLE) != SIZEOF(char)) {
242
+ /* When quantizing, we need an output buffer for colormap indexes
243
+ * that's separate from the physical I/O buffer. We also need a
244
+ * separate buffer if pixel format translation must take place.
245
+ */
246
+ dest->pub.buffer = (*cinfo->mem->alloc_sarray)
247
+ ((j_common_ptr) cinfo, JPOOL_IMAGE,
248
+ cinfo->output_width * cinfo->output_components, (JDIMENSION) 1);
249
+ dest->pub.buffer_height = 1;
250
+ if (! cinfo->quantize_colors)
251
+ dest->pub.put_pixel_rows = copy_pixel_rows;
252
+ else if (cinfo->out_color_space == JCS_GRAYSCALE)
253
+ dest->pub.put_pixel_rows = put_demapped_gray;
254
+ else
255
+ dest->pub.put_pixel_rows = put_demapped_rgb;
256
+ } else {
257
+ /* We will fwrite() directly from decompressor output buffer. */
258
+ /* Synthesize a JSAMPARRAY pointer structure */
259
+ /* Cast here implies near->far pointer conversion on PCs */
260
+ dest->pixrow = (JSAMPROW) dest->iobuffer;
261
+ dest->pub.buffer = & dest->pixrow;
262
+ dest->pub.buffer_height = 1;
263
+ dest->pub.put_pixel_rows = put_pixel_rows;
264
+ }
265
+
266
+ return (djpeg_dest_ptr) dest;
267
+ }
268
+
269
+ #endif /* PPM_SUPPORTED */
@@ -0,0 +1,305 @@
1
+ /*
2
+ * wrrle.c
3
+ *
4
+ * Copyright (C) 1991-1996, Thomas G. Lane.
5
+ * This file is part of the Independent JPEG Group's software.
6
+ * For conditions of distribution and use, see the accompanying README file.
7
+ *
8
+ * This file contains routines to write output images in RLE format.
9
+ * The Utah Raster Toolkit library is required (version 3.1 or later).
10
+ *
11
+ * These routines may need modification for non-Unix environments or
12
+ * specialized applications. As they stand, they assume output to
13
+ * an ordinary stdio stream.
14
+ *
15
+ * Based on code contributed by Mike Lijewski,
16
+ * with updates from Robert Hutchinson.
17
+ */
18
+
19
+ #include "cdjpeg.h" /* Common decls for cjpeg/djpeg applications */
20
+
21
+ #ifdef RLE_SUPPORTED
22
+
23
+ /* rle.h is provided by the Utah Raster Toolkit. */
24
+
25
+ #include <rle.h>
26
+
27
+ /*
28
+ * We assume that JSAMPLE has the same representation as rle_pixel,
29
+ * to wit, "unsigned char". Hence we can't cope with 12- or 16-bit samples.
30
+ */
31
+
32
+ #if BITS_IN_JSAMPLE != 8
33
+ Sorry, this code only copes with 8-bit JSAMPLEs. /* deliberate syntax err */
34
+ #endif
35
+
36
+
37
+ /*
38
+ * Since RLE stores scanlines bottom-to-top, we have to invert the image
39
+ * from JPEG's top-to-bottom order. To do this, we save the outgoing data
40
+ * in a virtual array during put_pixel_row calls, then actually emit the
41
+ * RLE file during finish_output.
42
+ */
43
+
44
+
45
+ /*
46
+ * For now, if we emit an RLE color map then it is always 256 entries long,
47
+ * though not all of the entries need be used.
48
+ */
49
+
50
+ #define CMAPBITS 8
51
+ #define CMAPLENGTH (1<<(CMAPBITS))
52
+
53
+ typedef struct {
54
+ struct djpeg_dest_struct pub; /* public fields */
55
+
56
+ jvirt_sarray_ptr image; /* virtual array to store the output image */
57
+ rle_map *colormap; /* RLE-style color map, or NULL if none */
58
+ rle_pixel **rle_row; /* To pass rows to rle_putrow() */
59
+
60
+ } rle_dest_struct;
61
+
62
+ typedef rle_dest_struct * rle_dest_ptr;
63
+
64
+ /* Forward declarations */
65
+ METHODDEF(void) rle_put_pixel_rows
66
+ JPP((j_decompress_ptr cinfo, djpeg_dest_ptr dinfo,
67
+ JDIMENSION rows_supplied));
68
+
69
+
70
+ /*
71
+ * Write the file header.
72
+ *
73
+ * In this module it's easier to wait till finish_output to write anything.
74
+ */
75
+
76
+ METHODDEF(void)
77
+ start_output_rle (j_decompress_ptr cinfo, djpeg_dest_ptr dinfo)
78
+ {
79
+ rle_dest_ptr dest = (rle_dest_ptr) dinfo;
80
+ size_t cmapsize;
81
+ int i, ci;
82
+ #ifdef PROGRESS_REPORT
83
+ cd_progress_ptr progress = (cd_progress_ptr) cinfo->progress;
84
+ #endif
85
+
86
+ /*
87
+ * Make sure the image can be stored in RLE format.
88
+ *
89
+ * - RLE stores image dimensions as *signed* 16 bit integers. JPEG
90
+ * uses unsigned, so we have to check the width.
91
+ *
92
+ * - Colorspace is expected to be grayscale or RGB.
93
+ *
94
+ * - The number of channels (components) is expected to be 1 (grayscale/
95
+ * pseudocolor) or 3 (truecolor/directcolor).
96
+ * (could be 2 or 4 if using an alpha channel, but we aren't)
97
+ */
98
+
99
+ if (cinfo->output_width > 32767 || cinfo->output_height > 32767)
100
+ ERREXIT2(cinfo, JERR_RLE_DIMENSIONS, cinfo->output_width,
101
+ cinfo->output_height);
102
+
103
+ if (cinfo->out_color_space != JCS_GRAYSCALE &&
104
+ cinfo->out_color_space != JCS_RGB)
105
+ ERREXIT(cinfo, JERR_RLE_COLORSPACE);
106
+
107
+ if (cinfo->output_components != 1 && cinfo->output_components != 3)
108
+ ERREXIT1(cinfo, JERR_RLE_TOOMANYCHANNELS, cinfo->num_components);
109
+
110
+ /* Convert colormap, if any, to RLE format. */
111
+
112
+ dest->colormap = NULL;
113
+
114
+ if (cinfo->quantize_colors) {
115
+ /* Allocate storage for RLE-style cmap, zero any extra entries */
116
+ cmapsize = cinfo->out_color_components * CMAPLENGTH * SIZEOF(rle_map);
117
+ dest->colormap = (rle_map *) (*cinfo->mem->alloc_small)
118
+ ((j_common_ptr) cinfo, JPOOL_IMAGE, cmapsize);
119
+ MEMZERO(dest->colormap, cmapsize);
120
+
121
+ /* Save away data in RLE format --- note 8-bit left shift! */
122
+ /* Shifting would need adjustment for JSAMPLEs wider than 8 bits. */
123
+ for (ci = 0; ci < cinfo->out_color_components; ci++) {
124
+ for (i = 0; i < cinfo->actual_number_of_colors; i++) {
125
+ dest->colormap[ci * CMAPLENGTH + i] =
126
+ GETJSAMPLE(cinfo->colormap[ci][i]) << 8;
127
+ }
128
+ }
129
+ }
130
+
131
+ /* Set the output buffer to the first row */
132
+ dest->pub.buffer = (*cinfo->mem->access_virt_sarray)
133
+ ((j_common_ptr) cinfo, dest->image, (JDIMENSION) 0, (JDIMENSION) 1, TRUE);
134
+ dest->pub.buffer_height = 1;
135
+
136
+ dest->pub.put_pixel_rows = rle_put_pixel_rows;
137
+
138
+ #ifdef PROGRESS_REPORT
139
+ if (progress != NULL) {
140
+ progress->total_extra_passes++; /* count file writing as separate pass */
141
+ }
142
+ #endif
143
+ }
144
+
145
+
146
+ /*
147
+ * Write some pixel data.
148
+ *
149
+ * This routine just saves the data away in a virtual array.
150
+ */
151
+
152
+ METHODDEF(void)
153
+ rle_put_pixel_rows (j_decompress_ptr cinfo, djpeg_dest_ptr dinfo,
154
+ JDIMENSION rows_supplied)
155
+ {
156
+ rle_dest_ptr dest = (rle_dest_ptr) dinfo;
157
+
158
+ if (cinfo->output_scanline < cinfo->output_height) {
159
+ dest->pub.buffer = (*cinfo->mem->access_virt_sarray)
160
+ ((j_common_ptr) cinfo, dest->image,
161
+ cinfo->output_scanline, (JDIMENSION) 1, TRUE);
162
+ }
163
+ }
164
+
165
+ /*
166
+ * Finish up at the end of the file.
167
+ *
168
+ * Here is where we really output the RLE file.
169
+ */
170
+
171
+ METHODDEF(void)
172
+ finish_output_rle (j_decompress_ptr cinfo, djpeg_dest_ptr dinfo)
173
+ {
174
+ rle_dest_ptr dest = (rle_dest_ptr) dinfo;
175
+ rle_hdr header; /* Output file information */
176
+ rle_pixel **rle_row, *red, *green, *blue;
177
+ JSAMPROW output_row;
178
+ char cmapcomment[80];
179
+ int row, col;
180
+ int ci;
181
+ #ifdef PROGRESS_REPORT
182
+ cd_progress_ptr progress = (cd_progress_ptr) cinfo->progress;
183
+ #endif
184
+
185
+ /* Initialize the header info */
186
+ header = *rle_hdr_init(NULL);
187
+ header.rle_file = dest->pub.output_file;
188
+ header.xmin = 0;
189
+ header.xmax = cinfo->output_width - 1;
190
+ header.ymin = 0;
191
+ header.ymax = cinfo->output_height - 1;
192
+ header.alpha = 0;
193
+ header.ncolors = cinfo->output_components;
194
+ for (ci = 0; ci < cinfo->output_components; ci++) {
195
+ RLE_SET_BIT(header, ci);
196
+ }
197
+ if (cinfo->quantize_colors) {
198
+ header.ncmap = cinfo->out_color_components;
199
+ header.cmaplen = CMAPBITS;
200
+ header.cmap = dest->colormap;
201
+ /* Add a comment to the output image with the true colormap length. */
202
+ sprintf(cmapcomment, "color_map_length=%d", cinfo->actual_number_of_colors);
203
+ rle_putcom(cmapcomment, &header);
204
+ }
205
+
206
+ /* Emit the RLE header and color map (if any) */
207
+ rle_put_setup(&header);
208
+
209
+ /* Now output the RLE data from our virtual array.
210
+ * We assume here that (a) rle_pixel is represented the same as JSAMPLE,
211
+ * and (b) we are not on a machine where FAR pointers differ from regular.
212
+ */
213
+
214
+ #ifdef PROGRESS_REPORT
215
+ if (progress != NULL) {
216
+ progress->pub.pass_limit = cinfo->output_height;
217
+ progress->pub.pass_counter = 0;
218
+ (*progress->pub.progress_monitor) ((j_common_ptr) cinfo);
219
+ }
220
+ #endif
221
+
222
+ if (cinfo->output_components == 1) {
223
+ for (row = cinfo->output_height-1; row >= 0; row--) {
224
+ rle_row = (rle_pixel **) (*cinfo->mem->access_virt_sarray)
225
+ ((j_common_ptr) cinfo, dest->image,
226
+ (JDIMENSION) row, (JDIMENSION) 1, FALSE);
227
+ rle_putrow(rle_row, (int) cinfo->output_width, &header);
228
+ #ifdef PROGRESS_REPORT
229
+ if (progress != NULL) {
230
+ progress->pub.pass_counter++;
231
+ (*progress->pub.progress_monitor) ((j_common_ptr) cinfo);
232
+ }
233
+ #endif
234
+ }
235
+ } else {
236
+ for (row = cinfo->output_height-1; row >= 0; row--) {
237
+ rle_row = (rle_pixel **) dest->rle_row;
238
+ output_row = * (*cinfo->mem->access_virt_sarray)
239
+ ((j_common_ptr) cinfo, dest->image,
240
+ (JDIMENSION) row, (JDIMENSION) 1, FALSE);
241
+ red = rle_row[0];
242
+ green = rle_row[1];
243
+ blue = rle_row[2];
244
+ for (col = cinfo->output_width; col > 0; col--) {
245
+ *red++ = GETJSAMPLE(*output_row++);
246
+ *green++ = GETJSAMPLE(*output_row++);
247
+ *blue++ = GETJSAMPLE(*output_row++);
248
+ }
249
+ rle_putrow(rle_row, (int) cinfo->output_width, &header);
250
+ #ifdef PROGRESS_REPORT
251
+ if (progress != NULL) {
252
+ progress->pub.pass_counter++;
253
+ (*progress->pub.progress_monitor) ((j_common_ptr) cinfo);
254
+ }
255
+ #endif
256
+ }
257
+ }
258
+
259
+ #ifdef PROGRESS_REPORT
260
+ if (progress != NULL)
261
+ progress->completed_extra_passes++;
262
+ #endif
263
+
264
+ /* Emit file trailer */
265
+ rle_puteof(&header);
266
+ fflush(dest->pub.output_file);
267
+ if (ferror(dest->pub.output_file))
268
+ ERREXIT(cinfo, JERR_FILE_WRITE);
269
+ }
270
+
271
+
272
+ /*
273
+ * The module selection routine for RLE format output.
274
+ */
275
+
276
+ GLOBAL(djpeg_dest_ptr)
277
+ jinit_write_rle (j_decompress_ptr cinfo)
278
+ {
279
+ rle_dest_ptr dest;
280
+
281
+ /* Create module interface object, fill in method pointers */
282
+ dest = (rle_dest_ptr)
283
+ (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE,
284
+ SIZEOF(rle_dest_struct));
285
+ dest->pub.start_output = start_output_rle;
286
+ dest->pub.finish_output = finish_output_rle;
287
+
288
+ /* Calculate output image dimensions so we can allocate space */
289
+ jpeg_calc_output_dimensions(cinfo);
290
+
291
+ /* Allocate a work array for output to the RLE library. */
292
+ dest->rle_row = (*cinfo->mem->alloc_sarray)
293
+ ((j_common_ptr) cinfo, JPOOL_IMAGE,
294
+ cinfo->output_width, (JDIMENSION) cinfo->output_components);
295
+
296
+ /* Allocate a virtual array to hold the image. */
297
+ dest->image = (*cinfo->mem->request_virt_sarray)
298
+ ((j_common_ptr) cinfo, JPOOL_IMAGE, FALSE,
299
+ (JDIMENSION) (cinfo->output_width * cinfo->output_components),
300
+ cinfo->output_height, (JDIMENSION) 1);
301
+
302
+ return (djpeg_dest_ptr) dest;
303
+ }
304
+
305
+ #endif /* RLE_SUPPORTED */