home *** CD-ROM | disk | FTP | other *** search
/ Photo CD Demo 1 / Demo.bin / gle / gle / dvilj.c < prev    next >
C/C++ Source or Header  |  1992-11-29  |  2KB  |  63 lines

  1. /* this is for a   Laserjet series II printer, which I think doesn't
  2. like the compressed data format */
  3.  
  4. #define XSIZECM 19        /* 150 dpi*/
  5. #define YSIZECM 27        /* */
  6. #define NXBITS 1128     /* (XSIZECM/2.54)*150  rounded up to nearest byte */
  7. #define NYBITS 1600
  8.  
  9. extern int hp_plus;
  10. #include "bitmap.h"
  11. dvitype(void)
  12. {
  13.     if (hp_plus)
  14.      printf("Deskjet/Laserjet  (usage: dvilj [-old] [-debug] [outfile.prt])\n  (use -old for printers which cannot handle data compression.)");
  15.     else
  16.      printf("Deskjet/Laserjet  (NO COMPRESSION)");
  17. }
  18. int ljsendline(char *s, int nc, int y);
  19. bitmap_print(void)
  20. {
  21.     int x,y,nout;
  22.     static unsigned char out_buff[NXBITS+30];
  23.     unsigned char swapbit[256];
  24.     unsigned char swapnib[16]={0,8,4,12,2,10,6,14,1,9,5,13,3,11,7,15};
  25.     unsigned char *o,c;
  26.     int nc,i,n1,n2;
  27.  
  28.     printf("Writing out bitmap\n");
  29.     for (i=0;i<256;i++) {
  30.         n1 = i & 0xf;
  31.         n2 = (i >> 4) & 0xf;
  32.         swapbit[i] = swapnib[n2] | (swapnib[n1] << 4);
  33.     }
  34.     pprintf("%cE",27);     /* reset  */
  35.     pprintf("\x1b*t150R");    /* set resolution 150 dpi */
  36.     /* pprintf("\x1b&a%.1fH",0.0); */            /* move x */
  37.     /* pprintf("\x1b&a%.1fV",((NYBITS-y)/150.0)*720.0); */    /* move y */
  38.     if (hp_plus)  pprintf("\x1b*b1M");    /* compact */
  39.     pprintf("\x1b*r1A");            /* start graphics at cur pos */
  40.     for (y=(nybits-1); y>=0; y--) {
  41.         for (nout=(nxbits/8);  bitmap[y][nout-1]==0 && nout>0; nout--);
  42.         o = &out_buff[0];
  43.         for (x=0; x<nout ; x++) {
  44.         c = bitmap[y][x];
  45.         nc = 0;
  46.         if (hp_plus) {
  47.             for (;x<(nout-1) && bitmap[y][x+1]==c && nc<250; x++) nc++;
  48.             *o++ = nc;
  49.         }
  50.         *o++ = swapbit[c];
  51.       }
  52.       ljsendline(out_buff,o-out_buff,y);
  53.     }
  54.     pprintf("\x1b*rB");    /* end graphics */
  55.     pprintf("\x0c");    /* form feed, reset origin */
  56. }
  57. ljsendline(char *s, int nc,int y)
  58. {
  59.     pprintf("\x1b*b%dW",nc);    /* send y bytes */
  60.     printmem(s,nc);
  61. }
  62.  
  63.