home *** CD-ROM | disk | FTP | other *** search
/ Source Code 1994 March / Source_Code_CD-ROM_Walnut_Creek_March_1994.iso / compsrcs / misc / volume29 / hp2pbm / patch03 < prev    next >
Encoding:
Text File  |  1992-04-05  |  17.0 KB  |  636 lines

  1. Newsgroups: comp.sources.misc
  2. From: clewis@ferret.ocunix.on.ca (Chris Lewis)
  3. Subject:  v29i060:  hp2pbm - HP PCL to Portable Bit Map converter, Patch03
  4. Message-ID: <1992Apr5.035505.1572@sparky.imd.sterling.com>
  5. X-Md4-Signature: f1285513ee2872030e69c36da4b62670
  6. Date: Sun, 5 Apr 1992 03:55:05 GMT
  7. Approved: kent@sparky.imd.sterling.com
  8.  
  9. Submitted-by: clewis@ferret.ocunix.on.ca (Chris Lewis)
  10. Posting-number: Volume 29, Issue 60
  11. Archive-name: hp2pbm/patch03
  12. Environment: UNIX
  13. Patch-To: hp2pbm: Volume 26, Issue 102-104
  14.  
  15. This is official patch 03 for Hp2pbm.  Please apply it by:
  16.  
  17.     cd <hp2pbm source directory>
  18.     touch pbm2ps.c pbm2xd.c
  19.     patch -N -p < <this file>
  20.     
  21.     The initial release of hp2pbm was in volume 26 of
  22.     comp.sources.misc.  The "touch" is only necessary
  23.     for some versions of patch.
  24.  
  25. Synopsis:
  26.     - made Makefile safer with paranoid root umasks.
  27.     - one-liner bug fix to HP emulation (X position
  28.       after raster graphics was wrong)
  29.     - New: PBM to PostScript filter.  Very stupid.
  30.       (hope you have >9600 baud)
  31.     - New: PBM to X windows dump filter.
  32.  
  33. ./Makefile        Made installs more paranoid.
  34. ./hpfntwrite.c        Real bug
  35. ./README        Fixed up psroff docs slightly.
  36. ./hptopbm.h        Patch level & paper sizes
  37. ./pbm2ps.c        pbm2PostScript filter
  38. ./pbm2xd.c        pbm2X Windows dump filter (xwd/xwud)
  39.  
  40. Patchwrapped: 920401024721
  41.  
  42. Index: ./Makefile
  43. *** /tmp/PATCHold/./Makefile    Wed Apr  1 02:46:12 1992
  44. --- ./Makefile    Wed Apr  1 02:46:13 1992
  45. ***************
  46. *** 1,4 ****
  47. ! # Makefile for hptopbm standalone release 1.6 92/03/05
  48.   
  49.   #    Configuration:
  50.   
  51. --- 1,4 ----
  52. ! # Makefile for hptopbm standalone release 1.7 92/04/01
  53.   
  54.   #    Configuration:
  55.   
  56. ***************
  57. *** 38,44 ****
  58.   
  59.   .SUFFIXES:    .S~ .S
  60.   
  61. ! all:    README hp2pbm pbm2e24 hp2pbm.m $(LIBFILES)
  62.   
  63.   # programs
  64.   hp2pbm:        $(HP2OBJ)
  65. --- 38,44 ----
  66.   
  67.   .SUFFIXES:    .S~ .S
  68.   
  69. ! all:    README hp2pbm pbm2e24 pbm2ps pbm2xd hp2pbm.m $(LIBFILES)
  70.   
  71.   # programs
  72.   hp2pbm:        $(HP2OBJ)
  73. ***************
  74. *** 100,107 ****
  75.           test -d $(LIBDIR) || mkdir $(LIBDIR)
  76.           test -d $(LIBDIR)/BITMAPS || mkdir $(LIBDIR)/BITMAPS
  77.           cd $(BINDIR) ; rm -f hp2pbm $(ALTNAMES)
  78. !         cp hp2pbm $(BINDIR)/hp2pbm
  79. !         cp pbm2e24 $(BINDIR)/pbm2e24
  80.           $(IGNORESH) cd $(BINDIR) ; \
  81.           for i in $(ALTNAMES) ; \
  82.           do \
  83. --- 100,111 ----
  84.           test -d $(LIBDIR) || mkdir $(LIBDIR)
  85.           test -d $(LIBDIR)/BITMAPS || mkdir $(LIBDIR)/BITMAPS
  86.           cd $(BINDIR) ; rm -f hp2pbm $(ALTNAMES)
  87. !         $(IGNORESH) for i in hp2pbm pbm2e24 pbm2ps pbm2xd ; \
  88. !         do \
  89. !             rm -f $(BINDIR)/$$i ; \
  90. !             cp $$i $(BINDIR)/$$i ; \
  91. !             chmod 555 $(BINDIR)/$$i ; \
  92. !         done
  93.           $(IGNORESH) cd $(BINDIR) ; \
  94.           for i in $(ALTNAMES) ; \
  95.           do \
  96. ***************
  97. *** 109,112 ****
  98. --- 113,117 ----
  99.           done
  100.           cd $(LIBDIR)/BITMAPS ; rm -f $(LIBFILES)
  101.           cp $(LIBFILES) $(LIBDIR)/BITMAPS
  102. +         cd $(LIBDIR)/BITMAPS ; chmod 444 $(LIBFILES)
  103.           -cp hp2pbm.m $(MANDIR)/hp2pbm.$(MANEXT)
  104. Index: ./hpfntwrite.c
  105. *** /tmp/PATCHold/./hpfntwrite.c    Wed Apr  1 02:46:24 1992
  106. --- ./hpfntwrite.c    Wed Apr  1 02:46:28 1992
  107. ***************
  108. *** 24,30 ****
  109.   #endif
  110.   
  111.   #ifndef    lint
  112. ! char SCCSid[] = "@(#)hpfntwrite.c: 1.4 92/03/01 02:04:25";
  113.   #endif
  114.   
  115.   #ifdef    FAXPAK
  116. --- 24,30 ----
  117.   #endif
  118.   
  119.   #ifndef    lint
  120. ! char SCCSid[] = "@(#)hpfntwrite.c: 1.5 92/04/01 01:40:15";
  121.   #endif
  122.   
  123.   #ifdef    FAXPAK
  124. ***************
  125. *** 1234,1240 ****
  126.               break;
  127.       }
  128.       BMY += inc;
  129. !     BMX = (double)(graphx + inc);
  130.       ymax_used = max(ymax_used,(localy-1)+inc);
  131.       xmax_used = max(xmax_used,xscale[(graphx-1)+inc]);
  132.       dotted = TRUE;
  133. --- 1234,1240 ----
  134.               break;
  135.       }
  136.       BMY += inc;
  137. !     BMX = /*(double)(graphx + inc);*/ GRAPHX;
  138.       ymax_used = max(ymax_used,(localy-1)+inc);
  139.       xmax_used = max(xmax_used,xscale[(graphx-1)+inc]);
  140.       dotted = TRUE;
  141. Index: ./README
  142. *** /tmp/PATCHold/./README    Wed Apr  1 02:46:44 1992
  143. --- ./README    Wed Apr  1 02:46:45 1992
  144. ***************
  145. *** 1,8 ****
  146.               HP2PBM et. al.
  147. !             Version 1.00
  148.               Chris Lewis    <clewis@ferret.ocunix.on.ca>
  149.               Klaus Schallhorn    <klaus@cnix.uucp>
  150. !             [README V1.1]
  151.   
  152.   The first section of this README is a discussion of how you
  153.   integrate this package with faxpak, the second half is how
  154. --- 1,8 ----
  155.               HP2PBM et. al.
  156. !             Version 1.03
  157.               Chris Lewis    <clewis@ferret.ocunix.on.ca>
  158.               Klaus Schallhorn    <klaus@cnix.uucp>
  159. !             [README V1.2]
  160.   
  161.   The first section of this README is a discussion of how you
  162.   integrate this package with faxpak, the second half is how
  163. ***************
  164. *** 151,169 ****
  165.   
  166.   For epson printing, you will want to run:
  167.   
  168. !     psroff -Tlj -t <whatever> | hp2e24 file
  169.   
  170. ! Which will create a series of files called "file.0", "file.1" etc.
  171. ! Caution: these files can get quite big.
  172.   
  173. - Then you run:
  174. -     for i in file.?
  175. -     do
  176. -         pbm2e24 $i | <your print spooler>
  177. -     done
  178.   In order to run the other varians of hp2*, you'll have to obtain
  179.   other PBM drivers, such as those in faxpak, or in PBM+.
  180.   
  181.   Chris Lewis    <clewis@ferret.ocunix.on.ca>
  182. --- 151,166 ----
  183.   
  184.   For epson printing, you will want to run:
  185.   
  186. !     psroff -Tlj -t <whatever> | hp2e24 '-r|pbm2e24'
  187.   
  188. ! Which will produce Epson codes on standard output.
  189.   
  190.   In order to run the other varians of hp2*, you'll have to obtain
  191.   other PBM drivers, such as those in faxpak, or in PBM+.
  192. + Psroff 3.0, PL9 or later has examples on how to roll the above
  193. + pipeline into psroff's configuration, so just
  194. +     psroff -Te24
  195. + will be sufficient.
  196.   
  197.   Chris Lewis    <clewis@ferret.ocunix.on.ca>
  198. Index: ./hptopbm.h
  199. *** /tmp/PATCHold/./hptopbm.h    Wed Apr  1 02:46:56 1992
  200. --- ./hptopbm.h    Wed Apr  1 02:46:57 1992
  201. ***************
  202. *** 16,25 ****
  203.       Canada K0A 1T0
  204.       (613) 832-0541
  205.   
  206. !     Function: Header file for hp2pbm.  1.4 92/03/01 02:05:16
  207.    */
  208.   
  209. ! #define    VERSION    "hp2pbm V1.02"
  210.   
  211.   #include <stdio.h>
  212.   #include <ctype.h>
  213. --- 16,25 ----
  214.       Canada K0A 1T0
  215.       (613) 832-0541
  216.   
  217. !     Function: Header file for hp2pbm.  1.5 92/04/01 02:44:38
  218.    */
  219.   
  220. ! #define    VERSION    "hp2pbm V1.03"
  221.   
  222.   #include <stdio.h>
  223.   #include <ctype.h>
  224. ***************
  225. *** 58,67 ****
  226. --- 58,76 ----
  227.   #define    A4    1
  228.   #endif
  229.   
  230. + #define    RES    300
  231. + /* The YLEN and XLEN need only be approximate.  They *must* be
  232. +    >= actual dimensions.  If someone knows what the precise dimensions
  233. +    of A4 and B5 are, please email me.
  234. +  */
  235.   #if    LETTER
  236.   #define    PAGE_LEN    66
  237.   #define    RITE_MARGIN    80
  238.   #define RITE_LOGICAL    LEFT_LOGICAL+2400
  239. + #define    YLEN        ((double) 11)
  240. + #define    XLEN        ((double) 8.5)
  241.   #endif
  242.   
  243.   #if    A4
  244. ***************
  245. *** 68,73 ****
  246. --- 77,84 ----
  247.   #define    PAGE_LEN    70
  248.   #define    RITE_MARGIN    77
  249.   #define RITE_LOGICAL    LEFT_LOGICAL+2338
  250. + #define    YLEN        ((double) 12)
  251. + #define    XLEN        ((double) 8.5)
  252.   #endif
  253.   
  254.   #if    LEGAL
  255. ***************
  256. *** 74,79 ****
  257. --- 85,92 ----
  258.   #define    PAGE_LEN    84
  259.   #define    RITE_MARGIN    80
  260.   #define RITE_LOGICAL    LEFT_LOGICAL+2400
  261. + #define    YLEN        ((double) 14)
  262. + #define    XLEN        ((double) 8.5)
  263.   #endif
  264.   
  265.   #if    B5
  266. ***************
  267. *** 80,87 ****
  268. --- 93,103 ----
  269.   #define    PAGE_LEN    60
  270.   #define    RITE_MARGIN    66
  271.   #define RITE_LOGICAL    LEFT_LOGICAL+2400    /* dont know about B5's */
  272. + #define    YLEN        ((double) 10)
  273. + #define    XLEN        ((double) 8)
  274.   #endif
  275.   
  276.   #define    PRIMARY        1
  277.   #define    SECONDARY    2
  278.   
  279. ***************
  280. *** 147,149 ****
  281. --- 163,173 ----
  282.   #ifndef    TRUE
  283.   #define    TRUE    1
  284.   #endif
  285. + #define    RES    300
  286. + #ifdef    LETTER
  287. + #define    YLEN    ((double) 11)
  288. + #define    XLEN    ((double) 8.5)
  289. + #endif
  290. Index: ./pbm2ps.c
  291. *** /tmp/PATCHold/./pbm2ps.c    Wed Apr  1 02:47:05 1992
  292. --- ./pbm2ps.c    Wed Apr  1 02:47:07 1992
  293. ***************
  294. *** 0 ****
  295. --- 1,143 ----
  296. + /*
  297. +     Copyright 1989, 1990, 1991 Chris Lewis
  298. +     All Rights Reserved
  299. +     Permission to copy and further distribute is freely given provided
  300. +     this copyright notice remains intact, that this software is not
  301. +     sold for profit, that credit is given, and that sources will be made
  302. +     available on request.
  303. +     This software is a subset of Psroff 3.0.  See the LICENSE file
  304. +     in Psroff 3.0 for more details, or contact:
  305. +     Chris Lewis
  306. +     Box 124
  307. +     Dunrobin, Ontario
  308. +     Canada K0A 1T0
  309. +     (613) 832-0541
  310. +     Function: Very stupid PBM to PS converter.
  311. +           I hope you have a parallel interface!
  312. +  */
  313. + #ifndef    lint
  314. + static char SCCSID[] =
  315. +     "@(#)pbm2ps.c 1.1 92/04/01 01:45:04";
  316. + #endif
  317. + #include "hptopbm.h"
  318. + #define    RES    300
  319. + #ifdef    LETTER
  320. + #define    YLEN    ((double) 11)
  321. + #define    XLEN    ((double) 8.5)
  322. + #endif
  323. + #define    YMAX    (YLEN * RES)
  324. + #define    XMAX    (XLEN * RES)
  325. + #define    FASTER
  326. + #ifdef FASTER
  327. + char hex[] = "0123456789abcdef";
  328. + #endif
  329. + emitps(numx, numy, image)
  330. + int numx;
  331. + int numy;
  332. + char *image; {
  333. +     register long total, i;
  334. +     int bperline;
  335. +     int yoffset;
  336. +     register char *p;
  337. +     register int t;
  338. +     int skiplines;
  339. +     yoffset = YMAX - numy;    /* in pixels */
  340. +     bperline = ((numx + 7) / 8);
  341. +     total = bperline * numy;
  342. +     /* strip excess baggage from front of raster */
  343. +     for (p = image; p - image < total && !(*p); p++) ;
  344. +     skiplines = (p - image) / bperline;
  345. +     image = image + skiplines * bperline;
  346. +     numy = numy - skiplines;
  347. +     total = bperline * numy;
  348. +     /*fprintf(stderr, "Stripped %d lines from front\n", skiplines);*/
  349. +     /* strip excess baggage from end of raster */
  350. +     for (p = &image[total]; p > image && !(*p); p--) ;
  351. +     skiplines = numy - (p - image) / bperline - 1;
  352. +     numy -= skiplines;
  353. +     yoffset += skiplines;
  354. +     /*fprintf(stderr, "Stripped %d lines from end\n", skiplines);*/
  355. +     total = bperline * numy;
  356. +     /* end strip */
  357. +     printf("%%!PS-Adobe-2.0\n");
  358. +     printf("%%%%EndComments\n");
  359. +     printf("/DataString %d string def\n", bperline);
  360. +     printf("%%%%EndProlog\n");
  361. +     printf("%%Page: 1 1\n");
  362. +     printf("0 %f translate\n", (double) yoffset / 300 * 72);
  363. +     printf("%f %f scale\n", (numx / XMAX) * XLEN * 72,
  364. +                 (numy / YMAX) * YLEN * 72);
  365. +     printf("%d %d 1 [ %d 0 0 -%d 0 %d ]\n", numx, numy, numx, numy, numy);
  366. +     printf("{\n");
  367. +     printf("    currentfile DataString readhexstring pop\n");
  368. +     printf("} bind image\n");
  369. +     for (p = image, i = 0; i < total; p++, i++) {
  370. + #ifdef    FASTER
  371. +     t = ((*p) & 0xff) ^ 0xff;
  372. +     putchar(hex[(t >> 4)&0xf]);
  373. +     putchar(hex[t&0xf]);
  374. + #else
  375. +     printf("%02x", (*p) & 0xff);
  376. + #endif
  377. +     if ((i % 40) == 39)
  378. +         putchar('\n');
  379. +     }
  380. +     printf("\n\nshowpage\n");
  381. +     printf("%%%%Trailer\n");
  382. + }
  383. + char str[] =
  384. +     {0xdd, 0xff, 0x00, 0xff, 0x54, 0x1f, 0x80, 0x03, 0xfb, 0xf9, 0x00, 0x1e };
  385. + main() {
  386. +     long x, y;
  387. +     long count;
  388. +     register char *p;
  389. +     register char *buffer;
  390. +     char b[30];
  391. +     gets(b);
  392. +     if (strcmp(b, "P4")) {
  393. +     fprintf(stderr, "Not a PBM\n");
  394. +     exit(1);
  395. +     }
  396. +     gets (b);
  397. +     if (2 != sscanf(b, "%ld %ld", &x, &y)) {
  398. +     fprintf(stderr, "Not a PBM\n");
  399. +     exit(1);
  400. +     }
  401. +     count = ((x + 7) / 8) * y;
  402. +     buffer = malloc(count);
  403. +     if (!buffer) {
  404. +     fprintf(stderr, "Couldn't malloc raster buffer\n");
  405. +     exit(1);
  406. +     }
  407. +     /*fprintf(stderr, "Trying to read %ld bytes\n", count);*/
  408. +     if (fread(buffer, 1, count, stdin) != count) {
  409. +     fprintf(stderr, "Couldn't read the bitmap properly\n");
  410. +     exit(1);
  411. +     }
  412. +     emitps(x, y, buffer);
  413. +     exit(0);
  414. + }
  415. Index: ./pbm2xd.c
  416. *** /tmp/PATCHold/./pbm2xd.c    Wed Apr  1 02:47:14 1992
  417. --- ./pbm2xd.c    Wed Apr  1 02:47:17 1992
  418. ***************
  419. *** 0 ****
  420. --- 1,175 ----
  421. + /*
  422. +     Copyright 1989, 1990, 1991 Chris Lewis
  423. +     All Rights Reserved
  424. +     Permission to copy and further distribute is freely given provided
  425. +     this copyright notice remains intact, that this software is not
  426. +     sold for profit, that credit is given, and that sources will be made
  427. +     available on request.
  428. +     This software is a subset of Psroff 3.0.  See the LICENSE file
  429. +     in Psroff 3.0 for more details, or contact:
  430. +     Chris Lewis
  431. +     Box 124
  432. +     Dunrobin, Ontario
  433. +     Canada K0A 1T0
  434. +     (613) 832-0541
  435. +     Function: Creates xwd format files from PBM.  Permits
  436. +           X window display by xwud.
  437. +  */
  438. + #ifndef    lint
  439. + static char SCCSID[] =
  440. +     "@(#)pbm2Xd.c 1.2 92/04/01 02:44:44";
  441. + #endif
  442. + #include "hptopbm.h"
  443. + typedef long xwdval;
  444. + #define XWD_FILE_VERSION 7
  445. + typedef struct _xwd_file_header {
  446. +     xwdval header_size;      /* Size of the entire file header (bytes). */
  447. +     xwdval file_version;      /* XWD_FILE_VERSION */
  448. +     xwdval pixmap_format;      /* Pixmap format */
  449. +     xwdval pixmap_depth;      /* Pixmap depth */
  450. +     xwdval pixmap_width;      /* Pixmap width */
  451. +     xwdval pixmap_height;      /* Pixmap height */
  452. +     xwdval xoffset;           /* Bitmap x offset */
  453. +     xwdval byte_order;        /* MSBFirst, LSBFirst */
  454. +     xwdval bitmap_unit;       /* Bitmap unit */
  455. +     xwdval bitmap_bit_order;  /* MSBFirst, LSBFirst */
  456. +     xwdval bitmap_pad;      /* Bitmap scanline pad */
  457. +     xwdval bits_per_pixel;      /* Bits per pixel */
  458. +     xwdval bytes_per_line;      /* Bytes per scanline */
  459. +     xwdval visual_class;      /* Class of colormap */
  460. +     xwdval red_mask;      /* Z red mask */
  461. +     xwdval green_mask;      /* Z green mask */
  462. +     xwdval blue_mask;      /* Z blue mask */
  463. +     xwdval bits_per_rgb;      /* Log base 2 of distinct color values */
  464. +     xwdval colormap_entries;  /* Number of entries in colormap */
  465. +     xwdval ncolors;          /* Number of Color structures */
  466. +     xwdval window_width;      /* Window width */
  467. +     xwdval window_height;      /* Window height */
  468. +     long window_x;          /* Window upper left X coordinate */
  469. +     long window_y;          /* Window upper left Y coordinate */
  470. +     xwdval window_bdrwidth;      /* Window border width */
  471. + } XWDFileHeader;
  472. + dump(argc, argv)
  473. + int argc;
  474. + char **argv; {
  475. +     XWDFileHeader *d;
  476. +     char *p;
  477. +     xwdval v;
  478. +     extern char *malloc();
  479. +     int i;
  480. +     fread(&v, sizeof(d->header_size), 1, stdin);
  481. +     printf("Header size is %ld, struct is: %d\n", v, sizeof(*d));
  482. +     d = (XWDFileHeader *) malloc(v);
  483. +     d->header_size = v;
  484. +     fread(&d->file_version, sizeof(*d) - sizeof(d->header_size), 1, stdin);
  485. +     printf("Size of the entire file header (bytes).: %ld\n", d->header_size);
  486. +     printf("XWD_FILE_VERSION: %ld\n", d->file_version);
  487. +     printf("Pixmap format: %ld\n", d->pixmap_format);
  488. +     printf("Pixmap depth: %ld\n", d->pixmap_depth);
  489. +     printf("Pixmap width: %ld\n", d->pixmap_width);
  490. +     printf("Pixmap height: %ld\n", d->pixmap_height);
  491. +     printf("Bitmap x offset: %ld\n", d->xoffset);
  492. +     printf("MSBFirst, LSBFirst: %ld\n", d->byte_order);
  493. +     printf("Bitmap unit: %ld\n", d->bitmap_unit);
  494. +     printf("MSBFirst, LSBFirst: %ld\n", d->bitmap_bit_order);
  495. +     printf("Bitmap scanline pad: %ld\n", d->bitmap_pad);
  496. +     printf("Bits per pixel: %ld\n", d->bits_per_pixel);
  497. +     printf("Bytes per scanline: %ld\n", d->bytes_per_line);
  498. +     printf("Class of colormap: %ld\n", d->visual_class);
  499. +     printf("Z red mask: %ld\n", d->red_mask);
  500. +     printf("Z green mask: %ld\n", d->green_mask);
  501. +     printf("Z blue mask: %ld\n", d->blue_mask);
  502. +     printf("Log base 2 of distinct color values: %ld\n", d->bits_per_rgb);
  503. +     printf("Number of entries in colormap: %ld\n", d->colormap_entries);
  504. +     printf("Number of Color structures: %ld\n", d->ncolors);
  505. +     printf("Window width: %ld\n", d->window_width);
  506. +     printf("Window height: %ld\n", d->window_height);
  507. +     printf("Window upper left X coordinate: %ld\n", d->window_x);
  508. +     printf("Window upper left Y coordinate: %ld\n", d->window_y);
  509. +     printf("Window border width: %ld\n", d->window_bdrwidth);
  510. +     p = (char*) d;
  511. +     for (i = sizeof(*d); i < d->header_size; i++)
  512. +     printf("%02x", p[i]);
  513. +     putchar('\n');
  514. + }
  515. + emitX(x, y, buffer)
  516. + int x, y;
  517. + char *buffer; {
  518. +     XWDFileHeader d;
  519. +     d.header_size = 100;
  520. +     d.file_version = 7;
  521. +     d.pixmap_format = 2;
  522. +     d.pixmap_depth = 1;
  523. +     d.pixmap_width = x;
  524. +     d.pixmap_height = y;
  525. +     d.xoffset = 0;
  526. +     d.byte_order = 1;
  527. +     d.bitmap_unit = 32;
  528. +     d.bitmap_bit_order = 1;
  529. +     d.bits_per_pixel = 1;
  530. +     d.bytes_per_line = (x + 7) / 8;
  531. +     d.visual_class = 0;
  532. +     d.red_mask = 0;
  533. +     d.green_mask = 0;
  534. +     d.blue_mask = 0;
  535. +     d.bits_per_rgb = 0;
  536. +     d.colormap_entries = 0;
  537. +     d.ncolors = 0;
  538. +     d.window_width = x;
  539. +     d.window_height = y;
  540. +     d.window_x = 50;
  541. +     d.window_y = 50;
  542. +     d.window_bdrwidth = 0;
  543. +     fwrite(&d, 1, sizeof(d), stdout);
  544. +     fwrite(buffer, d.bytes_per_line * y, 1, stdout);
  545. + }
  546. + main(argc, argv)
  547. + int argc; char **argv; {
  548. +     long x, y;
  549. +     long count;
  550. +     register char *p;
  551. +     register char *buffer;
  552. +     char b[30];
  553. +     if (argc != 1) {
  554. +     dump(argc, argv);
  555. +     exit(0);
  556. +     }
  557. +     gets(b);
  558. +     if (strcmp(b, "P4")) {
  559. +     fprintf(stderr, "Not a PBM\n");
  560. +     exit(1);
  561. +     }
  562. +     gets (b);
  563. +     if (2 != sscanf(b, "%ld %ld", &x, &y)) {
  564. +     fprintf(stderr, "Not a PBM\n");
  565. +     exit(1);
  566. +     }
  567. +     count = ((x + 7) / 8) * y;
  568. +     buffer = malloc(count);
  569. +     if (!buffer) {
  570. +     fprintf(stderr, "Couldn't malloc raster buffer\n");
  571. +     exit(1);
  572. +     }
  573. +     /*fprintf(stderr, "Trying to read %ld bytes\n", count);*/
  574. +     if (fread(buffer, 1, count, stdin) != count) {
  575. +     fprintf(stderr, "Couldn't read the bitmap properly\n");
  576. +     exit(1);
  577. +     }
  578. +     emitX(x, y, buffer);
  579. +     exit(0);
  580. + }
  581.  
  582. -- 
  583. Chris Lewis; clewis@ferret.ocunix.on.ca; Phone: Canada 613 832-0541
  584. Psroff 3.0 info: psroff-request@ferret.ocunix.on.ca
  585. Ferret list: ferret-request@ferret.ocunix.on.ca
  586.  
  587. exit 0 # Just in case...
  588.