home *** CD-ROM | disk | FTP | other *** search
/ Amiga Elysian Archive / AmigaElysianArchive.iso / printer / dvi2pcl.lha / rotatechar.c < prev    next >
C/C++ Source or Header  |  1992-11-25  |  1KB  |  52 lines

  1.  
  2. /*
  3.  * Rotate the pixel pattern, stored in pxlbuffer by 90 degrees for landscape
  4.  * printout mode. The rotated pixel pattern starts at the end of the
  5.  * original pixel pattern in pxlbuffer. The pointer to the begin of the
  6.  * rotated pattern is returned by rotatechar()
  7.  */
  8.  
  9. #include "globals.h"
  10.  
  11. byte *rotatechar()
  12. {
  13.     int lbit, tbit;
  14.     int width, height, bytes, length;
  15.     int mask;
  16.     byte *pp, *lp, *tp;
  17.     register int i,j;
  18.  
  19.     width  = c_height;
  20.     height = c_width;
  21.     bytes = (height + 7) / 8;
  22.     length = height*((width + 7)/8);
  23.     if(endofchardata - pxlbuffer + length >= MAXPXLSIZE)
  24.         prerror("Out of memory while rotating character\n");
  25.     lp = endofchardata;
  26.     for(i = 0 ; i < length ; i++)
  27.     *lp++ = 0;
  28.     lp = endofchardata - 1;
  29.     tp = pxlbuffer - 1;
  30.     tbit = 7 - (height -1) % 8;
  31.     for(i = 0 ; i < height; i++) { 
  32.         if(tbit == 8) { 
  33.             tbit = 0; 
  34.             tp--; 
  35.         }
  36.         pp = tp + bytes;
  37.         mask = power[tbit++];
  38.         lp++;
  39.         lbit = 8;
  40.         for(j = 0 ; j < width ; j++) { 
  41.             if(!lbit--) { 
  42.                 lbit = 7; 
  43.                 lp++; 
  44.             }
  45.             if(*pp & mask)
  46.             *lp |= power[lbit];
  47.             pp += bytes;
  48.         }
  49.     }
  50.     return(endofchardata);
  51. }
  52.