summaryrefslogtreecommitdiff
path: root/dviware/dvi2pcl/rotatechar.c
blob: 3b57191e783b0d3566e4b73a22bfbc31f64bf2ef (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51

/*
 * Rotate the pixel pattern, stored in pxlbuffer by 90 degrees for landscape
 * printout mode. The rotated pixel pattern starts at the end of the
 * original pixel pattern in pxlbuffer. The pointer to the begin of the
 * rotated pattern is returned by rotatechar()
 */

#include "globals.h"

byte *rotatechar()
{
	int lbit, tbit;
	int width, height, bytes, length;
	int mask;
	byte *pp, *lp, *tp;
	register int i,j;

	width  = c_height;
	height = c_width;
	bytes = (height + 7) / 8;
	length = height*((width + 7)/8);
	if(endofchardata - pxlbuffer + length >= MAXPXLSIZE)
		prerror("Out of memory while rotating character\n");
	lp = endofchardata;
	for(i = 0 ; i < length ; i++)
	*lp++ = 0;
	lp = endofchardata - 1;
	tp = pxlbuffer - 1;
	tbit = 7 - (height -1) % 8;
	for(i = 0 ; i < height; i++) { 
		if(tbit == 8) { 
			tbit = 0; 
			tp--; 
		}
		pp = tp + bytes;
		mask = power[tbit++];
		lp++;
		lbit = 8;
		for(j = 0 ; j < width ; j++) { 
			if(!lbit--) { 
				lbit = 7; 
				lp++; 
			}
			if(*pp & mask)
			*lp |= power[lbit];
			pp += bytes;
		}
	}
	return(endofchardata);
}