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

  ViewVC Help
Powered by ViewVC 1.1.5