home *** CD-ROM | disk | FTP | other *** search
/ Club Amiga de Montreal - CAM / CAM_CD_1.iso / files / 377b.lha / devices / printer / epsonq / transfer.c < prev   
Encoding:
C/C++ Source or Header  |  1980-02-03  |  2.7 KB  |  111 lines

  1.  
  2. #include <exec/types.h>
  3. #include <devices/printer.h>
  4. #include <devices/prtbase.h>
  5. #include <devices/prtgfx.h>
  6.  
  7. Transfer(PInfo, y, ptr, colors)
  8. struct PrtInfo *PInfo;
  9. UWORD y;    /* row # */
  10. UBYTE *ptr;    /* ptr to buffer */
  11. UWORD *colors; /* indexes to color buffers */
  12. {
  13.     extern struct PrinterData *PD;
  14.     extern struct PrinterExtendedData *PED;
  15.  
  16.     static UWORD bit_table[8] = {128, 64, 32, 16, 8, 4, 2, 1};
  17.     union colorEntry *ColorInt;
  18.     UBYTE *bptr, *yptr, *mptr, *cptr, Black, Yellow, Magenta, Cyan;
  19.     UBYTE *dmatrix, dvalue, threshold;
  20.     UWORD x, width, sx, *sxptr, bit, x3, ymod;
  21.  
  22.     /* pre-compute */
  23.     /* printer non-specific, MUST DO FOR EVERY PRINTER */
  24.     x = PInfo->pi_xpos;
  25.     ColorInt = PInfo->pi_ColorInt;
  26.     sxptr = PInfo->pi_ScaleX;
  27.     width = PInfo->pi_width;
  28.     /* printer specific */
  29.     x3 = x * 3;
  30.     ymod = y % PED->ped_NumRows;
  31.     bit = bit_table[ymod & 7];
  32.     ptr += ymod >> 3;
  33.     bptr = ptr + colors[0];
  34.     yptr = ptr + colors[1];
  35.     mptr = ptr + colors[2];
  36.     cptr = ptr + colors[3];
  37.  
  38.     /* pre-compute threshold; are we thresholding? */
  39.     if (threshold = PInfo->pi_threshold) { /* thresholding */
  40.         dvalue = threshold ^ 15;
  41.         bptr += x3;
  42.         do { /* for all source pixels */
  43.             /* pre-compute intensity values for each component */
  44.             Black = ColorInt->colorByte[PCMBLACK];
  45.             ColorInt++;
  46.  
  47.             sx = *sxptr++;
  48.  
  49.             do { /* use this pixel 'sx' times */
  50.                 if (Black > dvalue) {
  51.                     *bptr |= bit;
  52.                 }
  53.                 bptr += 3;
  54.             } while (--sx);
  55.         } while (--width);
  56.     }
  57.     else { /* not thresholding, pre-compute ptr to dither matrix */
  58.         dmatrix = PInfo->pi_dmatrix + ((y & 3) << 2);
  59.         if (PD->pd_Preferences.PrintShade == SHADE_GREYSCALE) { 
  60.             bptr += x3;
  61.             do { /* for all source pixels */
  62.                 /* compute intensity val for each component */
  63.                 Black = ColorInt->colorByte[PCMBLACK];
  64.                 ColorInt++;
  65.  
  66.                 sx = *sxptr++;
  67.  
  68.                 do { /* use this pixel 'sx' times */
  69.                     if (Black > dmatrix[x & 3]) {
  70.                         *bptr |= bit;
  71.                     }
  72.                     x++; /* done 1 more printer pixel */
  73.                     bptr += 3;
  74.                 } while (--sx);
  75.             } while (--width);
  76.         }
  77.         else { /* color */
  78.             do { /* for all source pixels */
  79.                 /* compute intensity val for each component */
  80.                 Black = ColorInt->colorByte[PCMBLACK];
  81.                 Yellow = ColorInt->colorByte[PCMYELLOW];
  82.                 Magenta = ColorInt->colorByte[PCMMAGENTA];
  83.                 Cyan = ColorInt->colorByte[PCMCYAN];
  84.                 ColorInt++;
  85.  
  86.                 sx = *sxptr++;
  87.  
  88.                 do { /* use this pixel 'sx' times */
  89.                     dvalue = dmatrix[x & 3];
  90.                     if (Black > dvalue) {
  91.                         *(bptr + x3) |= bit;
  92.                     }
  93.                     else  { /* black not rendered */
  94.                         if (Yellow > dvalue) {
  95.                             *(yptr + x3) |= bit;
  96.                         }
  97.                         if (Magenta > dvalue) {
  98.                             *(mptr + x3) |= bit;
  99.                         }
  100.                         if (Cyan > dvalue) {
  101.                             *(cptr + x3) |= bit;
  102.                         }
  103.                     }
  104.                     x++; /* done 1 more printer pixel */
  105.                     x3 += 3;
  106.                 } while (--sx);
  107.             } while (--width);
  108.         }
  109.     }
  110. }
  111.