/[opencvs]/eyes/hpgl2.c
ViewVC logotype

Contents of /eyes/hpgl2.c

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.1 - (show annotations)
Tue Apr 16 13:59:15 2013 UTC (6 years, 9 months ago) by hib
Branch: MAIN
CVS Tags: HEAD
File MIME type: text/plain
Added hpgl2 routines and bitmap_to_hpgl2 - this allows
us to use the vector mode to print out 600 dots per inch
on the hp designjet 600.  It is kind of a folloy, but it is a use of what I have versus what I dont have.
I only made a 36 x 1/2 inch strip so far.  This has no scaling defined so it
should be asolute.  the print area is about 3 inches smaller (or more) than the printer size. Also,  the printer margins is not even.  But hey,
it probably works.

Right now I am testing a 2.3 inch long strip which will take 20 minutes to run.
And then there is the question of if the plotter can handle millions
of vector commands - which we just don't know yet.
If it can't then there might be a way to send it in blocks - I guess blocks of 12 million or so because that is the memory size of the plotter I got.

1 /* $Revision$
2
3 $Log$
4
5 */
6
7 #include <stdio.h>
8
9 int curx,cury;
10 int penmode;
11 int penmode_first;
12
13 inline char *point_decode(char *buf,int point) {
14 double point_double;
15 int point_int;
16 int point_ip1;
17 int point_ip2;
18 point_double = ((double)(point)) * 1693.33333333333333333;
19 point_int = point_double;
20 point_ip1 = point_int % 1000;
21 if (point_ip1>=998) {
22 point_int += (1000-point_ip1);
23 point_ip1 = 0;
24 }
25 else if (point_ip1 <=2) {
26 point_int -= point_ip1;
27 point_ip1 = 0;
28 }
29 point_ip2 = point_int / 1000;
30 if (point_ip1) {
31 if (((point_ip1 /10)% 10)==0) {
32 sprintf(buf,"%d.%d",point_ip2,point_ip1/100);
33 }
34 else {
35 sprintf(buf,"%d.%2.2d",point_ip2,point_ip1/10);
36 }
37 }
38 else {
39 sprintf(buf,"%d",point_ip2);
40 }
41 return buf;
42 }
43
44 void hpgl2_init() {
45 /* was int ysize */
46 curx=0;cury=0;
47 penmode=0; /* up */
48 penmode_first=1;
49 char buf[20];
50 //printf("BP;IN;PS%s;SP1;PW0;",point_decode(buf,ysize));
51 printf("BP;IN;SP1;PW0;");
52 /* BP is ??? */
53 /* IN is initialize */
54 /* PS(numberof pixels) - this is skipped because of what it says
55 in http://h20000.www2.hp.com/bc/docs/support/SupportManual/bpl13211/bpl13211.pdf */
56 /* IP (initial pixels) is also skipped so we should be in absolute mode */
57 /* SC (scale) is also skipped - note that plotutils scales everything
58 to 10001 by 10001, which would suck for doing detailed work */
59 /*
60 WU1
61 SP1 - select pen 1
62 TR0
63 LT
64 LA1,4,2,4
65 PW0
66 PA.... plot absolute
67 PD pen down and draw
68 PU pen up
69 note - do not need ;
70 but need semicolon at the very end
71
72 origin is lower left corner
73
74 each plotter unit = 0.025 mm - 0.00098 inces
75 1016 plotter unit = 1 in
76 3.39 plu = 1 dot at 300 dpi
77
78 */
79 }
80
81
82
83
84
85 void hpgl2_point(int x,int y) {
86 /* extend the PD to be a line if this point is in line with the last one
87 and they are close.
88 Otherwise put the pen up and then down in the right place
89 otherwise just put the pen down
90 */
91 double xd,yd;
92 int xx,yy;
93 int x_part1,x_part2;
94 int y_part1,y_part2;
95 xd=x*169.333333333333333333;
96 yd=y*169.333333333333333333;
97 xx=xd;
98 yy=yd;
99 char bufx[100];
100 char bufy[100];
101 if (penmode) {
102 if ( ((y==cury)&&((x==curx+1)||(x==curx-1)))
103 ||((x==curx)&&((y==cury+1)||(y==cury-1))) ) {
104 if (penmode_first) {
105 printf("%s,%s",point_decode(bufy,y),point_decode(bufx,x));
106 penmode_first=0;
107 }
108 else {
109 printf(",%s,%s",point_decode(bufy,y),point_decode(bufx,x));
110 }
111 }
112 else {
113 printf("PU%s,%sPD",point_decode(bufy,y),point_decode(bufx,x));
114 penmode_first=1;
115 }
116 }
117 else {
118 printf("PD%s,%s",point_decode(bufy,y),point_decode(bufx,x));
119 penmode_first=1;
120 }
121 penmode=1;
122 cury=y;
123 curx=x;
124 }
125
126
127 void hpgl2_finish() {
128 printf("PU;EP;PA0,0;SP0;PG0;\n");
129 penmode=0;
130 cury=0;
131 curx=0;
132 }
133
134

  ViewVC Help
Powered by ViewVC 1.1.26