home *** CD-ROM | disk | FTP | other *** search
/ Graphics Plus / Graphics Plus.iso / libs / gle / dvivt.c < prev    next >
Encoding:
C/C++ Source or Header  |  1992-11-29  |  14.6 KB  |  658 lines

  1. /* This file contains the output drivers for
  2.         LaserJets, Epson, Vt100's and pc screens.
  3.     If some kind sole would like to add LA100 etc, go right ahead,
  4.         (you will have to modify DVITOBIT.C to call your
  5.         extra dev_size_la100, and dev_print_la100 routines)
  6. */
  7.  
  8. #include <stdlib.h>
  9. #include <stdio.h>
  10. #include <ctype.h>
  11. #include <string.h>
  12. #include <assert.h>
  13. #ifdef __TURBOC__
  14. #include <graphics.h>
  15. #include <conio.h>
  16. #endif
  17. #include "bmp.h"
  18. #define false 0
  19. #define true !false
  20.  
  21. char *bgidir();
  22. int cmtobits(double *x, int *nx, double dpi);
  23. int printstrd(char *s, int i);
  24. int printstr(char *s);
  25. extern int dev_hpplus,dev_hires,bmp_compress,dev_lowmem,dev_low,iscolor;
  26. extern int dev_noff,dev_nosquash,dev_wide,dev_noclip,dev_over,dev_noflip;
  27. extern char outbitname[];
  28.  
  29. #ifdef __TURBOC__
  30. dev_size_vt(int *nxbits, int *nybits, double *devxcm, double *devycm)
  31. {
  32.     *devxcm = 20;
  33.     *devycm = 15;
  34.     dev_noflip = true;
  35.     dev_hires = true;
  36.     if (dev_hires) {
  37.         *nxbits = 400;
  38.         *nybits = 400;
  39.     } else {
  40.         *nxbits = 70;
  41.         *nybits = 50;
  42.     }
  43. }
  44. dev_print_vt(Bitmap *b)
  45. {
  46.    int gdriver = DETECT, gmode, errorcode;
  47.    int x,y,z;
  48.    int white;
  49.    char *line;
  50.    initgraph(&gdriver, &gmode, bgidir());
  51.    errorcode = graphresult();
  52.    if (errorcode != grOk)  /* an error occurred */
  53.    {
  54.       printf("Graphics error: %s\n", grapherrormsg(errorcode));
  55.       printf("Press any key to halt:");
  56.       getch();
  57.       exit(1);             /* return with error code */
  58.    }
  59.  
  60.    white = getmaxcolor();
  61.     for (y=0; y<b->ny; y++) {
  62.       line = bmp_row(b,b->ny-y);
  63.       setfillstyle(SOLID_FILL,getmaxcolor());
  64.       for (x=0; x< b->nx ; x++) {
  65.         z = 1 << (x % 8);
  66.         if ((z & line[x/8]) != 0) {
  67.           if (dev_hires) {
  68.             putpixel(x,y,white);
  69.           } else {
  70.                 bar(x*10,y*10,x*10+8,y*10+8);
  71.           }
  72.         }
  73.       }
  74.     }
  75.  
  76.    /* clean up */
  77.    getch();
  78.    closegraph();
  79.    return 0;
  80. }
  81. #else
  82. dev_size_vt(int *nxbits, int *nybits, double *devxcm, double *devycm)
  83. {
  84.     *devxcm = 20;
  85.     *devycm = 15;
  86.     *nxbits = 76;
  87.     *nybits = 22;
  88. }
  89. dev_print_vt(Bitmap *b)
  90. {
  91.    int x,y,z;
  92.    char *line;
  93.  
  94.     for (y=0; y<b->ny; y++) {
  95.       line = bmp_row(b,b->ny-y);
  96.       for (x=0; x<b->nx ; x++) {
  97.         z = 1 << (x % 8);
  98.         if ((z & line[x/8]) != 0) {
  99.             printf("#");
  100.         } else printf(" ");
  101.       }
  102.       printf("[%d]\n",b->ny-y);
  103.     }
  104. }
  105. #endif
  106.  
  107. dev_size_lj(int *nxbits, int *nybits, double *devxcm, double *devycm)
  108. {
  109.     if (dev_wide) {
  110.         if (!dev_nosquash && *devxcm>28) *devxcm = 28;
  111.     } else {
  112.         if (!dev_nosquash && *devycm>27) *devycm = 27;
  113.         if (!dev_nosquash && *devxcm>19) *devxcm = 19;
  114.     }
  115.     if (dev_lowmem) {
  116.         *devxcm = 16;
  117.         *devycm = 12;
  118.     }
  119.     if (dev_hires) {
  120.         cmtobits(devxcm,nxbits,300);
  121.         cmtobits(devycm,nybits,300);
  122.     } else {
  123.         cmtobits(devxcm,nxbits,150);
  124.         cmtobits(devycm,nybits,150);
  125.     }
  126. }
  127.  
  128. int ljsendline(char *s, int nc, int y);
  129. dev_print_lj(Bitmap *b)
  130. {
  131.     int x,y,nout;
  132.     static unsigned char *out_buff;
  133.     char pbuff[80];
  134.     unsigned char swapbit[257];
  135.     unsigned char swapnib[16]={0,8,4,12,2,10,6,14,1,9,5,13,3,11,7,15};
  136.     unsigned char *o,c,*line;
  137.     int nc,i,n1,n2;
  138.  
  139.     out_buff = (ucharp) malloc(b->nx + 10);
  140.     if (out_buff==NULL) {
  141.         printf("Memory allocation failure for outbuff \n");
  142.         exit(1);
  143.     }
  144.     for (i=0;i<256;i++) {
  145.         n1 = i & 0xf;
  146.         n2 = (i >> 4) & 0xf;
  147.         swapbit[i] = swapnib[n2] | (swapnib[n1] << 4);
  148.     }
  149.     for (i=0;i<256;i++) swapbit[i] = 255-swapbit[i]; /* invert */
  150.  
  151.     if (!dev_noff)     printstrd("%cE",27);     /* reset  */
  152.     if (dev_hires) printstr("\x1b*t300R");    /* set resolution */
  153.     else           printstr("\x1b*t150R");
  154.     if (dev_hpplus)  printstr("\x1b*b1M");    /* compact */
  155.     printstr("\x1b*r1A");            /* start graphics at cur pos */
  156.     for (y=(b->ny-1); y>=0; y--) {
  157.       line = (ucharp) bmp_row(b,y);
  158.       for (nout=(b->nx/8+1); line[nout-1]==255 && nout>0; nout--);
  159.       o = &out_buff[0];
  160.       for (x=0; x<nout; x++) {
  161.           c = line[x];
  162.           nc = 0;
  163.            if (dev_hpplus) {
  164.           for (;x<nout-1 && line[x+1]==c && nc<250; x++) nc++;
  165.           *o++ = nc;
  166.           }
  167.           *o++ = swapbit[c];
  168.       }
  169.       ljsendline((char *) out_buff,o-out_buff,y);
  170.     }
  171.     printstr("\x1b*rB");        /* end graphics */
  172. #ifdef __TURBOC__
  173.     /* vax print symbiont adds a FF character itself */
  174.     if (!dev_noff) printstr("\x0c"); /* form feed, reset origin */
  175. #endif
  176. }
  177. ljsendline(char *s, int nc,int y)
  178. {
  179.     printstrd("\x1b*b%dW",nc);    /* send nc bytes */
  180.     printmem(s,nc);
  181. }
  182. printstrd(char *s, int i)
  183. {
  184.     static char pbuff[128];
  185.     sprintf(pbuff,s,i);
  186.     printmem(pbuff,strlen(pbuff));
  187. }
  188. printstr(char *s)
  189. {
  190.     printmem(s,strlen(s));
  191. }
  192.  
  193. dev_size_pj(int *nxbits, int *nybits, double *devxcm, double *devycm)
  194. {
  195.     if (dev_wide) {
  196.         if (!dev_nosquash && *devxcm>28) *devxcm = 28;
  197.     } else {
  198.         if (!dev_nosquash && *devycm>27) *devycm = 27;
  199.         if (!dev_nosquash && *devxcm>19) *devxcm = 19;
  200.     }
  201.     iscolor = true;
  202.     if (dev_hires) {
  203.         cmtobits(devxcm,nxbits,180);
  204.         cmtobits(devycm,nybits,180);
  205.     } else {
  206.         cmtobits(devxcm,nxbits,90);
  207.         cmtobits(devycm,nybits,90);
  208.     }
  209. }
  210. cmtobits(double *x, int *nx, double dpi)
  211. {
  212.     *nx = (int) dpi*(*x / 2.54);
  213.     *nx = *nx/8;
  214.     *nx = *nx*8+8;
  215.        (*nx)--;
  216.     *x = (*nx/dpi)*2.54;
  217. }
  218. int pjsendline(char *s, int nc, int y, int plane);
  219. dev_print_pj(Bitmap *b)
  220. {
  221.     int x,y,nout;
  222.     static unsigned char *out_buff, *out_buff2;
  223.     static unsigned char *out_buffp0, *out_buffp1, *out_buffp2;
  224.     char pbuff[80];
  225.     unsigned char swapbit[257];
  226.     unsigned char swapnib[16]={0,8,4,12,2,10,6,14,1,9,5,13,3,11,7,15};
  227.     unsigned char *o,c,*line;
  228.     int nc,i,n1,n2,plane;
  229.  
  230.     out_buff = (ucharp) malloc(b->nx + 10);
  231.     out_buffp0 = (ucharp)  malloc(b->nx + 10);
  232.     out_buffp1 = (ucharp) malloc(b->nx + 10);
  233.     out_buffp2 = (ucharp) malloc(b->nx + 10);
  234.     if (out_buff==NULL || out_buffp2==NULL) {
  235.         printf("Memory allocation failure for outbuff \n");
  236.         exit(1);
  237.     }
  238.     for (i=0;i<256;i++) {
  239.         n1 = i & 0xf;
  240.         n2 = (i >> 4) & 0xf;
  241.         swapbit[i] = swapnib[n2] | (swapnib[n1] << 4);
  242.     }
  243. /*    for (i=0;i<256;i++) swapbit[i] = 255-swapbit[i];  invert */
  244.  
  245.  
  246.  
  247.     if (!dev_noff)     printstrd("%cE",27);     /* reset  */
  248.     if (dev_over) printstrd("%c&k3W",27); /* transparency mode */
  249.     if (dev_hires) printstr("\x1b*t180R");    /* set resolution */
  250.     else           printstr("\x1b*t90R");
  251.     if (dev_hpplus)  printstr("\x1b*b1M");    /* compact */
  252.  
  253.     printstr("\x1b*r3U");    /* use 3 color planes, 8 colors*/
  254.     printstrd("\x1b*r%dS",b->nx); /* set width of image */
  255.     printstr("\x1b*r1A");            /* start graphics at cur pos */
  256.  
  257.  
  258.     for (y=(b->ny-1); y>=0; y--) {
  259.       line = (ucharp) bmp_row(b,y);
  260.       nout = b->nx/8;
  261.       for (x=0; x<=b->nx/8; x++) {  /* extract one plane of bits */
  262.           for (plane = 0; plane < 3; plane++) {
  263.         c = bitplane(line,x,plane);
  264.         switch (plane) {
  265.           case 0:
  266.             out_buffp0[x] = c; break;
  267.           case 1:
  268.             out_buffp1[x] = c; break;
  269.           case 2:
  270.             out_buffp2[x] = c; break;
  271.         }
  272.           }
  273.       }
  274.  
  275.       for (plane = 0; plane < 3; plane++) {
  276.         switch (plane) {
  277.           case 0:
  278.         out_buff2 = out_buffp0;
  279.         break;
  280.           case 1:
  281.         out_buff2 = out_buffp1;
  282.         break;
  283.           case 2:
  284.         out_buff2 = out_buffp2;
  285.         break;
  286.         }
  287.         o = &out_buff[0];
  288.         for (x=0; x<=nout; x++) {
  289.           c = out_buff2[x];
  290.           nc = 0;
  291.            if (dev_hpplus) {  /* compress if requested */
  292.           for (;x<nout-1 && out_buff2[x+1]==c && nc<250; x++) nc++;
  293.           *o++ = nc;
  294.           }
  295.           *o++ = swapbit[c];
  296.         }
  297.  
  298.         pjsendline((char *) out_buff,o-out_buff,y,plane);
  299.       }
  300.     }
  301.     printstr("\x1b*rB");        /* end graphics */
  302. #ifdef __TURBOC__
  303.     /* vax print symbiont adds a FF character itself */
  304.     if (!dev_noff) printstr("\x0c"); /* form feed, reset origin */
  305. #endif
  306. }
  307. int pjsendline(char *s, int nc,int y,int plane)
  308. {
  309.     int x;
  310.  
  311.     if (plane==2)     printstrd("\x1b*b%dW",nc);    /* send nc bytes */
  312.     else         printstrd("\x1b*b%dV",nc);    /* send nc bytes */
  313.     printmem(s,nc);
  314. }
  315.  
  316. bitplane(char line[],int x, int p)
  317. {
  318.     /* x is byte count */
  319.     /* construct a byte from line[x].hi.low.p  ... line[x+7] */
  320.     register xx,i,curbit,c,pm;
  321.     c = 0;
  322.     x = x*8;
  323.     pm = 1 << p;
  324.     curbit = 1;
  325.     for (xx=x; xx<x+8; xx++) {
  326.         i = line[xx/2];
  327.         if (xx % 2==0) i = (i & 0xf0)>>4;
  328.         else i = i & 0xf;
  329.         i = i & pm;
  330.         if (i!=0) c = c + curbit;
  331.         curbit = curbit << 1;
  332.     }
  333.     return c;
  334. }
  335.  
  336.  
  337. dev_size_ep(int *nxbits, int *nybits, double *devxcm, double *devycm)
  338. {
  339.     if (dev_wide) {
  340.         if (!dev_nosquash && *devxcm>28) *devxcm = 28;
  341.     } else {
  342.         if (!dev_nosquash && *devycm>27) *devycm = 27;
  343.         if (!dev_nosquash && *devxcm>19) *devxcm = 19;
  344.     }
  345.     if (dev_hires) {
  346.         cmtobits(devxcm,nxbits,180);
  347.         cmtobits(devycm,nybits,180);
  348.     } else {
  349.         cmtobits(devxcm,nxbits,120);
  350.         cmtobits(devycm,nybits,72);
  351.     }
  352. }
  353.  
  354. dev_print_ep(Bitmap *b)
  355. {
  356.     int nny,x,y,nout;
  357.     static unsigned char *out_buff;
  358.     char pbuff[80];
  359.     unsigned char *o,c,*line;
  360.     int nc,i,n1,n2,r,z;
  361.  
  362.     if (dev_hires) {
  363.         dev_print_ep24(b);
  364.         return;
  365.     }
  366.     out_buff = (ucharp) malloc(b->nx + 10);
  367.     if (out_buff==NULL) {
  368.         printf("Memory allocation failure for outbuff \n");
  369.         exit(1);
  370.     }
  371.     nny = b->ny;
  372.     if (8*(nny/8) != nny) nny = (1+(nny/8))*8;
  373.     for (y=nny-8 ; y>=0 ; y-=16) {
  374.         for (r=0;r<(b->nx+5);r++) out_buff[r] = 0; /* zero array */
  375.         for (r=0; r<8 ; r++,y++) {  /* for each of 8 columns */
  376.             line = (ucharp) bmp_row(b,y);
  377.             if (b->ny>=y) {
  378.             for (x=0; x<b->nx;x++) {
  379.                 z = 1 << (x % 8);
  380.                 if ((z & line[x/8]) == 0) {
  381.                      out_buff[x] |= 1 << r;
  382.                 }
  383.             }}
  384.         }
  385.         for (nout=(b->nx); out_buff[nout-1]==0 && nout>0; nout--);
  386.         epsendline(out_buff,nout);
  387.     }
  388. #ifdef __TURBOC__
  389.     /* vax print symbiont adds a FF character itself */
  390.     if (!dev_noff) printstr("\x0c"); /* form feed, reset origin */
  391. #endif
  392. }
  393. epsendline(char *s, int nc)
  394. {
  395.     char buff[20];
  396.     strcpy(buff,"\x1bL");
  397.     buff[2] = (nc) & 255;
  398.     buff[3] = (nc) / 256;
  399.     printmem(buff,4);
  400.     printmem(s,nc);
  401.     printstr("\x0d\x1bJ\x18");
  402. }
  403.  
  404. ep24sendline(char *s, int nc)
  405. {
  406.     char buff[20];
  407.     strcpy(buff,"\x1b*\x27");
  408.     nc = nc / 3 + 1;
  409.     buff[3] = (nc) & 255;
  410.     buff[4] = (nc) / 256;
  411.     printmem(buff,5);
  412.     printmem(s,nc*3);
  413.     printstr("\x0d\x1bJ\x18");
  414. }
  415. dev_print_ep24(Bitmap *b)
  416. {
  417.     int x,y,nout;
  418.     static unsigned char *out_buff;
  419.     char pbuff[80];
  420.     unsigned char *o,c,*line;
  421.     int nc,i,n1,n2,r,z,nny;
  422.  
  423.     out_buff = (ucharp) malloc(3*b->nx + 20);
  424.     if (out_buff==NULL) {
  425.         printf("Memory allocation failure for outbuff \n");
  426.         exit(1);
  427.     }
  428.     nny = b->ny;
  429.     if (24*(nny/24) != nny) nny = (1+(nny/24))*24;
  430.     for (y=nny-24 ; y>=0 ; y-=48) {
  431.         /* printf("y=%d\n",y); */
  432.         for (r=0;r<(b->nx*3+5);r++) out_buff[r] = 0; /* zero array */
  433.         for (r=0; r<24; r++,y++) {  /* for each of 8 columns */
  434.             line = (ucharp) bmp_row(b,y);
  435.             if (b->ny>=y) {
  436.             for (x=0; x<b->nx; x++) {
  437.                 z = 1 << (x % 8);
  438.                 if ((z & line[x/8]) == 0) {
  439.                     if (r<8) {
  440.                          out_buff[x*3+2] |= 1 << r;
  441.                     } else if (r<16) {
  442.                          out_buff[x*3+1] |= 1 << (r-8);
  443.                     } else {
  444.                          out_buff[x*3+0] |= 1 << (r-16);
  445.                     }
  446.                 }
  447.             }}
  448.         }
  449.         for (nout=(3*b->nx); out_buff[nout-1]==0 && nout>0; nout--);
  450.         ep24sendline((char *)out_buff,nout);
  451.     }
  452. #ifdef __TURBOC__
  453.     /* vax print symbiont adds a FF character itself */
  454.     if (!dev_noff) printstr("\x0c"); /* form feed, reset origin */
  455. #endif
  456. }
  457.  
  458. /* Word Perfect, tiff generation */
  459.  
  460. extern int fittobit;
  461. dev_size_wp(int *nxbits, int *nybits, double *devxcm, double *devycm)
  462. {
  463.     *devxcm = 24;
  464.     *devycm = 24;
  465.     *nxbits = 200;
  466.     *nybits = 200;
  467.     fittobit = true;
  468. }
  469.  
  470. #ifndef unix
  471. /* tiff stuff starts here */
  472.  
  473. long sa(long a);
  474. long ss(char *s);
  475. long sw(int x);
  476. long sl(long x);
  477. long read_eps(char *fname,FILE *tf);
  478. int sendmem(char *s, long j);
  479. int setl(long p, long x);
  480. int setw(long p, int x);
  481.  
  482. long tcnt; /* current byte position */
  483. extern FILE *outbit;
  484. FILE *tf;
  485. int addeps=true;
  486. long tstart;
  487.  
  488. dev_print_wp(Bitmap *b)
  489. {
  490.     /* 1=byte, 2=ascii, 3=short, 4=long, 5=rational */
  491.     char fname[80];
  492.     long strip1,entrycount,stripoffsets,stripbcounts,ifd;
  493.     long datep,datelen,namep,namelen,i,j;
  494.     long h_ps,h_pslen,h_tiff,h_tifflen;
  495.  
  496.     tf = outbit; /* output file handle */
  497.  
  498.     if (addeps) {
  499.         sw(0xd0c5); sw(0xc6d3);
  500.         h_ps = sl(0);
  501.         h_pslen = sl(0);
  502.         sl(0); sl(0);
  503.         h_tiff = sl(0);
  504.         h_tifflen = sl(0);
  505.         sw(0xffff);
  506.  
  507.         setl(h_ps,sa(tcnt));
  508.         i = tcnt;
  509.         tcnt += read_eps(outbitname,tf);
  510.         setl(h_pslen,tcnt-i);
  511.     }
  512.  
  513.  
  514.     tstart = sw(0x4949); /* byte order  4d 4d */
  515.     sw(0x002a);
  516.     ifd = sl(0x0000);
  517.     entrycount = sw(0);
  518.     setl(ifd,sa(entrycount));
  519.     sw(0xff); sw(3); sl(1); sw(1);  sw(0);        /* subfiletype */
  520.     sw(0x100); sw(3); sl(1); sl(b->nx);     /* image width */
  521.     sw(0x101); sw(3); sl(1); sl(b->ny);          /* image length */
  522.     sw(0x102); sw(3); sl(1); sw(1); sw(0);  /* bits per sample */
  523.     sw(0x103); sw(3); sl(1); sw(1); sw(0);    /* no compression */
  524.     sw(0x106); sw(3); sl(1); sw(1); sw(0);  /* black and white */
  525.     sw(0x111); sw(4); sl(1); stripoffsets = sl(0); /* offsets to image data */
  526.     sw(0x11c); sw(3); sl(1); sw(1); sw(0); /* planar config */
  527.     sw(0x131); sw(2); namelen = sl(1); namep = sl(0); /* Name  */
  528.     sl(0); /* end of table  */
  529.     setw(entrycount,9);
  530.     strip1 = tcnt;
  531.     send_image(b);
  532.     setl(stripoffsets,sa(strip1));
  533.  
  534.     namelen = strlen("GLE Tiff output.");
  535.     setl(namep,sa(ss("GLE Tiff output.")));
  536.  
  537.     if (addeps) {
  538.         setl(h_tiff,tstart);
  539.         setl(h_tifflen,tcnt-tstart);
  540.     }
  541.  
  542.     fclose(tf);
  543.  
  544. }
  545. send_image(Bitmap *b)
  546. {
  547.     int y;
  548.     unsigned char swapnib[16]={0,8,4,12,2,10,6,14,1,9,5,13,3,11,7,15};
  549.     unsigned char swapbit[257];
  550.     unsigned char savechar,temp;
  551.     static unsigned char *out_buff;
  552.     unsigned int r,i,j,newy,x,z;
  553.     unsigned char *line;
  554.     unsigned char *o,c;
  555.     int n1,n2;
  556.  
  557.     if (out_buff==0) out_buff = (ucharp) malloc(b->nx + 10);
  558.     if (out_buff==NULL) {
  559.         printf("Memory allocation failure for outbuff \n");
  560.         exit(1);
  561.     }
  562.     for (i=0;i<256;i++) {
  563.         n1 = i & 0xf;
  564.         n2 = (i >> 4) & 0xf;
  565.         swapbit[i] = swapnib[n2] | (swapnib[n1] << 4);
  566.     }
  567.  
  568.     for (y=b->ny-1 ; y>=0 ; y-=1) {
  569.         out_buff[0] = 0;
  570.         line = (ucharp) bmp_row(b,y);
  571.         for (i=0; i<b->nx/8; i++) {
  572.             out_buff[i] = swapbit[line[i]];
  573.         }
  574.  
  575.         sendmem((char *) out_buff,b->nx/8);
  576.     }
  577. }
  578.  
  579.  
  580. long sa(long a)
  581. {
  582.     return a-tstart;
  583. }
  584. long sw(int x)
  585. {
  586.     fwrite(&x,2,1,tf);
  587.     tcnt += 2;
  588.     return tcnt-2;
  589. }
  590. long ss(char *s)
  591. {
  592.     int i;
  593.  
  594.     i = strlen(s)+1;
  595.     if (i&1 == 1) i++;
  596.     fwrite(s,1,i,tf);
  597.     tcnt += i;
  598.     return tcnt-i;
  599. }
  600. sendmem(char *s, long j)
  601. {
  602.     fwrite(s,1,j,tf);
  603.     tcnt += j;
  604. }
  605. long sl(long x)
  606. {
  607.     fwrite(&x,4,1,tf);
  608.     tcnt += 4;
  609.     return tcnt-4;
  610. }
  611. setl(long p, long x)
  612. {
  613.     if (fseek(tf,p,SEEK_SET)!=0)  printf("Seekl failed, %ld %ld\n",p,tcnt);
  614.     fwrite(&x,4,1,tf);
  615.     if (fseek(tf,tcnt,SEEK_SET)!=0) printf("Seekl eof failed, %ld \n",p);
  616. }
  617. setw(long p, int x)
  618. {
  619.     if (fseek(tf,p,SEEK_SET)!=0) printf("Seekw failed, %ld  %ld\n",p,tcnt);
  620.     fwrite(&x,2,1,tf);
  621.     if (fseek(tf,tcnt,SEEK_SET)!=0) printf("Seekw eof failed, %ld \n",p);
  622. }
  623.  
  624. long read_eps(char *fname,FILE *tf)
  625. {
  626.     FILE *eps;
  627.     static char buff[1002];
  628.     char *s;
  629.     long tot=0;
  630.     int n;
  631.  
  632.     strcpy(buff,fname);
  633.     s = strchr(buff,'.');
  634.     if (s!=NULL) *s = 0;
  635.     strcat(buff,".eps");
  636.  
  637.     eps = fopen(buff,"rb");
  638.     if (eps==NULL) {
  639.         printf("Unable to open {%s}, you must PSGLE /EPS first\n",buff);
  640.         abort();
  641.     }
  642.  
  643.     for (;!feof(eps);) {
  644.       n = fread(buff,1,1000,eps);
  645.       if (n>0) {
  646.         fwrite(buff,1,n,tf);
  647.         tot += n;
  648.       }
  649.     }
  650.     buff[0] = 13; buff[1] = 10; buff[2] = 0;
  651.     if (tot&1 == 1) {fwrite(" ",1,1,tf); tot++;}
  652.     fwrite(buff,1,2,tf); tot+=2;
  653.     return tot;
  654. }
  655. #else
  656. dev_print_wp(Bitmap *b){}
  657. #endif
  658.