home *** CD-ROM | disk | FTP | other *** search
/ Source Code 1994 March / Source_Code_CD-ROM_Walnut_Creek_March_1994.iso / compsrcs / 3b1 / volume02 / consix / part01 < prev    next >
Encoding:
Internet Message Format  |  1993-05-18  |  23.9 KB

  1. Path: comp-sources-3b1
  2. From: krf1061@ultb.isc.rit.edu (K.R. Flanagan)
  3. Subject:  v02i039:  consix - An LA100 - SIXEL Converter, Part01/01
  4. Newsgroups: comp.sources.3b1
  5. Approved: dave@galaxia.network23.com
  6. X-Checksum-Snefru: 21a1e788 1d557ae4 dbabe554 76cde34f
  7.  
  8. Submitted-by: krf1061@ultb.isc.rit.edu (K.R. Flanagan)
  9. Posting-number: Volume 2, Issue 39
  10. Archive-name: consix/part01
  11.  
  12. [ I almost rejected this because it has also been posted to alt.sources, ]
  13. [ but then I decided there might be people who get comp.sources.3b1 that ]
  14. [ don't get alt.sources so I am letting it go through.    -- Dave        ]
  15.  
  16.         Consix will convert pbm files to sixel format, Which is
  17.      printable by DIGITAL LA100 series printers and should be printable
  18.      by la50, and la75 printers also. I'm posting it since my inquires 
  19.      into drivers for la100's showed that there where a few 3b1 users in 
  20.      the same boat. Is it possible to do a screen capture and save it into
  21.      a file instead of having it ported off to the printer, then convert it
  22.      into some form thats hackable by the pbmtools package?
  23.                  -Kevin Flanagan
  24.             krf1061@ritvax.isc.rit.edu
  25.  
  26. #! /bin/sh
  27. # This is a shell archive.  Remove anything before this line, then unpack
  28. # it by saving it into a file and typing "sh file".  To overwrite existing
  29. # files, type "sh file -c".  You can also feed this as standard input via
  30. # unshar, or by typing "sh <file", e.g..  If this archive is complete, you
  31. # will see the following message at the end:
  32. #        "End of shell archive."
  33. # Contents:  COPYRIGHT Makefile README Thanks consix.1 consix.c
  34. #   consixi.c giffer giftosix sixinv.1 sixinv.c
  35. # Wrapped by dave@galaxia on Mon Mar 15 23:13:47 1993
  36. PATH=/bin:/usr/bin:/usr/ucb ; export PATH
  37. if test -f 'COPYRIGHT' -a "${1}" != "-c" ; then 
  38.   echo shar: Will not clobber existing file \"'COPYRIGHT'\"
  39. else
  40. echo shar: Extracting \"'COPYRIGHT'\" \(476 characters\)
  41. sed "s/^X//" >'COPYRIGHT' <<'END_OF_FILE'
  42. X     Consix, Consixi, Sixinv
  43. X
  44. X     AUTHOR
  45. X      Copyright (C)    1993 by    Kevin R. Flanagan.
  46. X
  47. X      Permission to    use, copy, modify, and distribute this
  48. X      software and its documentation for any purpose and without
  49. X      fee is hereby    granted, provided that the above copyright
  50. X      notice appear    in all copies and that both that copyright
  51. X      notice and this permission notice appear in supporting
  52. X      documentation.  This software    is provided "as    is" without
  53. X      express or implied warranty.
  54. END_OF_FILE
  55. if test 476 -ne `wc -c <'COPYRIGHT'`; then
  56.     echo shar: \"'COPYRIGHT'\" unpacked with wrong size!
  57. fi
  58. chmod +x 'COPYRIGHT'
  59. # end of 'COPYRIGHT'
  60. fi
  61. if test -f 'Makefile' -a "${1}" != "-c" ; then 
  62.   echo shar: Will not clobber existing file \"'Makefile'\"
  63. else
  64. echo shar: Extracting \"'Makefile'\" \(950 characters\)
  65. sed "s/^X//" >'Makefile' <<'END_OF_FILE'
  66. X#
  67. X#  makefile for  consix, consixi, sixinv
  68. X#    by: Kevin Flanagan
  69. X#
  70. X#CC = gcc
  71. XCC = cc
  72. X
  73. XSRC    = consix.c consixi.c sixinv.c
  74. XOBJ    = consix.o consixi.o sixinv.o
  75. XDOC    = consix.1 
  76. X
  77. Xall    : consix consixi sixinv
  78. X
  79. X
  80. Xconsix    : consix.c
  81. X    $(CC) -O consix.c -s -o consix
  82. X
  83. Xconsixi    : consixi.c
  84. X    $(CC) -O consixi.c -s -o consixi
  85. X
  86. Xsixinv : sixinv.c
  87. X    $(CC) -O sixinv.c -s -o sixinv
  88. X
  89. X#
  90. X#    Consix, Consixi, Sixinv
  91. X#
  92. X#     AUTHOR
  93. X#     Copyright (C)    1993 by    Kevin R. Flanagan.
  94. X#
  95. X#     Permission to    use, copy, modify, and distribute this
  96. X#     software and its documentation for any purpose and without
  97. X#     fee is hereby    granted, provided that the above copyright
  98. X#     notice appear    in all copies and that both that copyright
  99. X#     notice and this permission notice appear in supporting
  100. X#     documentation.  This software    is provided "as    is" without
  101. X#     express or implied warranty.
  102. X#
  103. X#    Send any comments, bugs, hate mail, bomb threats, to;
  104. X#               -Kevin R. Flanagan
  105. X#            krf1061@ritvax.isc.rit.edu
  106. END_OF_FILE
  107. if test 950 -ne `wc -c <'Makefile'`; then
  108.     echo shar: \"'Makefile'\" unpacked with wrong size!
  109. fi
  110. # end of 'Makefile'
  111. fi
  112. if test -f 'README' -a "${1}" != "-c" ; then 
  113.   echo shar: Will not clobber existing file \"'README'\"
  114. else
  115. echo shar: Extracting \"'README'\" \(2967 characters\)
  116. sed "s/^X//" >'README' <<'END_OF_FILE'
  117. XI'm most likely reinventing the wheel here but, I couldn't find anything in FTP
  118. Xland that suited my needs on this topic. ppmtosixel didn't work as desired
  119. Xfor my purposes.
  120. X
  121. X
  122. X     Consix, Consixi
  123. X
  124. X     AUTHOR
  125. X      Copyright (C)    1993 by    Kevin R. Flanagan.
  126. X
  127. X      Permission to    use, copy, modify, and distribute this
  128. X      software and its documentation for any purpose and without
  129. X      fee is hereby    granted, provided that the above copyright
  130. X      notice appear    in all copies and that both that copyright
  131. X      notice and this permission notice appear in supporting
  132. X      documentation.  This software    is provided "as    is" without
  133. X      express or implied warranty.
  134. X
  135. X    This program(s) (actually program, consixi just has some numbers 
  136. X    reversed from consix) will take a pbm file and convert it to a "sixel" 
  137. X    format. The qualifier on sixel is, I have nothing in what I've looked 
  138. X    through to indicate it is actually "sixel". This program takes raw pbm 
  139. X    and converts it to a form printable by DEC la100's ("sixel"). The output 
  140. X    is also directly viewable on vt240, vt340 terminals, along with DEC's
  141. X    X windowing DECterms. This should also work on la75, la50 printers,
  142. X    I don't have one I can test it on.
  143. X   
  144. X    Use is simple, 
  145. X        consix <file.pbm
  146. X        consix <file.pbm >file.six
  147. X        consix <file.pbm |lpr -P printer.name
  148. X
  149. X    There are some limitations, it will not work with a file of more than 
  150. X    1280 pixels (this size can be changed, by editing consix.c and consixi.c, 
  151. X    the version posted to alt.sources is limited to 2048) horizontally. And 
  152. X    errors are handled ungracefully, with either a core dump or a garbage 
  153. X    output (just as bad). It does not handle, ppm, pgm, or ascii pbm files. 
  154. X    This program has been compiled on a 3b1 (stock(non ansii) and gcc 1.41),
  155. X    DEC risk 5000 (stock and gcc), and SUN SPARC 4.1.1 (stock and gcc). 
  156. X    This program has also worked on pbm files created from Jef Poskanzers 
  157. X    pbmplus package and raw pbm files created from the ever popular xv, 
  158. X    John Bradley. With the PBMplus package you can print out almost 
  159. X    any picture format (including gif) on a la100 series printer, and it
  160. X    should work other dec laXX series printers. I would love to hear about
  161. X    these since besides la100's every thing I have access to are non DEC
  162. X    or Laser printers. 
  163. X
  164. X    Also included are sixinv, a program to make a negative of the of
  165. X    sixel file (thus invert it :) ) and two shell scripts; giftosix and
  166. X    giffer. These assuming you have the pbmplus package and will convert
  167. X    gifs into a format that is printable on la100's or viewable on DIGITAL
  168. X    graphics terminals. A small bug, you cannot pipe the output of giffer
  169. X    to sixinv (giffer foo.gif|sixinv). Note these will be monochrome images!
  170. X
  171. X    Please send all bug reports, congrads., job offers, hate mail,
  172. X    ideas, comments, fixxes, modifications, etc...to;
  173. X            
  174. X            -Kevin Flanagan
  175. X            krf1061@ritvax.isc.rit.edu
  176. X
  177. X    I'll be sure to forward them to where they belong...
  178. END_OF_FILE
  179. if test 2967 -ne `wc -c <'README'`; then
  180.     echo shar: \"'README'\" unpacked with wrong size!
  181. fi
  182. chmod +x 'README'
  183. # end of 'README'
  184. fi
  185. if test -f 'Thanks' -a "${1}" != "-c" ; then 
  186.   echo shar: Will not clobber existing file \"'Thanks'\"
  187. else
  188. echo shar: Extracting \"'Thanks'\" \(630 characters\)
  189. sed "s/^X//" >'Thanks' <<'END_OF_FILE'
  190. X    Special thanks to;
  191. X
  192. X        The comp.sys.3b1 news group for the technical support that
  193. X  has kept my 3b1 running...the platform this was developed for and on.
  194. X
  195. X    Mark Schroeder "mas7480@ritvax.isc.rit.edu" for technical help with 
  196. X  the RIT ULTRIX systems, and continued maintenance of the software that I 
  197. X  used to create and test the pbm files I used.
  198. X
  199. X    The ritvax.isc.rit.edu notes group "UNIX" that helped me solve many of
  200. X  the problems I had with the Makefile...
  201. X
  202. X    Anyone that sends me bug reports and ideas on how to improve
  203. X  the performance of these programs.
  204. X
  205. X            -Kevin Flanagan
  206. X                krf1061@ritvax.isc.rit.edu
  207. X  
  208. END_OF_FILE
  209. if test 630 -ne `wc -c <'Thanks'`; then
  210.     echo shar: \"'Thanks'\" unpacked with wrong size!
  211. fi
  212. # end of 'Thanks'
  213. fi
  214. if test -f 'consix.1' -a "${1}" != "-c" ; then 
  215.   echo shar: Will not clobber existing file \"'consix.1'\"
  216. else
  217. echo shar: Extracting \"'consix.1'\" \(2431 characters\)
  218. sed "s/^X//" >'consix.1' <<'END_OF_FILE'
  219. X.TH Consix "6 March 1993"
  220. X.SH NAME
  221. Xconsix, consixi -graphical front end for la100 series printers
  222. X.SH DESCRIPTION
  223. XConsix is a front end for digital LA100 series printers that converts
  224. Xraw PBM format bitmaps into digitals black and white sixel format.
  225. XConsixi produces a inverse sixel image for the printer.
  226. X.IP - 2 
  227. XThe pbm file's magic number is the two characters "P4".  "P1" files are
  228. Xin ascii format, and not readable by this version.  The raw pbm format
  229. Xis 8 times smaller than the ascii format.
  230. X.IP - 2
  231. XThe DEC sixel format for la100's has 6 bits in each horizontal byte,
  232. Xrepresenting 6 vertical pixels on the paper.  An actual sixel byte is
  233. Xthe the six on off bits from BIT0 -BIT5, plus a offset of 077 octal (63
  234. Xdec).  Each line of bytes is followed by a graphical line feed and
  235. Xcarriage return (044 & 055 octal).  The program works on a line by line
  236. Xbasis, outputting each line of data for every 6 lines of pbm data
  237. Xreceive to cut down on memory requirements.  Once the EOF is detected a
  238. Xreset (ESC 134 octal) is sent to the printer to set it back to ascii
  239. Xmode.
  240. X.IP - 2
  241. XThis version does allow a single comment line starting with a '#'
  242. Xbetween the P4 and x,y size of the file, as is done with the pbm raw
  243. Xformat in the popular program xv.
  244. X.IP - 2
  245. Xfor more information on pbm (pnm,ppm,pgm) see Jef Poskanzers PBMplus package.
  246. X.SH "USAGE"
  247. X.IP - 2 
  248. Xconsix <infile.pbm 
  249. X.IP - 2
  250. Xconsix <infile.pbm >outfile.six
  251. X.IP - 2
  252. Xconsix <infile.pbm |lpr -P printer
  253. X.SH "BUGS"
  254. XConsix may truncate the last line if it is one bit out of sync.  for
  255. Xmore information on pbm (pnm,ppm,pgm) see .SH "BUGS" Consix may truncate
  256. Xthe last line if it is one bit out of sync.  Consix does not enforce
  257. Xerror checking at any level, feeding a pnm type file of any other format
  258. Xwill most likely result in garbage out.  feeding a non P* file type will
  259. Xmost likely result in a core dump.  This filter was written using the
  260. Xunix 10% , 90% rule.  10% of the effort solves 90% of the problem.
  261. X.SH "SEE ALSO"
  262. Xpnm(5), pgm(5), ppm(5), pbm(5)
  263. X.SH AUTHOR
  264. XCopyright (C) 1993 by Kevin R. Flanagan.
  265. X
  266. XPermission to use, copy, modify, and distribute this software and its
  267. Xdocumentation for any purpose and without fee is hereby granted, provided
  268. Xthat the above copyright notice appear in all copies and that both that
  269. Xcopyright notice and this permission notice appear in supporting
  270. Xdocumentation.  This software is provided "as is" without express or
  271. Ximplied warranty.
  272. END_OF_FILE
  273. if test 2431 -ne `wc -c <'consix.1'`; then
  274.     echo shar: \"'consix.1'\" unpacked with wrong size!
  275. fi
  276. chmod +x 'consix.1'
  277. # end of 'consix.1'
  278. fi
  279. if test -f 'consix.c' -a "${1}" != "-c" ; then 
  280.   echo shar: Will not clobber existing file \"'consix.c'\"
  281. else
  282. echo shar: Extracting \"'consix.c'\" \(3678 characters\)
  283. sed "s/^X//" >'consix.c' <<'END_OF_FILE'
  284. X#include <stdio.h>
  285. X            /* Consix V1.01 */
  286. X/* consix, converts a pbm file to a DEC LA100's sixel format */
  287. X/* By: Kevin Flanagan */
  288. X/* on: 3 - 7 - 1993 */
  289. X/* bug fixed: 3 - 11 - 1993 */
  290. X
  291. Xmain ()
  292. X{
  293. X    char c,nill,six;
  294. X    int  hi,h[10],huh;
  295. X    int  Bin, A[8],x,x2,x3,x4;
  296. X    int  B[1350][6],ci,sixi,xdimen;
  297. X    /* The first dimension on B[] can be made as large as your system will
  298. Xsupport, This is just done to make sure that it compiles on some of
  299. Xthe older pre-ansii systems, like my 3b1 (limit around 1350), It has been
  300. Xtested out to 4000, only, a la100 will not support much more than 1800 pixels */
  301. X
  302. X
  303. X    /* read's the pbm header, P4 */
  304. X
  305. X/* this receives the P4 Cr from the pbm file */
  306. X
  307. X    while (getchar() != 'P')
  308. X        {
  309. X        }
  310. X    nill = getchar();
  311. X    nill = getchar();
  312. X
  313. X/* this removes any comments from the header */
  314. X
  315. X    if ((c = getchar() ) == '#')
  316. X        {
  317. X        while (getchar() != '\n')
  318. X            {
  319. X            }
  320. X        c = getchar();
  321. X        }
  322. X
  323. X    /* this now gets the x dimension */
  324. X
  325. X/* This reads the X dimension out of the ascii header of the input */
  326. X
  327. X    h[0] = c - 48;
  328. X    x = 1;
  329. X    while ( x <= 10 )
  330. X        {
  331. X        if ((c = getchar() ) != ' ')
  332. X            {
  333. X            h[x] = c - 48;
  334. X            }
  335. X        else
  336. X            {
  337. X            x2 = x;
  338. X            x = 10;
  339. X            }
  340. X        x = x + 1;
  341. X        }
  342. X    while ((c = getchar()) != '\n')
  343. X        {
  344. X        }
  345. X
  346. X/* obtain's the x dimension */
  347. X
  348. X    xdimen = 0;
  349. X    x = 0;
  350. X    while (x <= x2)
  351. X        {
  352. X        x3 = x2 - x;
  353. X        for (huh = 1; x3 > 0; --x3)
  354. X            huh = huh * 10;
  355. X        xdimen = xdimen + (h[x]*huh);
  356. X        x = x + 1;
  357. X        }
  358. X    xdimen = xdimen / 10;
  359. X
  360. X    /* sixel printing control characters to insert it in graphics mode */
  361. X
  362. X/* ESC */
  363. X    c = 27;
  364. X    putchar (c);
  365. X/* P */
  366. X    c = 80;
  367. X    putchar (c);
  368. X/* 1 */
  369. X    c = 49;
  370. X    putchar (c);
  371. X/* q */
  372. X    c = 113;
  373. X    putchar (c);
  374. X
  375. X    /* converts the raw pbm data into sixel and outputs it as stdio */
  376. X    
  377. X    x2 = 0;
  378. X    hi = 0;
  379. X    while ((ci = getchar()) != EOF)
  380. X        {
  381. X            x = 7;
  382. X            Bin = 1;
  383. X
  384. X/* Decompress's each raw byte into 1's and 0's */
  385. X
  386. X            while ( x >= 0)
  387. X                {
  388. X                if ( (ci & Bin) != 0)
  389. X                    A[x] = 1;
  390. X                else 
  391. X                    A[x] = 0;
  392. X                x = x - 1;
  393. X                Bin = Bin * 2;
  394. X                }
  395. X            x = 0;
  396. X
  397. X/* Stores the pbm bytes for conversion to sixel (guts of program) */
  398. X
  399. X            while (x <= 7)
  400. X                {
  401. X
  402. X                B[x2][hi] = A[x];
  403. X                x = x + 1;
  404. X                x2 = x2 + 1;
  405. X                if (x2 == xdimen)
  406. X                    {
  407. X                    x2 = 0;
  408. X                        
  409. X/* this gets around a nasty feature involving pbm raw files not writing
  410. X    the second bit in each to 2 bit sequence at a line break */
  411. X
  412. X                    if ((x = 1)|(x = 3)|(x = 5)|(x = 7))
  413. X                        x = x + 1;
  414. X
  415. X/* besides which line in the array it is reading */
  416. X
  417. X                    if (hi != 5)
  418. X                        hi = hi + 1;
  419. X                    else
  420. X
  421. X/* This section outputs each line of sixel, as it goes through it */
  422. X
  423. X                        {
  424. X                        hi = 0;
  425. X                        x3 = 0;
  426. X                        while (x3 < xdimen)
  427. X                            {
  428. X
  429. X/* adds 6 lines of decompressed PBM to produce one line of sixel */
  430. X
  431. X                            sixi = B[x3][0] + 2*B[x3][1] + 4*B[x3][2] + 8*B[x3][3];
  432. X                            sixi = sixi + 63 + 16*B[x3][4] + 32*B[x3][5];
  433. X                            six = sixi;
  434. X/* outputs each 6 pixel vertical column as it creates it */
  435. X                            putchar (six);
  436. X                            x3 = x3 + 1;
  437. X                            }
  438. X
  439. X/* produces a graphical carriage return after each line */
  440. X
  441. X/* graphical carriage return */
  442. X                        c = 36;
  443. X                        putchar (c);
  444. X/* graphical line feed */
  445. X                        c = 45;
  446. X                        putchar (c);
  447. X                        }
  448. X                    }
  449. X                }
  450. X        }
  451. X/* resets the printer, terminal to ascii mode */
  452. X/* ESC */
  453. X    c = 27;
  454. X    putchar (c);
  455. X/* slash */
  456. X    c = 92;
  457. X    putchar (c);
  458. X}
  459. X
  460. X
  461. X/*      Copyright (C)    1993 by    Kevin R. Flanagan.
  462. X
  463. X      Permission to    use, copy, modify, and distribute this
  464. X      software and its documentation for any purpose and without
  465. X      fee is hereby    granted, provided that the above copyright
  466. X      notice appear    in all copies and that both that copyright
  467. X      notice and this permission notice appear in supporting
  468. X      documentation.  This software    is provided "as    is" without
  469. X      express or implied warranty. */
  470. END_OF_FILE
  471. if test 3678 -ne `wc -c <'consix.c'`; then
  472.     echo shar: \"'consix.c'\" unpacked with wrong size!
  473. fi
  474. chmod +x 'consix.c'
  475. # end of 'consix.c'
  476. fi
  477. if test -f 'consixi.c' -a "${1}" != "-c" ; then 
  478.   echo shar: Will not clobber existing file \"'consixi.c'\"
  479. else
  480. echo shar: Extracting \"'consixi.c'\" \(3680 characters\)
  481. sed "s/^X//" >'consixi.c' <<'END_OF_FILE'
  482. X#include <stdio.h>
  483. X            /* Consixi V1.01 */
  484. X/* consixi, converts a pbm file to a DEC LA100's sixel format */
  485. X/* By: Kevin Flanagan */
  486. X/* on: 3 - 7 - 1993 */
  487. X/* bug fixed: 3 - 11 - 1993 */
  488. X
  489. Xmain ()
  490. X{
  491. X    char c,nill,six;
  492. X    int  hi,h[10],huh;
  493. X    int  Bin, A[8],x,x2,x3,x4;
  494. X    int  B[1350][6],ci,sixi,xdimen;
  495. X    /* The first dimension on B[] can be made as large as your system will
  496. Xsupport, This is just done to make sure that it compiles on some of
  497. Xthe older pre-ansii systems, like my 3b1 (limit around 1350), It has been
  498. Xtested out to 4000, only, a la100 will not support much more than 1800 pixels */
  499. X
  500. X
  501. X    /* read's the pbm header, P4 */
  502. X
  503. X/* this receives the P4 Cr from the pbm file */
  504. X
  505. X    while (getchar() != 'P')
  506. X        {
  507. X        }
  508. X    nill = getchar();
  509. X    nill = getchar();
  510. X
  511. X/* this removes any comments from the header */
  512. X
  513. X    if ((c = getchar() ) == '#')
  514. X        {
  515. X        while (getchar() != '\n')
  516. X            {
  517. X            }
  518. X        c = getchar();
  519. X        }
  520. X
  521. X    /* this now gets the x dimension */
  522. X
  523. X/* This reads the X dimension out of the ascii header of the input */
  524. X
  525. X    h[0] = c - 48;
  526. X    x = 1;
  527. X    while ( x <= 10 )
  528. X        {
  529. X        if ((c = getchar() ) != ' ')
  530. X            {
  531. X            h[x] = c - 48;
  532. X            }
  533. X        else
  534. X            {
  535. X            x2 = x;
  536. X            x = 10;
  537. X            }
  538. X        x = x + 1;
  539. X        }
  540. X    while ((c = getchar()) != '\n')
  541. X        {
  542. X        }
  543. X
  544. X/* obtain's the x dimension */
  545. X
  546. X    xdimen = 0;
  547. X    x = 0;
  548. X    while (x <= x2)
  549. X        {
  550. X        x3 = x2 - x;
  551. X        for (huh = 1; x3 > 0; --x3)
  552. X            huh = huh * 10;
  553. X        xdimen = xdimen + (h[x]*huh);
  554. X        x = x + 1;
  555. X        }
  556. X    xdimen = xdimen / 10;
  557. X
  558. X    /* sixel printing control characters to insert it in graphics mode */
  559. X
  560. X/* ESC */
  561. X    c = 27;
  562. X    putchar (c);
  563. X/* P */
  564. X    c = 80;
  565. X    putchar (c);
  566. X/* 1 */
  567. X    c = 49;
  568. X    putchar (c);
  569. X/* q */
  570. X    c = 113;
  571. X    putchar (c);
  572. X
  573. X    /* converts the raw pbm data into sixel and outputs it as stdio */
  574. X    
  575. X    x2 = 0;
  576. X    hi = 0;
  577. X    while ((ci = getchar()) != EOF)
  578. X        {
  579. X            x = 7;
  580. X            Bin = 1;
  581. X
  582. X/* Decompress's each raw byte into 1's and 0's */
  583. X
  584. X            while ( x >= 0)
  585. X                {
  586. X                if ( (ci & Bin) != 0)
  587. X                    A[x] = 0;
  588. X                else 
  589. X                    A[x] = 1;
  590. X                x = x - 1;
  591. X                Bin = Bin * 2;
  592. X                }
  593. X            x = 0;
  594. X
  595. X/* Stores the pbm bytes for conversion to sixel (guts of program) */
  596. X
  597. X            while (x <= 7)
  598. X                {
  599. X
  600. X                B[x2][hi] = A[x];
  601. X                x = x + 1;
  602. X                x2 = x2 + 1;
  603. X                if (x2 == xdimen)
  604. X                    {
  605. X                    x2 = 0;
  606. X                        
  607. X/* this gets around a nasty feature involving pbm raw files not writing
  608. X    the second bit in each to 2 bit sequence at a line break */
  609. X
  610. X                    if ((x = 1)|(x = 3)|(x = 5)|(x = 7))
  611. X                        x = x + 1;
  612. X
  613. X/* besides which line in the array it is reading */
  614. X
  615. X                    if (hi != 5)
  616. X                        hi = hi + 1;
  617. X                    else
  618. X
  619. X/* This section outputs each line of sixel, as it goes through it */
  620. X
  621. X                        {
  622. X                        hi = 0;
  623. X                        x3 = 0;
  624. X                        while (x3 < xdimen)
  625. X                            {
  626. X
  627. X/* adds 6 lines of decompressed PBM to produce one line of sixel */
  628. X
  629. X                            sixi = B[x3][0] + 2*B[x3][1] + 4*B[x3][2] + 8*B[x3][3];
  630. X                            sixi = sixi + 63 + 16*B[x3][4] + 32*B[x3][5];
  631. X                            six = sixi;
  632. X/* outputs each 6 pixel vertical column as it creates it */
  633. X                            putchar (six);
  634. X                            x3 = x3 + 1;
  635. X                            }
  636. X
  637. X/* produces a graphical carriage return after each line */
  638. X
  639. X/* graphical carriage return */
  640. X                        c = 36;
  641. X                        putchar (c);
  642. X/* graphical line feed */
  643. X                        c = 45;
  644. X                        putchar (c);
  645. X                        }
  646. X                    }
  647. X                }
  648. X        }
  649. X/* resets the printer, terminal to ascii mode */
  650. X/* ESC */
  651. X    c = 27;
  652. X    putchar (c);
  653. X/* slash */
  654. X    c = 92;
  655. X    putchar (c);
  656. X}
  657. X
  658. X
  659. X/*      Copyright (C)    1993 by    Kevin R. Flanagan.
  660. X
  661. X      Permission to    use, copy, modify, and distribute this
  662. X      software and its documentation for any purpose and without
  663. X      fee is hereby    granted, provided that the above copyright
  664. X      notice appear    in all copies and that both that copyright
  665. X      notice and this permission notice appear in supporting
  666. X      documentation.  This software    is provided "as    is" without
  667. X      express or implied warranty. */
  668. END_OF_FILE
  669. if test 3680 -ne `wc -c <'consixi.c'`; then
  670.     echo shar: \"'consixi.c'\" unpacked with wrong size!
  671. fi
  672. chmod +x 'consixi.c'
  673. # end of 'consixi.c'
  674. fi
  675. if test -f 'giffer' -a "${1}" != "-c" ; then 
  676.   echo shar: Will not clobber existing file \"'giffer'\"
  677. else
  678. echo shar: Extracting \"'giffer'\" \(386 characters\)
  679. sed "s/^X//" >'giffer' <<'END_OF_FILE'
  680. XFIRST=1
  681. Xfor FILE
  682. Xdo
  683. X    if test $FIRST -eq 0; then
  684. X        echo "--More--(Next file: $FILE)"
  685. X        echo " "
  686. X    fi
  687. X    echo "------> $FILE <------"
  688. X    giftoppm $FILE |ppmtopgm|pgmtopbm|consix
  689. X    if test -t; then
  690. X        FIRST=0
  691. X    fi
  692. Xdone
  693. X#    This script gives a brief file descriptor between each file your loading
  694. X#    giffer
  695. X#    by: Kevin Flanagan
  696. X#    on:3-13-1993
  697. X
  698. X#
  699. X#    Note, sixinv will not work with this shell script.
  700. X#
  701. END_OF_FILE
  702. if test 386 -ne `wc -c <'giffer'`; then
  703.     echo shar: \"'giffer'\" unpacked with wrong size!
  704. fi
  705. chmod +x 'giffer'
  706. # end of 'giffer'
  707. fi
  708. if test -f 'giftosix' -a "${1}" != "-c" ; then 
  709.   echo shar: Will not clobber existing file \"'giftosix'\"
  710. else
  711. echo shar: Extracting \"'giftosix'\" \(39 characters\)
  712. sed "s/^X//" >'giftosix' <<'END_OF_FILE'
  713. Xgiftoppm $1 |ppmtopgm|pgmtopbm|consixi
  714. END_OF_FILE
  715. if test 39 -ne `wc -c <'giftosix'`; then
  716.     echo shar: \"'giftosix'\" unpacked with wrong size!
  717. fi
  718. chmod +x 'giftosix'
  719. # end of 'giftosix'
  720. fi
  721. if test -f 'sixinv.1' -a "${1}" != "-c" ; then 
  722.   echo shar: Will not clobber existing file \"'sixinv.1'\"
  723. else
  724. echo shar: Extracting \"'sixinv.1'\" \(1137 characters\)
  725. sed "s/^X//" >'sixinv.1' <<'END_OF_FILE'
  726. X.TH Sixinv "11 March 1993"
  727. X.SH NAME
  728. XSixinv -produces a negative sixel image of a sixel image
  729. X.SH "USAGE"
  730. X.IP - 2 
  731. Xsixinv <infile.sixel
  732. X.IP - 2
  733. Xsixinv <infile.sixel >outfile.sixel
  734. X.IP - 2 
  735. Xfoo.sixoutput |sixinv >outfile.sixel
  736. X.IP - 2
  737. Xsixinv <infile.sixel |lpr -P printer
  738. X.SH "BUGS"
  739. XSixinv does not enforce error checking at any level, feeding a non sixel
  740. Ximage into it will most likely result in garbage out.  If any text is
  741. Xfed into sixinv before the header the header that defines a sixel file
  742. Xas sixel will be lost.  Embedded escape sequences of more than two
  743. Xcharacters will be mangled.  This filter was written using the unix 10%,
  744. X90% rule.  10% of the effort solves 90% of the problem.
  745. X.SH "SEE ALSO"
  746. Xconsix(1)
  747. X.SH AUTHOR
  748. XCopyright (C) 1993 by Kevin R. Flanagan.
  749. X
  750. XPermission to use, copy, modify, and distribute this software and its
  751. Xdocumentation for any purpose and without fee is hereby granted, provided
  752. Xthat the above copyright notice appear in all copies and that both that
  753. Xcopyright notice and this permission notice appear in supporting
  754. Xdocumentation.  This software is provided "as is" without express or
  755. Ximplied warranty.
  756. END_OF_FILE
  757. if test 1137 -ne `wc -c <'sixinv.1'`; then
  758.     echo shar: \"'sixinv.1'\" unpacked with wrong size!
  759. fi
  760. chmod +x 'sixinv.1'
  761. # end of 'sixinv.1'
  762. fi
  763. if test -f 'sixinv.c' -a "${1}" != "-c" ; then 
  764.   echo shar: Will not clobber existing file \"'sixinv.c'\"
  765. else
  766. echo shar: Extracting \"'sixinv.c'\" \(1517 characters\)
  767. sed "s/^X//" >'sixinv.c' <<'END_OF_FILE'
  768. X#include <stdio.h>
  769. X            /* Sixinv V1.0 */
  770. X/* Sixinv makes a negative of a Sixel image */
  771. X/* By: Kevin Flanagan */
  772. X/* on: 3 - 11 - 1993 */
  773. X
  774. Xmain ()
  775. X{
  776. X    int c;
  777. X     char ci;
  778. X
  779. X    /* preserves the header, does not do any error checking */
  780. X/* reads the first 4 characters that define a sixel file, ESC, P, 1, q */
  781. X
  782. X    ci = getchar();
  783. X    putchar(ci);
  784. X    ci = getchar();
  785. X    putchar(ci);
  786. X    ci = getchar();
  787. X    putchar(ci);
  788. X    ci = getchar();
  789. X    putchar(ci);
  790. X
  791. X/* starts the loop for making a negative */
  792. X
  793. X    while ((c=getchar()) != EOF)
  794. X        {
  795. X/* checks for a graphical carriage return, line feed, esc  sequence */
  796. X/* 27 = ESC, 36 = graph line feed, 45 = graph return, 92 = reset */
  797. X
  798. X        if ((c == 36) | (c == 45))
  799. X            putchar(c);
  800. X        else
  801. X            {
  802. X/* propperly handles single character escape sequences */
  803. X            if ( c == 27)
  804. X                {
  805. X                putchar (c);
  806. X                c = getchar();
  807. X                putchar (c);
  808. X                }
  809. X            else
  810. X                {
  811. X/* code to invert the sixel part of the image, inefficient but easy to read */
  812. X
  813. X                c = c - 63;
  814. X                c = 63 - c;
  815. X                ci = c + 63;
  816. X                putchar(ci);
  817. X                }
  818. X            }
  819. X        }
  820. X}
  821. X
  822. X/*      Copyright (C)    1993 by    Kevin R. Flanagan.
  823. X
  824. X      Permission to    use, copy, modify, and distribute this
  825. X      software and its documentation for any purpose and without
  826. X      fee is hereby    granted, provided that the above copyright
  827. X      notice appear    in all copies and that both that copyright
  828. X      notice and this permission notice appear in supporting
  829. X      documentation.  This software    is provided "as    is" without
  830. X      express or implied warranty. */
  831. X
  832. X
  833. X/* wow some actually read more than the make file :) */
  834. END_OF_FILE
  835. if test 1517 -ne `wc -c <'sixinv.c'`; then
  836.     echo shar: \"'sixinv.c'\" unpacked with wrong size!
  837. fi
  838. chmod +x 'sixinv.c'
  839. # end of 'sixinv.c'
  840. fi
  841. echo shar: End of shell archive.
  842. exit 0
  843. -- 
  844. David H. Brierley
  845. Home: dave@galaxia.network23.com; Work: dhb@quahog.ssd.ray.com
  846. Send comp.sources.3b1 submissions to comp-sources-3b1@galaxia.network23.com
  847. %% Pardon me Professor, can I be excused, my brain is full. **
  848.