Codebase list pnm2ppa / f13ae2f
Imported Upstream version 1.12 Didier Raboud 12 years ago
56 changed file(s) with 6340 addition(s) and 3689 deletion(s). Raw diff Collapse all Expand all
152152 pattern bug in calibrate_ppa. repaired the HP820
153153 fix that got broken when the vertical offset was
154154 redefined by 600 dots...
155
156
157
158
159
160
161
162
155 20010829 duncan Change the preprocessor flag __BEOS__ to __NO_SYSLOG__
156 as it is not BeOS specific (it supresses use of the
157 System Log) Added Makefile entries for Solaris, and
158 an INSTALL.SOLARIS file.
159
160 20020211 duncan Cleanup C++-style comments (gives gcc compiler warnings)
161 Small syslog.c/Makefile cleanups for Solaris.
162 Minor documentation updates. Change a confusing
163 syslog message about "unsupported PNM formats" so it is
164 clear that the error was non-PNM input to pnm2ppa.
165 Increase version to pnm2ppa-1.10
166
167 20020224 duncan Reworked cutswath.c and ppa.c so print sweeps
168 are sent separately by ppa_print_page()
169 in cutswath.c to ppa_print_sweep() in ppa.c
170 (until now, they were going in groups of
171 gMaxPass= 4 at a time in color high quality mode)
172 This will now permit improvement of the print sweep
173 pattern, and make the code easier to understand
174 (easier to separate ppa stuff from image stuff)
175 if someone wants to do a gimp-print PPA backend.
176
177
178 20020311 duncan lots more (incremental) reworking of cutswath.c;
179 now it's pretty well modularized, reading the input
180 image constructing the sweep data, constructing
181 the nozzle data, are all done in separate functions
182 now. Also, modified image.c so the
183 the expansion of data to ppm format
184 (three bytes per 8 dots) is not done for
185 pgm or pbm input (unless the -p option which uses
186 colored ink to make black, and disbles the black
187 ink is used). a new global variable gByteCount = 1
188 or 3 distingushes the two types of intermediate data
189 format.
190
191
192 Also still TODO: I finally understood that
193 the striping of black parts of the image when
194 e.g. the gs example file "tiger.ps"is printed in
195 high-quality mode is because the color and black
196 sweeps are not aligned, so sometimes the color prints
197 on top of black, sometimes the color prints
198 underneath black. If both types of ink are to be used
199 at the same place, the simple solution is probably to
200 prevent black sweeps getting ahead of
201 unprinted color in ppaprint_page() in cutswath.c.
202
203 20020526 duncan solved the striping problem; reworked cutswath.c
204 so black ink is never overprinted by color ink.
205
206 20020601 duncan reworked the code that prevents color swaths
207 and black swaths from having vertical_pos that
208 differs by 1, 2 or 3 lines (needed for HP820C).
209 (to go with the new swath-cutting algorithm).
210
211 Added a method for recognising if input is a
212 calibration page produced by calibrate_ppa,
213 as these dont work correctly with the new
214 swath-cutting algorithm. (will restore
215 a "legacy-style" (pnm2ppa-1.04-style) method
216 for printing input that is detected to be
217 calibration pages)
218
219 20020610 duncan added a method for storing info on lines as
220 they are read from the image. (whether they have black,
221 and/or color data, etc.) Helps a lot!
222 final fixes to calibrate_ppa. new code seems to work
223 20020623 duncan added a new command line option --dpi300 that
224 interprets input resolution as 300dpi instead of 600dpi
225 20020930 duncan enable compression of (color) data by default (only
226 compression of black data was previously enabled).
227 added a configuration file keyword "compression"
228 to switch it off, in case there are problems ...
229 (color data compression seems to work on HP722C!)
230 20021005 duncan disable logging of informational syslog messages by
231 default. They can (only) be reenabled by "log_info 1"
232 in the default configuration file /etc/pnm2ppa.conf.
233 (They will still go to stderr in "verbose" mode).
234 20021109 duncan make "version 0" in the config file set the printer
235 type to NOPRINTER, and abort printing if this is not
236 subsequently set to a valid printer model.
11 # Makefile for pnm2ppa
22 #
33
4 INSTALLDIR=/usr/local/bin
5 CONFDIR=/etc
6 MANDIR=/usr/local/man/man1
4 # paths to locations where the pnm2ppa binary, the configuration file,
5 # and the man page should be installed. On some systems (like Solaris)
6 # the install command requires the syntax BINDIR="-f /usr/local/bin".
7 BINDIR="/usr/local/bin"
8 CONFDIR="/etc"
9 MANDIR="/usr/local/man/man1"
710
11 #compiler and linker options:
812 CC=gcc
13 CFLAGS=-Wall -pedantic -O2
14 LDFLAGS=-lm
15
916 INSTALL=install
17 # Install under Linux and other versions with the -b (backup) option
18 # (Comment out next line on systems (*BSD, Solaris..) without this option)
19 INSTALL+= -b
1020
11 # production build
12 CFLAGS=-Wall -pedantic -O2 -g -DNDEBUG
13 LDFLAGS=-lm
1421 OBJS = pnm2ppa.o syslog.o ppa.o image.o dither.o cutswath.o hash_ink.o gamma.o
1522 SRC = pnm2ppa.c syslog.c ppa.c image.c dither.c cutswath.c hash_ink.c gamma.c
1623
17 # production build (beos)
18 #CFLAGS=-Wall -pedantic -O2 -g -DNDEBUG -D__BEOS__
19 #OBJS = pnm2ppa.o syslog.o ppa.o image.o dither.o cutswath.o hash_ink.o gamma.o
20 #SRC = pnm2ppa.c syslog.c ppa.c image.c dither.c cutswath.c hash_ink.c gamma.c
24 # The SysLog call may be absent or incompatible on some systems
25 # (e.g., BeOS,..) or you may not wish to have this feature.
26 # To remove support for writing to the System Log, uncomment the next line:
27 #CFLAGS+= -D__NO_SYSLOG__
2128
22 # debug build
23 #CFLAGS=-Wall -pedantic -g -O2 -DDEBUG=1
24 #LDFLAGS=-lm
25 #-lefence
26 #DOBJS = pnm2ppa.o syslog.o ppa.o image.o cutswath.o debug.o dither.o gamma.o hash_ink.o
27 #OBJS = $(DOBJS)
28 #SRC = pnm2ppa.c syslog.c ppa.c image.c cutswath.c debug.c dither.c gamma.c hash_ink.c
29 # Some systems (e.g. Solaris) may not support the LOG_PERROR option to
30 # open_syslog(). (This copies syslog messages to stderr as well as to
31 # the system log.) In that case, uncomment the next line:
32 #CFLAGS+= -D__NO_LOG_PERROR__
2933
30 # debug build (beos)
31 #CFLAGS=-Wall -pedantic -g -DDEBUG=1 -D__BEOS__
32 #OBJS = pnm2ppa.o ppa.o image.o cutswath.o debug.o dither.o hash_ink.o gamma.o syslog.o
33 #SRC = pnm2ppa.c ppa.c image.c cutswath.c debug.c dither.c hash_ink.c gamma.c syslog.c
34 # For debug builds, uncomment the next three lines to get debug messages:
35 #CFLAGS+= -g -DDEBUG=1
36 #OBJS+= debug.o
37 #SRC+= debug.c
3438
35 # If you have FreeBSD, you need to uncomment the next LDFLAG.
39 # For debugging with "Electric Fence" (if you have it):
40 #LDFLAGS+=-lefence
41
42 # On BeOS the LDFLAGS should not be used.
43 # Uncomment the next line if you are compiling for BeOS:
44 #LDFLAGS=
45
46 # On Mac OS X 10.x, you need to uncomment the next CFLAGS and LDFLAGS lines.
47 # You may also need to install libgnugetopt (there are precompiled
48 # versions for Mac OS X available on the net, or it can be compiled
49 # from source). Don't forget to rename the shared library from
50 # "/usr/local/lib/libgnugetopt.a" to "/usr/local/lib/libgnugetopt.dylib".
51 #CFLAGS=-Wall -no-cpp-precomp -traditional-cpp -pedantic -O2
52 #LDFLAGS=-L/usr/local/lib -lgnugetopt
53
54 # If you have FreeBSD you need to uncomment the next LDFLAGS.
3655 # You may also need to install libgnugetopt from the ports collection.
37 # LDFLAGS+=-L/usr/local/lib -lgnugetopt
56 # (Also, make sure the getopt.h it supplies is appropriately installed.)
57 #LDFLAGS+=-L/usr/local/lib -lgnugetopt
3858
39 # Install under Linux and other versions with the -b (backup) option
40 INSTALL=install -b
41 INSTALLD=install -b -d
59 # If you have Solaris you need to uncomment the next LDFLAG
60 # You will also need to install a library with GNU getopt:
61 # (e.g., libiberty which is available from http://sunfreeware.com)
62 #LDFLAGS+=-L/usr/local/lib -liberty
4263
43 # INSTALL for FreeBSD (doesn't have the -b (backup) option)
44 # XXX FreeBSD users, please tell me what the flag for backup is!
45 #
46 # If you have FreeBSD, uncomment the next line
47 # INSTALL=install
48 # INSTALLD=install -d
49
50 # Language selection. Choose one only.
51
64 # Language selection for messages from pnm2ppa. Choose one only.
5265 LANG=EN
5366 #LANG=CZ
5467 #LANG=ES
5669 #LANG=IT
5770 #LANG=NL
5871
72 #------------------------------------------------------------------
5973 # Normal Users!
6074 #
6175 # Do not edit below this line! No user servicable parts below!
62
76 #--------------------------------------------------------------------
77 INSTALLD=$(INSTALL) -d
6378 CFLAGS+=-DLANG_$(LANG)
6479
6580 default: all
87102 rm -f *.o *~ calibrate_ppa pnm2ppa make_hash_ink gmon.out hash_ink.c
88103
89104
90 install: pnm2ppa calibrate_ppa
91 $(INSTALL) -m 755 pnm2ppa $(INSTALLDIR)
105 install: pnm2ppa calibrate_ppa
106 $(INSTALLD) $(BINDIR)
107 $(INSTALLD) $(CONFDIR)
92108 $(INSTALLD) $(MANDIR)
109 $(INSTALL) -m 755 pnm2ppa $(BINDIR)
93110 $(INSTALL) -m 644 docs/en/pnm2ppa.1 $(MANDIR)
94111 # development only - allows root to edit
95 $(INSTALL) -m 644 pnm2ppa.conf $(CONFDIR)
112 $(INSTALL) -m 644 pnm2ppa.conf $(CONFDIR)
96113 # calibration tool
97 $(INSTALL) -m 755 calibrate_ppa $(INSTALLDIR)
114 $(INSTALL) -m 755 calibrate_ppa $(BINDIR)
98115 # final production - much tighter
99116 # $(INSTALL) -m 444 pnm2ppa.conf $(CONFDIR)
100117 @@echo
101118 @@echo Now, edit /etc/pnm2ppa.conf to choose your printer
102119
103120 uninstall:
104 rm -f $(INSTALLDIR)/pnm2ppa
105 rm -f $(INSTALLDIR)/calibrate_ppa
121 rm -f $(BINDIR)/pnm2ppa
122 rm -f $(BINDIR)/calibrate_ppa
106123 rm -f $(MANDIR)/pnm2ppa.1
107124 rm -f $(CONFDIR)/pnm2ppa.conf
108125
7777
7878 Do NOT install these suid/gid!
7979
80 calibrate.c: This is used to produce various ppmraw format PixMap images
80 calibrate_ppa.c:
81 This is used to produce various ppmraw format PixMap images
8182 used with pnm2ppa for printer calibration. Note: these
8283 PixMaps are LARGE (100MB!!) and should generally be piped
8384 directly to pnm2ppa.
8485
8586 THIS SHOULD USUALLY BE INSTALLED.
8687
87 parse_vlink.c a utility useful in debugging pnm2ppa that can interpret
88 parse_vlink.c
89 a utility useful in debugging pnm2ppa that can interpret
8890 ppa format output instructions to the printer, whether
8991 produced by pnm2ppa, or captured from the Windows9x drivers.
9092 It is in the ppa_protocol subdirectory, and is not compiled
3737 int make_test_pattern ( FILE *, int, char * );
3838
3939
40 //int black_maxlines = 300;
41 int black_maxlines = 128; //put this back to old value for now (duncan)
40 /* int black_maxlines = 300; */
41 int black_maxlines = 128; /*put this back to old value for now (duncan)*/
4242
4343
4444 void
6060 printf (" --clean pattern 2: clean print head. \n");
6161 printf (" --center pattern 3: center paper. \n");
6262 printf (" -s <paper> default papersize (a4, legal, letter = us (default))\n");
63 // printf (" -v <printer> Printer model:710=712=720=722;820;1000 (default:7xx)\n");
63 #if 0
64 printf (" -v <printer> Printer model:710=712=720=722;820;1000 (default:7xx)\n");
65 #endif
6466 printf ("\n");
6567 }
6668
9092 gHeight = LETTERHEIGHT ;
9193
9294
93 // read through the optional arguments before tring to find filenames
95 /* read through the optional arguments before tring to find filenames */
9496
9597 while ((c = getopt_long (argc, argv, "gho:p:s:v:",
9698 long_opts, &opt_index)) != EOF)
99101 switch (c)
100102 {
101103 case 0:
102 // long options
104 /* long options */
103105 switch (opt_index)
104106 {
105107 case 0:
106 // --gamma
108 /* --gamma */
107109 gamma = true;
108110 break;
109111 case 1:
110 // --align
112 /* --align */
111113 gamma = false;
112114 testPattern = 0;
113115 break;
114116 case 2:
115 // --test
117 /* --test */
116118 gamma = false;
117119 testPattern = 1;
118120 break;
119121 case 3:
120 // --clean
122 /* --clean */
121123 gamma = false;
122124 testPattern = 2;
123125 break;
124126 case 4:
125 // --center
127 /* --center */
126128 gamma = false;
127129 testPattern = 3;
128130 break;
129131 case 5:
130 // --help
132 /* --help */
131133 show_usage (*argv);
132134 return 0;
133135 break;
165167 break;
166168
167169 case 'p':
168 // select alternate test pattern
170 /* select alternate test pattern */
169171 gamma = false;
170172 testPattern = atoi( optarg );
171173 break;
172174
173175
174176 case 's':
175 // paper size stuffer
177 /* paper size stuffer */
176178 if (!strncmp (optarg, "us", 2) || !strncmp (optarg, "letter", 6))
177179 {
178180 gWidth = LETTERWIDTH;
195197 exit (0);
196198 }
197199 break;
198
200 #if 0
199201 case 'v':
200 // printer model
202 /* printer model */
201203 if (!strncmp (optarg, "820", 3) || !strncmp (optarg, "1000", 4))
202204 black_maxlines = 128;
203205 else if (!strncmp (optarg, "71", 2) || !strncmp (optarg, "72", 2))
204 // black_maxlines = 300;
205 black_maxlines = 128; //reverted for the moment
206 /* black_maxlines = 300; */
207 black_maxlines = 128; /*reverted for the moment - Duncan */
206208 else
207209 {
208210 fprintf(stderr,"%s: unknown printer model \"%s\"\n",
210212 exit (0);
211213 }
212214 break;
213
215 #endif
216
214217 default:
215218 exit (0);
216219 break;
330333 Height = gHeight;
331334
332335 /* pixel dimensions */
333 // Pwidth = Width ;
334 // Pheight = Height ;
336 #if 0
337 Pwidth = Width ;
338 Pheight = Height ;
339 #endif
335340
336341 /* each color is coded on 2 bits if 1 byte rrggbbxx */
337342
338 fprintf(outFile,"P6\n%d %d\n255\n",Width,Height);
343 fprintf(outFile,"P6\n# pnm2ppa calibration image\n%d %d\n255\n",
344 Width,Height);
339345
340346 for ( line = 0; line < Height ; line += maxlines )
341347 {
367373 case 3:
368374 centering();
369375 break;
370 // case 4:
371 //centering_grid();
372 //break;
373 // case 4:
374 //color_squares();
375 //break;
376 //case 5:
377 // make_vertical_line();
378 //break;
379 //case 6:
380 //make_big_x();
381 //break;
382
376 #if 0
377 case 4:
378 centering_grid();
379 break;
380 case 4:
381 color_squares();
382 break;
383 case 5:
384 make_vertical_line();
385 break;
386 case 6:
387 make_big_x();
388 break;
389 #endif
383390 default:
384391 fprintf(stderr,"%s: unknown test pattern (%d)\n",progname,testPattern);
385392 fprintf(stderr,"test pattern 0 : cartridge alignment (default)\n");
410417 v = ((color_bitmap [x] & mask) >> i);
411418 switch(v)
412419 {
413 case 0x00: // 4 drops of ink
420 case 0x00: /* 4 drops of ink */
414421 v=0x00;
415422 break;
416 case 0x01: // 3 drops of ink
423 case 0x01: /* 3 drops of ink */
417424 v=0x08;
418425 break;
419 case 0x02: // 1 drops of ink
426 case 0x02: /* 1 drops of ink */
420427 v=0x80;
421428 break;
422 case 0x03: // 0 drops of ink
429 case 0x03: /* 0 drops of ink */
423430 v=0xff;
424431 }
425432 putc(v, outFile);
495502 void
496503 color_alignment( void )
497504 {
498 //add for color test, alignment pattern
505 /* add for color test, alignment pattern */
499506 int x,y,t,shear,direction;
500507 int vpos;
501508 int hpos;
507514 hpos=Width/2-2000;
508515 for(y=1;y<20;y++)
509516 {
510 for(x=0;x<100;x++)
517 for(x=0;x<128;x++)
511518 {
512519 setpixel(y*200+hpos,x+vpos,BLACK);
513 setpixel(y*201-10+hpos,x+vpos+100,BLUE);
514 setpixel(y*201-10+1+hpos,x+vpos+100,BLUE);
515 setpixel(y*200+hpos,x+vpos+200,BLACK);
520 setpixel(y*201-10+hpos,x+vpos+128,BLUE);
521 setpixel(y*201-10+1+hpos,x+vpos+128,BLUE);
522 setpixel(y*200+hpos,x+vpos+256,BLACK);
516523 }
517524 if ((y-10) > 0)
518525 sprintf(buf,"+%d",y-10);
519526 else
520527 sprintf(buf,"%d",y-10);
521 setstring(y*200+hpos,vpos+350,buf,5);
522 }
523 setstring(Width/2 -200,vpos+450,"COLOFFSX",7);
528 setstring(y*200+hpos,vpos+400,buf,5);
529 }
530 setstring(Width/2 -200,vpos+500,"COLOFFSX",7);
524531 /* vertical black/color offset pattern */
525532
526533 vpos=1200;
583590 direction = -1; /* this is determined by whether sweep is L2R or R2L */
584591 for(y=1;y<20;y++)
585592 {
586 shear = direction*(y-10);
593 shear = -direction*(y-10);
587594 for(x=0; x < black_maxlines ;x++)
588595 {
589596 setpixel(y*200+hpos,x+vpos+000,BLACK);
614621 void
615622 check_alignment( void )
616623 {
617 // alignment verification pattern
624 /* alignment verification pattern */
618625 int x,y;
619626 int vpos, vpos1, vpos2;
620627 int hpos, hpos1,hpos2;
794801 void
795802 head_cleaning( void )
796803 {
797 // test page for cleaning
804 /* test page for cleaning */
798805 int x,y,a,b,c;
799806 int vpos;
800807 char buf[128];
876883 }
877884 }
878885
879 //grey
886 /*grey*/
880887 vpos=2000;
881888 for (y=100;y<Width-1000;y++)
882889 {
886893 }
887894 }
888895
889 //magenta,yellow,cyan
896 /*magenta,yellow,cyan*/
890897 vpos=2300;
891898 for (y=100;y<Width-1000;y++)
892899 {
897904 setpixel (y,x+vpos+256,CYAN);
898905 }
899906 }
900 //black
907 /*black*/
901908 vpos=2800;
902909 for (y=100;y<Width-1000;y++)
903910 {
982989 color_squares( void )
983990 {
984991 int x,y,z;
985 //color squares (Giorgio) (dont work after modifications 15/03/2000)
986 //seems to use a different color coding scheme ..... 125 possible
987 // color values in a byte ...
992 /* color squares (Giorgio) (dont work after modifications 15/03/2000)
993 seems to use a different color coding scheme ..... 125 possible
994 color values in a byte ... */
988995
989996
990997 z=0;
+2076
-1738
cutswath.c less more
00 /***********************************************************************
11 cutswath.c - function to cut a swath of a PNM file for PPA printers
2 -------------------
2 -------------------
33 begin : Thu Jan 13 2000
4 copyright : (C) 1998-2000 by the pnm2ppa project
4 copyright : (C) 1998-2002 by the pnm2ppa project
55 email :
66 ***************************************************************************/
77
3030
3131 #include "lang.h"
3232
33 int b_left, b_right, b_vpos , b_dir ;
34 int c_left, c_right, c_vpos , c_dir ;
35
36 /* sweep_data->direction must be set already */
33 /* stores information of previous sweeps */
34 int prev_black_vpos , prev_black_dir;
35 int prev_color_vpos , prev_color_dir;
36
37 /* pointers to next sweep that will print, and waiting sweeps */
38 ppaSweepData_t *current_swath, *waiting_color, *waiting_black;
39
40 /* stores info on printable limits of page */
41 ppaPageLimits_t ColorPageLimits;
42 ppaPageLimits_t BlackPageLimits;
43
44 int
45 cut_im_black_swath (image_t *image, ppaPrinter_t *printer,
46 ppaSweepData_t *sweep_data, int last_line);
47 int
48 cut_im_color_swath (image_t *image, ppaPrinter_t *printer,
49 ppaSweepData_t *sweep_data[4]);
50
51 /*
52 Here, we should call cut_im_black_swath and cut_im_color_swath to begin.
53
54 Then, we need to determine which of these swaths comes earlier on the page
55 and print it first. Then we should re-call the appropriate cut_im_*_swath
56 function to refill that buffer and repeat this procedure.
57
58 NEW (Feb 2002) : Finally, the sweep data is sent one sweep at a time to
59 ppa_print_sweep(), where the PPA instructions are produced...
60
61 This will make any further improvements much easier (i.e,
62 staggering the print swaths, in high quality color mode).
63 */
64
65 int
66 ppa_print_page (ppaPrinter_t *printer, image_t *image)
67 {
68 ppaSweepData_t sweeps[6];
69 ppaSweepData_t *prev = NULL, *curblack = NULL, *curcolor = NULL,
70 *color[4] = {NULL, NULL, NULL, NULL},
71 *tmp = NULL, *unused = NULL, *waiting = NULL;
72 int reload[2] = { 1, 1 };
73 int done[2] = { 0, 0 };
74 int found[2] = { 0, 0};
75 int j, k;
76 int last_dir = unknown;
77 int last_line;
78 int color_sweep = 0, color_todo = 0;
79 int color_byte_width, black_byte_width;
80 BOOLEAN NoPrint = gTerminate;
81 BOOLEAN color_done = false;
82 ppaPageLimits_t * black_page_limit = &BlackPageLimits;
83 ppaPageLimits_t * color_page_limit = &ColorPageLimits;
84 /* read the data from the input file */
85
86
87 /* initialize page limits for this document */
88 /*
89 vertical limits are in lines (1 line = 1dot at 600dpi),
90 horizontal limits are in data bytes:
91 1 color data byte = 8 dots at 300dpi,
92 1 black data byte = 8 dots at 600dpi
93 */
94
95 image->left = 0;
96 image->right = 0;
97 image->top = 0;
98 image->bottom = 0;
99 if(printer->left_margin > 0)
100 image->left = printer->left_margin;
101 if(printer->right_margin > 0)
102 image->right = printer->right_margin;
103 if(image->left >= image->width - image->right)
104 NoPrint = true;
105 if(printer->top_margin > 0)
106 image->top = printer->top_margin;
107 if(printer->bottom_margin > 0)
108 image->bottom = printer->bottom_margin;
109 if(image->top >= image->height - image->bottom)
110 NoPrint = true;
111 if(NoPrint)
112 gTerminate = true;
113
114
115
116 /* protect against invalid margin settings configured by users */
117 color_byte_width = (image->width / 2 + 7) / 8;
118 color_page_limit->left = printer->left_margin / 2 / 8;
119 if ( color_page_limit->left < 0 )
120 color_page_limit->left = 0 ;
121 color_page_limit->right = (gWidth - printer->right_margin) / 2 / 8;
122 if ( color_page_limit->right > color_byte_width )
123 color_page_limit->right = color_byte_width ;
124 color_page_limit->bottom = gHeight - printer->bottom_margin ;
125 if ( color_page_limit->bottom > gHeight)
126 color_page_limit->bottom = gHeight ;
127 if ( color_page_limit->bottom < 0 )
128 color_page_limit->bottom = 0;
129 color_page_limit->top = printer->top_margin ;
130 if ( color_page_limit->top < 0 )
131 color_page_limit->top = 0 ;
132 if ( color_page_limit->top > color_page_limit->bottom )
133 color_page_limit->top = color_page_limit->bottom ;
134
135 black_byte_width = (image->width + 7) / 8;
136 black_page_limit->left = printer->left_margin / 8;
137 if ( black_page_limit->left < 0 )
138 black_page_limit->left = 0;
139 black_page_limit->right = ( gWidth - printer->right_margin ) / 8;
140 if (black_page_limit->right > black_byte_width )
141 black_page_limit->right = black_byte_width;
142 black_page_limit->bottom = color_page_limit->bottom;
143 black_page_limit->top = color_page_limit->top;
144
145 /* create an array for storing info about each line on this page */
146
147 if ((image->LineType = malloc (image->height)) == NULL) {
148 snprintf(syslog_message,message_size,"ppa_print_page(): %s",
149 gMessages[E_CS_BADMALLOC]);
150 wrap_syslog (LOG_CRIT,"%s",syslog_message);
151 return 0;
152 }
153 memset(image->LineType, 0x00, image->height);
154
155 /* note: a full-size (all nozzles) color swath is 64 even lines (300dpi);
156 a full-size (all nozzles) black swath is 300 lines (150 even + 150 odd);
157
158 is is necessary to restrict black swath to 128 lines (64 even + 64 odd)
159 on some printer models, when printing in dual inks, color+black ?
160 HP7x0: NO, but there is some artifact at the begining of
161 each black swath that does not immediately follow a black
162 swath. (see the calibrate_ppa --align output....)
163 so leave the setting at 128 in gColorMode for now.
164 (duncan, 2000-10-24)
165 HP820: YES flashes lights ... (maybe it will work if what
166 produces the artifacts on HP7x0 is fixed..?)
167 HP1000: ?
168 */
169
170
171 DPRINTF("ppa_print_page(): begin page\n");
172
173 /* initialize global prev vertical position and direction markers, etc. */
174 prev_color_vpos = color_page_limit->top - 1;
175 prev_black_vpos = black_page_limit->top - 1;
176 prev_black_dir = prev_color_dir = unknown;
177
178 for (k = 0; k < 6; k++) {
179 sweeps[k].direction = unknown;
180 sweeps[k].next = NULL;
181 sweeps[k].image_data = NULL;
182 sweeps[k].nozzle_data = NULL;
183 }
184
185 /* initialize sweep_data pointers */
186 curblack = &sweeps[0];
187 unused = &sweeps[1];
188 for (k = 0; k < gMaxPass; k++)
189 color[k] = &sweeps[k+2];
190
191 /* when the cut_im_*_swath functions are called with
192 the sweep direction = "unknown", they will assign
193 the direction.
194 if gMaxPass is even (i.e. != 1) , the initial
195 value of color[0]->direction is ignored.
196 the cut_im_*swath functions may also override the
197 inital sweep directions in some other cases
198 (e.g., unidirectional printing was requested).
199
200 If gMaxPass is even, half of
201 the gMaxPass color sweeps will be left_to_right,
202 half will be right_to_left. In the present code
203 (gMaxPass = 4) all these sweeps have the same
204 vertical position. ppa_print_page() currently
205 is based on the assumption that if gMaxPass is even.
206 each r2L color sweep has a corresponding l2R sweep with
207 the same vertical_pos. If this changes, it should be
208 reworked.
209 */
210
211 if ( !gColorMode){
212 done[1] = 1;
213 prev_color_vpos = color_page_limit->bottom +1;
214 }
215 DPRINTF ("ppa_print_page: chkpt 1\n");
216
217 while (!done[0] || !done[1]){
218
219
220 /* to be safe, don't ever read beyond end of page */
221 if(image->blackCurLine >= gHeight)
222 done[0] = 1;
223 if(image->colorCurLine >= gHeight)
224 color_done = 1;
225 if(color_done && !color_todo)
226 done[1] = 1;
227
228 /* create a color swath */
229 if (reload[1] && !done[1]){
230 reload[1] = 0;
231 current_swath = prev;
232 waiting_color = NULL;
233 curcolor = NULL;
234 if(curblack->image_data)
235 waiting_black = curblack;
236 else
237 waiting_black = NULL;
238 if (color_todo){
239 color_sweep++;
240 color_todo--;
241 /* attempt to alternate direction */
242 if (!gUnimode && prev ){
243 BOOLEAN switch_dir=false;
244 if ( !waiting ||
245 color[color_sweep]->vertical_pos <= waiting->vertical_pos){
246 if (color[color_sweep]->direction == prev->direction)
247 switch_dir = true;
248 } else if (color[color_sweep]->direction == waiting->direction)
249 switch_dir = true;
250
251 if (switch_dir){
252 for (j=1; j <= color_todo; j++){
253 if (color[color_sweep+j]->vertical_pos >
254 color[color_sweep]->vertical_pos)
255 break;
256 if (color[color_sweep+j]->direction !=
257 color[color_sweep]->direction)
258 {
259 tmp = color[color_sweep];
260 color[color_sweep] = color[color_sweep+j];
261 color[color_sweep+j] = tmp;
262 break;
263 }
264 }
265 }
266 }
267 curcolor = color[color_sweep];
268 DPRINTF("*** loaded color[%d], dir=%d, vpos=%d, todo=%d\n",
269 color_sweep,curcolor->direction,
270 curcolor->vertical_pos, color_todo);
271 #ifdef DEBUG
272 for (k=0; k <= color_todo; k++){
273 DPRINTF(" %p [%d] dir=%d vpos=%d color=%d\n",
274 color[color_sweep+k],k,
275 color[color_sweep+k]->direction,
276 color[color_sweep+k]->vertical_pos,
277 color[color_sweep+k]->in_color);
278 }
279 #endif
280 } else if (!color_done)
281 switch (cut_im_color_swath (image, printer, color)) {
282 case 0:
283 snprintf(syslog_message,message_size, "ppa_print_page(): %s cut_im_color_swath()",
284 gMessages[E_CS_ERROR]);
285 wrap_syslog (LOG_CRIT,"%s",syslog_message);
286 break;
287 return 1;
288 case 1:
289 DPRINTF("ppa_print_page: cut_im_color_swath returned 1\n");
290 color_done = true;
291 prev_color_vpos = color_page_limit->bottom +1;
292 prev_color_dir = unknown;;
293 break;
294 case 2:
295 /* count and sort non-NULL sweeps */
296 color_todo = 0;
297 for (k=0; k < gMaxPass; k++){
298 if (color[k]->image_data)
299 color_todo++;
300 else {
301 for (j=k+1; j < gMaxPass; j++){
302 if (color[j]->image_data){
303 tmp = color[j];
304 color[j] = color[k];
305 color[k] = tmp;
306 break;
307 }
308 }
309 }
310 if (!color[k]->image_data)
311 break;
312 }
313 /* sort by vertical_pos */
314 for (k=0; k < color_todo; k++) {
315 int next = k;
316 for (j = k+1; j < color_todo; j++){
317 if (color[j]->vertical_pos < color[next]->vertical_pos)
318 next = j;
319 }
320 tmp = color[k];
321 color[k] = color[next];
322 color[next] = tmp;
323 }
324 /* attempt to alternate direction */
325 color_sweep = 0;
326 color_todo--;
327 if (!gUnimode && prev ){
328 BOOLEAN switch_dir=false;
329 if ( !waiting ||
330 color[color_sweep]->vertical_pos < waiting->vertical_pos){
331 if (color[color_sweep]->direction == prev->direction)
332 switch_dir = true;
333 }
334 else if (color[color_sweep]->direction == waiting->direction)
335 switch_dir = true;
336
337 if (switch_dir){
338 for (j=1; j <= color_todo; j++){
339 if (color[color_sweep+j]->vertical_pos >
340 color[color_sweep]->vertical_pos)
341 break;
342 if (color[color_sweep+j]->direction !=
343 color[color_sweep]->direction){
344 tmp = color[color_sweep];
345 color[color_sweep] = color[color_sweep+j];
346 color[color_sweep+j] = tmp;
347 break;
348 }
349 }
350 }
351 }
352 curcolor = color[color_sweep];
353 found[1]=1;
354 DPRINTF("*** loaded color[%d], dir=%d, vpos=%d, todo=%d\n",
355 color_sweep,curcolor->direction,
356 curcolor->vertical_pos, color_todo);
357 #ifdef DEBUG
358 for (k=0; k <= color_todo; k++){
359 DPRINTF(" %p [%d] dir=%d vpos=%d color=%d\n",
360 color[color_sweep+k],k,
361 color[color_sweep+k]->direction,
362 color[color_sweep+k]->vertical_pos,
363 color[color_sweep+k]->in_color);
364 }
365 #endif
366 break;
367 case 3:
368 prev_color_dir = unknown;
369 prev_color_vpos = color_page_limit->top - 1;
370 reload[1]=1;
371 found[1]=0;
372 break;
373 default:
374 snprintf(syslog_message,message_size,"ppa_print_page(): %s ",
375 gMessages[E_CS_BADSWITCH]);
376 wrap_syslog (LOG_CRIT,"%s",syslog_message);
377 return 1;
378 }
379 }
380
381
382 /* create a black swath */
383 if (reload[0]){
384 reload[0] = 0;
385 current_swath = prev;
386 waiting_black = NULL;
387 waiting_color = curcolor;
388 if (gColorMode && !color_done)
389 last_line = image->colorCurLine ;
390 else
391 last_line = image->height;
392 switch (cut_im_black_swath (image, printer, curblack, last_line)){
393 case 0:
394 snprintf(syslog_message,message_size,"ppa_print_page(): %s cut_im_black_swath()",
395 gMessages[E_CS_ERROR]);
396 wrap_syslog (LOG_CRIT,"%s",syslog_message);
397 return 1;
398 break;
399 case 1:
400 done[0] = 1;
401 prev_black_vpos = black_page_limit->bottom +1;
402 prev_black_dir = unknown;;
403 break;
404 case 2:
405 found[0]=1;
406 DPRINTF("*** loaded black, dir=%d, vpos=%d\n",
407 curblack->direction, curblack->vertical_pos);
408 #ifdef DEBUG
409 DPRINTF(" %p [B] dir=%d vpos=%d color=%d\n",
410 curblack,
411 curblack->direction,
412 curblack->vertical_pos,
413 curblack->in_color);
414 #endif
415 break;
416 case 3:
417 prev_black_vpos = black_page_limit->top -1;
418 prev_black_dir = unknown;
419 reload[0]=1;
420 found[0]=0;
421 break;
422 default:
423 snprintf(syslog_message,message_size,"ppa_print_page(): %s",
424 gMessages[E_CS_BADSWITCH]);
425 wrap_syslog (LOG_CRIT,"%s",syslog_message);
426 return 1;
427 }
428 }
429
430 if (done[0] && done[1])
431 break;
432
433 /* choose which swath (black or color) should print next */
434 if ( (!done[0] && found[0] &&
435 (color_done || !found[1] ||
436 curblack->vertical_pos < curcolor->vertical_pos)) ) {
437 /* print the current black swath, if it exists and has a
438 vertical_pos that is earlier any current color swath,
439 that exists */
440
441 DPRINTF("ppa_print_page: chkpt 2\n");
442
443 reload[0] = 1;
444 DPRINTF("ppa_print_page: chkpt 3\n");
445 if (prev){
446 prev->next = curblack;
447 if (found[1] && !done[1])
448 waiting = curcolor;
449 else
450 waiting = NULL;
451 #ifdef DEBUG
452 DPRINTF("*** ppa_print_sweep 1, %p, dir=%d (last=%d),"
453 "color=%d, vpos=%d, lines [%d-%d]\n",
454 prev,prev->direction, last_dir,
455 prev->in_color,prev->vertical_pos,
456 prev->first_data_line,prev->last_data_line);
457 #endif
458 if(!NoPrint)
459 ppa_print_sweep (printer, prev);
460 if (!gUnimode && last_dir == prev->direction){
461 DPRINTF("***SWEEP DIRECTION DID NOT CHANGE!!!***\n");
462 }
463 last_dir = prev->direction;
464 free (prev->image_data);
465 free (prev->nozzle_data);
466 prev->image_data = NULL;
467 prev->nozzle_data = NULL;
468 /* move the current sweep into the 'prev' position */
469 tmp = curblack;
470 curblack = prev;
471 prev = tmp;
472 } else {
473 /* move the current sweep into the 'prev' position */
474 prev = curblack;
475 assert (unused);
476 curblack = unused;
477 unused = NULL;
478 }
479 } else if ( (!done[1] && found[1]) ) {
480 /* print the current color swath, if it exists */
481 DPRINTF("ppa_print_page: chkpt 4 \n");
482
483 reload[1] = 1;
484
485 if (prev) {
486 prev->next = curcolor;
487 if (found[0] && !done[0])
488 waiting = curblack;
489 else
490 waiting = NULL;
491 #ifdef DEBUG
492 DPRINTF("*** ppa_print_sweep 2, %p, dir=%d (last=%d),"
493 "color=%d, vpos=%d, lines [%d-%d]\n",
494 prev,prev->direction, last_dir,
495 prev->in_color,prev->vertical_pos,
496 prev->first_data_line,prev->last_data_line);
497 #endif
498 if(!NoPrint)
499 ppa_print_sweep (printer, prev);
500 if (!gUnimode && last_dir == prev->direction){
501 DPRINTF("***SWEEP DIRECTION DID NOT CHANGE!!!***\n");
502 }
503 last_dir = prev->direction;
504 free (prev->image_data);
505 free (prev->nozzle_data);
506 prev->image_data = NULL;
507 prev->nozzle_data = NULL;
508 color[color_sweep] = prev;
509 } else {
510 assert (unused);
511 color[color_sweep] = unused;
512 unused = NULL;
513 }
514 /* move the current sweep into the 'prev' position */
515 prev = curcolor;
516 }
517 if(color_done && !color_todo)
518 done[1] = 1;
519 }
520
521 DPRINTF ("ppa_print_page: chkpt 5\n");
522
523 if (prev) {
524 DPRINTF ("ppa_print_page: chkpt 6 about to clear prev\n");
525
526 prev->next = NULL;
527 #ifdef DEBUG
528 DPRINTF("*** ppa_print_sweep 3, %p, dir=%d (last=%d),"
529 "color=%d, vpos=%d, lines [%d-%d]\n",
530 prev,prev->direction, last_dir,
531 prev->in_color,prev->vertical_pos,
532 prev->first_data_line,prev->last_data_line);
533 #endif
534 if(!NoPrint)
535 ppa_print_sweep (printer, prev);
536 if (!gUnimode && last_dir == prev->direction){
537 DPRINTF("***SWEEP DIRECTION DID NOT CHANGE!!!***\n");
538 }
539 last_dir = prev->direction;
540 free (prev->image_data);
541 free (prev->nozzle_data);
542 prev->image_data = NULL;
543 prev->nozzle_data = NULL;
544 DPRINTF ("ppa_print_page: chkpt 7 cleared prev\n");
545 }
546
547 DPRINTF ("ppa_print_page: chkpt 8 Finish.\n");
548
549 for (k=0; k < gMaxPass; k++)
550 free(image->buffer[k]);
551
552 free(image->LineType);
553 image->LineType = NULL;
554
555 return 0;
556 }
557
558 /* cutswath functions */
559
560 unsigned char *
561 l2r_black_sweep(unsigned char *place, unsigned char *data,
562 int data_width, ppaSwathLimits_t * swath_limits);
563 unsigned char *
564 r2l_black_sweep(unsigned char *place, unsigned char *data,
565 int data_width, ppaSwathLimits_t * swath_limits);
566 unsigned char *
567 l2r_color_sweep(unsigned char *place, unsigned char *data,
568 int data_width, ppaSwathLimits_t * swath_limits);
569 unsigned char *
570 r2l_color_sweep(unsigned char *place, unsigned char *data,
571 int data_width, ppaSwathLimits_t * swath_limits);
572
573 int
574 black_nozzle_data(ppaSweepData_t * sweep_data, int numlines, int margin_diff);
575
576 int
577 color_nozzle_data(ppaSweepData_t * sweep_data, int numlines);
578
579 int
580 read_black_image( unsigned char *data[], image_t *image,
581 ppaPrinter_t *printer, int byte_width,
582 int vpos_shift, int maxlines,
583 ppaSwathLimits_t *swath_limits,
584 int last_line);
585
586 int
587 read_color_image( unsigned char *data[], image_t *image,
588 ppaPrinter_t *printer, int byte_width,
589 int vpos_shift, int maxlines,
590 ppaSwathLimits_t *swath_limits);
591
37592
38593 /* Upon successful completion, sweep_data->image_data and
39594 sweep_data->nozzle_data have been set to pointers which this routine
40595 malloc()'d. */
41596
42597 /* Upon successful completion, all members of *sweep_data have been set
43 except direction, vertical_pos, and next. */
598 except next. */
44599
45600 /* Returns: 0 if unsuccessful
46601 1 if successful, but with non-printing result (end of page)
49604
50605 int
51606 cut_im_black_swath (image_t *image, ppaPrinter_t *printer,
52 int maxlines, ppaSweepData_t *sweep_data)
607 ppaSweepData_t *sweep_data, int last_line)
53608 {
54 unsigned char *data[4], *ppa, *place, *maxplace;
55 int width8, p_width8;
56 int k, i, j, left, right, numlines;
57 int left_limit , right_limit , bottom_limit, top_limit;
58 int top_vpos , bottom_vpos, sweep_offset;
59 int non_blanklines, pre_blanklines, post_blanklines ;
60 int even_non_blanklines, even_pre_blanklines, even_post_blanklines ;
61 int odd_non_blanklines, odd_pre_blanklines, odd_post_blanklines ;
62 int start_even, start_odd;
63 int vpos_shift=600; /* "vertical position" = line number - vpos_shift */
64 BOOLEAN at_bottom ;
65
66 BOOLEAN got_nonblank;
67 int horzpos, hp2;
68 ppaNozzleData_t nozzles[2];
69
70 /* better have (black) maxlines a multiple of 4;
71 color uses half this number, and that must be even !*/
72
73 assert ( !(maxlines %4));
74
75 /* safeguard against the user freeing these */
76 for (k = 0; k < gMaxPass; k++)
77 {
78 sweep_data->image_data[k] = NULL;
79 }
80 sweep_data->nozzle_data = NULL;
81
82 /* read the data from the input file */
83 width8 = (image->width + 7) / 8;
84 for (k = 0; k < gMaxPass; k++)
85 {
86 if ((data[k] = malloc (width8 * maxlines)) == NULL)
87 {
88 snprintf(syslog_message,message_size,"cut_im_black_swath(): %s",
89 gMessages[E_CS_BADMALLOC]);
90 wrap_syslog (LOG_CRIT,"%s",syslog_message);
609 unsigned char *data[4] = { NULL, NULL, NULL, NULL};
610 unsigned char *ppa, *place, *maxplace;
611 int width, byte_width = (image->width + 7) / 8;
612 int vpos_shift=600; /* "vertical position" = line number - vpos_shift */
613 int horizpos;
614 ppaSwathLimits_t Swath_Limits;
615 ppaSwathLimits_t *swath_limits = &Swath_Limits;
616 int maxlines = 300; /* fixed by design of print head */
617
618 /* return if we are not yet allowed to read next part of
619 black image */
620 if(image->blackCurLine >= last_line)
621 return 3;
622
623 /*
624 if we need to use "legacy" mode for printing Calibration pages
625 produced by calibrate_ppa, set maxlines = 128 as in pnm2ppa-1.04.
626 */
627 if(gCalibrate && gColorMode)
628 maxlines = 128;
629
630
631
632 /* safeguard against the user freeing these */
633 sweep_data->image_data = NULL;
634 sweep_data->nozzle_data = NULL;
635
636
637 if ((data[0] = malloc (byte_width * maxlines)) == NULL) {
638 snprintf(syslog_message,message_size,"cut_im_black_swath(): %s",
639 gMessages[E_CS_BADMALLOC]);
640 wrap_syslog (LOG_CRIT,"%s",syslog_message);
641 return 0;
642 }
643
644 /* read in and analyze image data for a black swath */
645 {
646 int retval = 0;
647 retval = read_black_image( data, image, printer, byte_width,
648 vpos_shift, maxlines, swath_limits, last_line);
649 if(retval != 2) {
650 free (data[0]);
651 return retval;
652 }
653 }
654 /* analysis of the image is now complete */
655
656 /* width of the swath in bytes */
657 /* change sweep params to ensure at least 4 bytes sweep width */
658 swath_limits->right += 3;
659 swath_limits->left-- ;
660
661 /* calculate vertical position */
662 sweep_data->vertical_pos = swath_limits->last_line +
663 swath_limits->post_blanklines;
664 /* subtract that 600 dot adjustment here */
665 sweep_data->vertical_pos -= vpos_shift;
666
667 /* fix sweep direction (right_to_left or left_to_right) */
668 sweep_data->direction = unknown;
669 /* always make left_to_right black sweeps if gUnimode is true */
670 /* also do this to avoid striping in multipass color print */
671 if (gUnimode || (gColorMode && !(gMaxPass %2) && !gCalibrate ))
672 sweep_data->direction = left_to_right;
673 else if (gCalibrate) {
674 /* use legacy direction choosing method from pnm2ppa-1.04 */
675 if (prev_color_dir == unknown &&
676 prev_black_dir == unknown )
677 sweep_data->direction = left_to_right;
678 else if (prev_black_vpos > prev_color_vpos ||
679 prev_color_vpos > sweep_data->vertical_pos ){
680 if (prev_black_dir == left_to_right)
681 sweep_data->direction = right_to_left;
682 else
683 sweep_data->direction = left_to_right;
684 } else {
685 if (prev_color_dir == left_to_right)
686 sweep_data->direction = right_to_left;
687 else
688 sweep_data->direction = left_to_right;
689 }
690 } else {
691 int opposite_dir = unknown;
692 if (current_swath) {
693 if (prev_color_dir != unknown &&
694 prev_color_vpos < sweep_data->vertical_pos
695 && current_swath->vertical_pos <= prev_color_vpos )
696 opposite_dir = prev_color_dir;
697 else
698 opposite_dir = current_swath->direction;
699 } else {
700 if (prev_black_dir != unknown)
701 opposite_dir = prev_black_dir;
702 else
703 opposite_dir = right_to_left;
704 }
705 if (opposite_dir == right_to_left)
706 sweep_data->direction = left_to_right;
707 else if (opposite_dir == left_to_right)
708 sweep_data->direction = right_to_left;
709 }
710
711 assert (sweep_data->direction != unknown);
712
713 sweep_data->in_color = false;
714
715 /*
716 create sweep image_data
717 "width" is horizontal swath width in bytes;
718 will add 12 null bytes on each side of black swath
719 */
720 width = swath_limits->right - swath_limits->left + 24;
721
722 if ((ppa = malloc (width * swath_limits->numlines)) == NULL) {
723 snprintf(syslog_message,message_size,"cut_im_black_swath(): %s",
724 gMessages[E_CS_BADPPAMALLOC]);
725 wrap_syslog (LOG_CRIT,"%s",syslog_message);
726 free (data[0]);
727 return 0;
728 }
729 place = ppa;
730
731 if (sweep_data->direction == right_to_left) /* right-to-left */
732 maxplace = r2l_black_sweep(place, data[0], byte_width,
733 swath_limits);
734 else /* sweep_data->direction == left_to_right */
735 maxplace = l2r_black_sweep(place, data[0], byte_width,
736 swath_limits);
737 sweep_data->image_data = ppa;
738 sweep_data->data_size = maxplace - ppa;
739 sweep_data->first_data_line = swath_limits->first_line;
740 sweep_data->last_data_line = swath_limits->last_line;
741 sweep_data->pre_blanklines = swath_limits->pre_blanklines;
742 sweep_data->post_blanklines = swath_limits->post_blanklines;
743
744 /* done with data */
745 free (data[0]);
746
747 horizpos = swath_limits->left * 8 ;
748 horizpos += (sweep_data->direction == left_to_right) ? 1 : 0;
749 if (sweep_data->direction == right_to_left )
750 horizpos += printer->r2l_bw_offset ;/* correct bidirectional shearing */
751
752 sweep_data->left_margin = horizpos;
753 sweep_data->right_margin = horizpos + printer->marg_diff + width * 8;
754
755
756 if (!black_nozzle_data(sweep_data, swath_limits->numlines, printer->marg_diff )) {
757 DPRINTF("black_nozzle_data: malloc failed");
758 free(sweep_data->image_data);
759 return 0;
760 }
761 prev_black_vpos = sweep_data->vertical_pos;
762 prev_black_dir = sweep_data->direction;
763
764 DPRINTF ("cut_im_black_swath: created swath, return 2\n");
765 return 2;
766 }
767
768 int
769 read_black_image( unsigned char * data[], image_t *image,
770 ppaPrinter_t *printer, int byte_width,
771 int vpos_shift, int maxlines,
772 ppaSwathLimits_t *swath_limits,
773 int last_line)
774 {
775 BOOLEAN got_nonblank = false, after_color = false, ignore_color = false;
776 int i, j;
777 int max_vpos, min_vpos;
778 int left, right;
779 int numlines = 0;
780 BOOLEAN blackline = true;
781 int non_blanklines = 0, pre_blanklines = 0, post_blanklines = 0;
782 ppaPageLimits_t *page_limit = &BlackPageLimits;
783
784 min_vpos = image->blackCurLine - vpos_shift;
785 max_vpos = BlackPageLimits.bottom - vpos_shift;
786
787 /* test to see whether color swaths can be ignored */
788 if(!gColorMode ||
789 !(waiting_color ||
790 (current_swath && current_swath->in_color ) ||
791 image->colorCurLine < ColorPageLimits.bottom ) )
792 ignore_color = true;
793
794 /* eat all lines that are below the lower margin */
795 if (image->blackCurLine >= page_limit->bottom ){
796 while (image->blackCurLine < image->height)
797 if (!im_black_readline (image, data, 0)){
798 snprintf(syslog_message,message_size,"read_black_image(): %s",
799 gMessages[E_CS_BADBOTMARG]);
800 wrap_syslog (LOG_CRIT,"%s",syslog_message);
801
802 return 0;
803 }
804 return 1;
805 }
806
807 left = page_limit->right - 1;
808 right = page_limit->left;
809
810 /* eat all beginning blank lines and then up to maxlines or lower margin */
811
812 while (( image->blackCurLine + pre_blanklines < page_limit->bottom)
813 && (image->blackCurLine < last_line)
814 && (numlines + pre_blanklines + post_blanklines < maxlines)
815 && image->blackCurLine < max_vpos + vpos_shift
816 && (!gColorMode || got_nonblank
817 || ((image->buflines < MAXBUFFLINES)
818 || (image->buftype == bitmap)))) {
819 if (!im_black_readline (image, data, byte_width * numlines)) {
820 snprintf(syslog_message,message_size,"read_black_image(): %s",
821 gMessages[E_CS_BADNEXTLINE]);
822 wrap_syslog (LOG_CRIT,"%s",syslog_message);
823 return 0;
824 }
825 blackline = image->LineType[image->blackCurLine - 1] & BLACKLINE;
826 if (!got_nonblank) {
827 if (blackline){
828 for (i = page_limit->left ; i < page_limit->right; i++) {
829 if (data[0][i]){
830 left = i;
831 got_nonblank = true;
832 right = i;
833 for (j = page_limit->right - 1; j > left ; j--){
834 if (data[0][j]){
835 right = j;
836 break;
837 }
838 }
839 break;
840 }
841 }
842 }
843 if(got_nonblank) {
844 /* begin a new swath;, nonblank pixels occur in
845 * bytes "left" through "right", inclusive,
846 * where
847 * page_limit->left <= left <= right < page_limit->right.
848 * This range will be expanded if necessary
849 * as the swath is constructed
850 */
851 DPRINTF("read_black_image: begin swath, line %d\n",
852 image->blackCurLine ) ;
853
854 numlines = 1;
855 non_blanklines = 1;
856 swath_limits->first_line = image->blackCurLine;
857 min_vpos = image->blackCurLine - vpos_shift;
858 max_vpos = min_vpos + maxlines - 1 ;
859
860 /*
861 fix to avoid flashing lights on HP820C:
862 Empirical observation shows that on HP820C,
863 a new swath cannot have a vertical_position that differs from
864 the previous swath that was printed by 1, 2 or 3 lines.
865 This problem does not occur on HP71x/72xC.
866 */
867 if(current_swath && min_vpos < current_swath->vertical_pos + 4)
868 min_vpos = current_swath->vertical_pos + 4;
869
870 if(ignore_color) {
871 if (max_vpos >= BlackPageLimits.bottom - vpos_shift + 20)
872 max_vpos = BlackPageLimits.bottom - vpos_shift + 20;
873 } else if( waiting_color) {
874 if (max_vpos >= waiting_color->vertical_pos
875 && waiting_color->vertical_pos >= min_vpos) {
876 /*
877 design this swath to have the same vertical_pos
878 as the waiting color swath, and print immediately after it.
879 */
880 pre_blanklines = max_vpos - waiting_color->vertical_pos;
881 max_vpos = waiting_color->vertical_pos;
882 min_vpos = max_vpos;
883 after_color = true;
884 } else if (max_vpos < waiting_color->vertical_pos) {
885 /*
886 design this swath to print before the
887 waiting color swath, and to not be overprinted by
888 the waiting color swath.
889 */
890 if (max_vpos > waiting_color->vertical_pos - 4)
891 max_vpos = waiting_color->vertical_pos - 4;
892 assert (max_vpos >= min_vpos);
893 if (last_line > waiting_color->first_data_line - 1 )
894 last_line = waiting_color->first_data_line - 1;
895
896 if(max_vpos + vpos_shift + 1 - maxlines <
897 swath_limits->first_line) {
898 pre_blanklines = maxlines + swath_limits->first_line
899 - max_vpos - vpos_shift - 1;
900 }
901 } else if (waiting_color->vertical_pos < min_vpos) {
902 /*
903 design this swath to print with vpos
904 at least 4 greater than that of the waiting color swath.
905 */
906 if (min_vpos < waiting_color->vertical_pos + 4)
907 min_vpos = waiting_color->vertical_pos + 4;
908 assert (max_vpos >= min_vpos);
909 }
910 }
911 }
912 } else {
913 int newleft = left, newright = right;
914 if (blackline) {
915 /* find left-most nonblank */
916 for (i = page_limit->left ; i < left; i++){
917 if (data[0][byte_width * numlines + i]){
918 newleft = i;
919 break;
920 }
921 }
922 /* find right-most nonblank */
923 for (j = page_limit->right - 1; j > right; j--){
924 if (data[0][byte_width * numlines + j]){
925 newright = j;
926 break;
927 }
928 }
929 }
930 numlines++;
931
932 if (newright < newleft){
933 DPRINTF ("Code error! newleft=%d, newright=%d, left=%d, right=%d\n",
934 newleft, newright, left, right);
935 return 0;
936 }
937
938 /* if the next line might push us over the buffer size, stop here! */
939 /* ignore this test for the 720 right now. Will add better */
940 /* size-guessing for compressed data in the near future! */
941 if (numlines % 2 == 1 && printer->version != HP7X0) {
942 int l = newleft, r = newright, w;
943
944 l--;
945 r += 3;
946 w = r - l;
947
948 if ((w + 24) * numlines > printer->bufsize){
949 numlines--;
950 im_unreadline (image, data[0] + byte_width * numlines);
951 break;
952 } else {
953 left = newleft;
954 right = newright;
955 if (blackline)
956 non_blanklines = numlines;
957 }
958 } else {
959 left = newleft;
960 right = newright;
961 if (blackline)
962 non_blanklines = numlines;
963 }
964 }
965 }
966
967 if ((gColorMode) && (image->buflines >= MAXBUFFLINES)
968 && (image->buftype == color)){
969 DPRINTF ("read_black_image: exceeding buffer size: buflines=%d, MAX=%d\n",
970 image->buflines, MAXBUFFLINES);
971 if ((!got_nonblank)){
972 return 3;
973 }
974 }
975
976 if ((!got_nonblank)) {
977 /* eat all lines that are below the lower margin */
978 if (image->blackCurLine >= page_limit->bottom ){
979 while (image->blackCurLine < image->height)
980 if (!im_black_readline (image, data, 0)){
981 snprintf(syslog_message,message_size,"read_black_image(): %s",
982 gMessages[E_CS_BADBOTMARG]);
983 wrap_syslog (LOG_CRIT,"%s",syslog_message);
984
91985 return 0;
92 }
93 }
94
95 /* prevent weird user settings of the margins
96 * from causing segfaults
97 */
98 left_limit = printer->left_margin / 8;
99 if ( left_limit < 0 )
100 left_limit = 0;
101 right_limit = ( gWidth - printer->right_margin ) / 8;
102 if (right_limit > width8 )
103 right_limit = width8;
104 bottom_limit = gHeight - printer->bottom_margin ;
105 if (bottom_limit > gHeight )
106 bottom_limit = gHeight;
107 if ( bottom_limit < 0 )
108 bottom_limit = 0;
109 top_limit = printer->top_margin ;
110 if ( top_limit < 0 )
111 top_limit = 0 ;
112 if ( top_limit > bottom_limit )
113 top_limit = bottom_limit ;
114
115 /* ignore lines that are above the upper margin */
116 while (image->blackCurLine < top_limit)
117 {
118 if (!im_black_readline (image, data, 0))
119 {
120 snprintf(syslog_message,message_size,"cut_im_black_swath(): %s",
121 gMessages[E_CS_BADTOPMARG]);
122 wrap_syslog (LOG_CRIT,"%s",syslog_message);
123
124 for (k = 0; k < gMaxPass; k++)
125 {
126 free (data[k]);
127 }
128 return 0;
129 }
130 }
131
132 /* eat all lines that are below the lower margin */
133 if (image->blackCurLine >= bottom_limit )
134 {
135 while (image->blackCurLine < image->height)
136 if (!im_black_readline (image, data, 0))
137 {
138 snprintf(syslog_message,message_size,"cut_im_black_swath(): %s",
139 gMessages[E_CS_BADBOTMARG]);
140 wrap_syslog (LOG_CRIT,"%s",syslog_message);
141
142 for (k = 0; k < gMaxPass; k++)
143 {
144 free (data[k]);
145 }
146 return 0;
147 }
148 for (k = 0; k < gMaxPass; k++)
149 {
150 free (data[k]);
151 }
986 }
152987 return 1;
153 }
154
155 left = right_limit - 1;
156 right = left_limit;
157
158 /* eat all beginning blank lines and then up to maxlines or lower margin */
159 got_nonblank = false;
160 numlines = 0;
161 pre_blanklines = 0;
162 post_blanklines = 0;
163 sweep_offset = 0;
164 at_bottom = false ;
165 while (( image->blackCurLine + pre_blanklines < bottom_limit)
166 && ((numlines + pre_blanklines + post_blanklines ) < maxlines)
167 && ((!gColorMode) || got_nonblank
168 || ((image->buflines < MAXBUFFLINES)
169 || (image->buftype == bitmap))))
170 {
171 if (!im_black_readline (image, data, width8 * numlines))
172 {
173 snprintf(syslog_message,message_size,"cut_im_black_swath(): %s",
174 gMessages[E_CS_BADNEXTLINE]);
175 wrap_syslog (LOG_CRIT,"%s",syslog_message);
176 for (k = 0; k < gMaxPass; k++)
177 {
178 free (data[k]);
179 }
180 return 0;
181 }
182 if (!got_nonblank)
183 {
184 for (i = left_limit ; i < right_limit; i++)
185 {
186 if (data[0][i])
187 {
188 left = i;
189 got_nonblank = true;
190 right = i;
191 for (j = right_limit - 1; j > left ; j--)
192 {
193 if (data[0][j])
194 {
195 right = j;
196 break;
197 }
198 }
199 /* begin a new swath;, nonblank pixels occur in
200 * bytes "left" through "right", inclusive,
201 * where
202 * left_limit <= left <= right < right_limit.
203 * This range will be expanded if necessary
204 * as the swath is constructed
205 */
206 DPRINTF("cut_im_black_swath: begin swath, line %d\n",
207 image->blackCurLine ) ;
208
209 /* vertical position of top of swath */
210 top_vpos = image->blackCurLine - vpos_shift ;
211
212 /* predicted vertical position of bottom of swath */
213 bottom_vpos = top_vpos + maxlines - 1 ;
214 if ( bottom_vpos > bottom_limit - vpos_shift)
215 {
216 at_bottom = true;
217 bottom_vpos = bottom_limit - vpos_shift ;
218 /* make sure we are at least 12 dots below the previous
219 black swath vertical position (this is only
220 a possible problem if we are at the bottom limit)*/
221 if ( b_vpos + 12 - bottom_vpos > 0 )
222 {
223 post_blanklines += (b_vpos + 12 - bottom_vpos) ;
224 bottom_vpos += post_blanklines ;
225 }
226 }
227
228 DPRINTF("cut_im_black_swath: shifted bottom_limit=%d, bottom_vpos=%d\n",
229 bottom_limit - vpos_shift , bottom_vpos) ;
230
231 /* sweep_offset is the difference in vertical position
232 of consecutive color and black sweeps.
233 Flashing lights happen on the HP820 if this
234 is -3, -2, -1, 1 , 2 or 3! */
235
236 /* test previous color swath vertical positions */
237 sweep_offset = bottom_vpos - c_vpos ;
238
239 if ( ( sweep_offset >= -4 ) &&
240 ( sweep_offset < 4 ) &&
241 ( sweep_offset != 0 || at_bottom) )
242 {
243 if ( ( at_bottom ) &&
244 ( c_vpos + 5 - sweep_offset < top_vpos + maxlines - 1 ))
245 {
246 /* we are at the bottom margin , and can add post_blanklines*/
247 post_blanklines += 4 - sweep_offset ;
248 }
249 else
250 {
251 /* we are in the middle of the page */
252 if ( ( sweep_offset > 0 ) && ( ! at_bottom ))
253 {
254 /* shift swath upward to have same vpos */
255 pre_blanklines = sweep_offset ;
256 }
257 else
258 {
259 /* shift swath up to have vertical position vpos - 5 */
260 pre_blanklines = 5 + sweep_offset ;
261 }
262 }
263 }
264 /* will add pre_blanklines blank lines at the top of the swath
265 and post_blanklines at the end of the swath. */
266 break;
267 }
268 }
269 }
270 if (got_nonblank)
271 {
272 int newleft = left, newright = right;
273
274 /* find left-most nonblank */
275 for (i = left_limit ; i < left; i++)
276 {
277 if (data[0][width8 * numlines + i])
278 {
279 newleft = i;
280 break;
281 }
282 }
283 /* find right-most nonblank */
284 for (j = right_limit - 1; j > right; j--)
285 {
286 if (data[0][width8 * numlines + j])
287 {
288 newright = j;
289 break;
290 }
291 }
292 numlines++;
293
294 if (newright < newleft)
295 {
296 DPRINTF ("Code error! newleft=%d, newright=%d, left=%d, right=%d\n",
297 newleft, newright, left, right);
298 for (k = 0; k < gMaxPass; k++)
299 {
300 free (data[k]);
301 }
302 return 0;
303 }
304
305 /* if the next line might push us over the buffer size, stop here! */
306 /* ignore this test for the 720 right now. Will add better */
307 /* size-guessing for compressed data in the near future! */
308 if (numlines % 2 == 1 && printer->version != HP7X0)
309 {
310 int l = newleft, r = newright, w;
311
312 l--;
313 r += 3;
314 w = r - l;
315
316 if ((w + 24) * numlines > printer->bufsize)
317 {
318 numlines--;
319 im_unreadline (image, data[0] + width8 * numlines);
320 break;
321 }
322 else
323 {
324 left = newleft;
325 right = newright;
326 }
327 }
328 else
329 {
330 left = newleft;
331 right = newright;
332 }
333 }
334 }
335
336 if ((gColorMode) && (image->buflines >= MAXBUFFLINES)
337 && (image->buftype == color))
338 {
339 DPRINTF ("cut_im_black_swath: exceeding buffer size: buflines=%d, MAX=%d\n",
340 image->buflines, MAXBUFFLINES);
341 if ((!got_nonblank))
342 {
343 for (k = 0; k < gMaxPass; k++)
344 {
345 free (data[k]);
346 }
347 return 3;
348 }
349 }
350
351 if ((!got_nonblank))
352 {
353 /* eat all lines that are below the lower margin */
354 if (image->blackCurLine >= bottom_limit )
355 {
356 while (image->blackCurLine < image->height)
357 if (!im_black_readline (image, data, 0))
358 {
359 snprintf(syslog_message,message_size,"cut_im_black_swath(): %s",
360 gMessages[E_CS_BADBOTMARG]);
361 wrap_syslog (LOG_CRIT,"%s",syslog_message);
362
363 for (k = 0; k < gMaxPass; k++)
364 {
365 free (data[k]);
366 }
367 return 0;
368 }
369 for (k = 0; k < gMaxPass; k++)
370 {
371 free (data[k]);
372 }
373 return 1;
374 }
375 for (k = 0; k < gMaxPass; k++)
376 {
377 free (data[k]);
378 }
379 return 0;
380 /* error, since didn't get to lower margin, yet blank */
381 }
382
383
384 /* calculate vertical position */
385 sweep_data->vertical_pos = image->blackCurLine ;
386
387 /* subtract that 600 dot adjustment here */
388 sweep_data->vertical_pos -= vpos_shift;
389
390 DPRINTF("cut_im_black_swath: end swath, line %d numlines=%d left=%d right=%d\n",
391 image->blackCurLine, numlines, left, right) ;
392 /* width of the swath in bytes */
393
394
395 /* calculate number of blank lines added at top and bottom of swath */
396
397 non_blanklines = numlines ;
398 numlines += pre_blanklines ;
399 if ( (numlines + post_blanklines) % 2 )
400 post_blanklines++ ;
401 numlines += post_blanklines ;
402 assert (maxlines >= numlines );
403 sweep_data->vertical_pos += post_blanklines ;
404
405 even_pre_blanklines = odd_pre_blanklines = pre_blanklines / 2 ;
406 even_non_blanklines = odd_non_blanklines = non_blanklines / 2 ;
407 even_post_blanklines = odd_post_blanklines = post_blanklines / 2 ;
408
988 }
989 if(image->blackCurLine == last_line)
990 return 3;
991 return 0;
992 /* error, since didn't get to lower margin, yet blank */
993 }
994
995 /*
996 remove any blank lines at end of swath;
997 */
998
999 swath_limits->last_line = image->blackCurLine;
1000 swath_limits->last_line += (non_blanklines - numlines);
1001 /* calculate number of blank lines added at top and bottom of swath */
1002 numlines = non_blanklines;
1003
1004 assert (swath_limits->last_line - vpos_shift <= max_vpos);
1005 if (swath_limits->last_line - vpos_shift > min_vpos)
1006 min_vpos = swath_limits->last_line - vpos_shift;
1007 post_blanklines = min_vpos - swath_limits->last_line + vpos_shift;
1008 numlines += post_blanklines;
1009 pre_blanklines = numlines % 2;
1010 numlines += pre_blanklines;
1011
1012
1013 DPRINTF("read_black_image: end swath, line %d numlines=%d= "
1014 " (%d,%d,%d) left=%d right=%d\n",
1015 image->blackCurLine, numlines,
1016 pre_blanklines, non_blanklines, post_blanklines,
1017 left, right) ;
1018
1019
1020 assert(pre_blanklines >= 0
1021 && post_blanklines >= 0
1022 && non_blanklines >= 0
1023 && numlines <= maxlines
1024 && numlines % 2 == 0);
1025
1026 swath_limits->left = left;
1027 swath_limits->right = right;
1028 swath_limits->numlines = numlines;
1029 swath_limits->non_blanklines = non_blanklines;
1030 swath_limits->pre_blanklines = pre_blanklines;
1031 swath_limits->post_blanklines = post_blanklines;
1032
1033 return 2;
1034 }
1035
1036 int
1037 black_nozzle_data(ppaSweepData_t *sweep_data, int numlines, int margin_diff )
1038 {
1039 int i;
1040 ppaNozzleData_t nozzles[2];
1041 for (i = 0; i < 2; i++) {
1042 nozzles[i].DPI = 600;
1043 nozzles[i].pins_used_d2 = numlines / 2;
1044 nozzles[i].unused_pins_p1 = 301 - numlines;
1045 nozzles[i].first_pin = 1;
1046 if (i == 0) {
1047 nozzles[i].left_margin = sweep_data->left_margin + margin_diff;
1048 nozzles[i].right_margin = sweep_data->right_margin;
1049 if (sweep_data->direction == right_to_left)
1050 nozzles[i].nozzle_delay = 0;
1051 else
1052 nozzles[i].nozzle_delay = 6;
1053 } else {
1054 nozzles[i].left_margin = sweep_data->left_margin;
1055 nozzles[i].right_margin = sweep_data->right_margin - margin_diff;
1056 if (sweep_data->direction == right_to_left)
1057 nozzles[i].nozzle_delay = 2;
1058 else
1059 nozzles[i].nozzle_delay = 0;
1060 }
1061 }
1062
1063 sweep_data->nozzle_data_size = 2;
1064 sweep_data->nozzle_data = malloc (sizeof (nozzles));
1065 if (sweep_data->nozzle_data == NULL)
1066 return 0;
1067 memcpy (sweep_data->nozzle_data, nozzles, sizeof (nozzles));
1068 return 2;
1069 }
1070
1071 unsigned char *
1072 r2l_black_sweep(unsigned char *place, unsigned char *data,
1073 int data_width, ppaSwathLimits_t * swath_limits)
1074 {
1075 int i, j , width, evenlines, oddlines;
1076
1077 int left = swath_limits->left;
1078 int right = swath_limits->right;
1079 int non_blanklines = swath_limits->non_blanklines;
1080 int pre_blanklines = swath_limits->pre_blanklines;
1081 int post_blanklines = swath_limits->post_blanklines;
1082 int even_non_blanklines, even_pre_blanklines, even_post_blanklines;
1083 int odd_non_blanklines, odd_pre_blanklines, odd_post_blanklines;
1084 int start_even, start_odd;
1085 ppaPageLimits_t * page_limit = &BlackPageLimits;
1086
1087 #ifdef DEBUG
1088 int data_size = data_width * swath_limits->non_blanklines;
1089 #endif
1090
1091 even_pre_blanklines = odd_pre_blanklines = pre_blanklines / 2 ;
1092 even_non_blanklines = odd_non_blanklines = non_blanklines / 2 ;
1093 even_post_blanklines = odd_post_blanklines = post_blanklines / 2 ;
1094
1095 start_even= 0;
1096 start_odd = 1;
1097
1098 if ( (pre_blanklines %2 == 0) &&
1099 !(non_blanklines % 2 == 0) &&
1100 !(post_blanklines % 2 == 0) ){
1101 even_non_blanklines++ ;
1102 odd_post_blanklines++;
4091103 start_even= 0;
4101104 start_odd = 1;
411
412 if ( (pre_blanklines %2 == 0) &&
413 !(non_blanklines % 2 == 0) &&
414 !(post_blanklines % 2 == 0))
415 {
416 even_non_blanklines++ ;
417 odd_post_blanklines++;
418 start_even= 0;
419 start_odd = 1;
420 }
421 if ( !(pre_blanklines %2 == 0) &&
422 !(non_blanklines % 2 == 0) &&
423 (post_blanklines % 2 == 0))
424 {
1105 }
1106 if ( !(pre_blanklines %2 == 0) &&
1107 !(non_blanklines % 2 == 0) &&
1108 (post_blanklines % 2 == 0)){
4251109 even_pre_blanklines++;
4261110 odd_non_blanklines++;
4271111 start_even= 1;
4281112 start_odd = 0;
429 }
430 if ( !(pre_blanklines %2 == 0) &&
431 (non_blanklines % 2 == 0) &&
432 !(post_blanklines % 2 == 0))
433 {
434 even_pre_blanklines++;
435 odd_post_blanklines++;
436 start_even= 1;
437 start_odd = 0;
438 }
439
1113 }
1114 if ( !(pre_blanklines %2 == 0) &&
1115 (non_blanklines % 2 == 0) &&
1116 !(post_blanklines % 2 == 0)){
1117 even_pre_blanklines++;
1118 odd_post_blanklines++;
1119 start_even= 1;
1120 start_odd = 0;
1121 }
1122
1123 width = right - left ;
1124 evenlines = even_pre_blanklines + even_non_blanklines + even_post_blanklines;
1125 oddlines = odd_pre_blanklines + odd_non_blanklines + odd_post_blanklines;
1126
1127 assert ( oddlines == evenlines );
1128
1129 /* place 0's in the first 12 columns */
1130 memset (place, 0, evenlines * 12);
1131 place += evenlines * 12;
1132
1133 for (i = width + 11; i >= 0; i--) {
1134 int x ;
1135 if (i >= 12){
1136 x = i - 12;
1137 if( left + x < page_limit->left || left + x >= page_limit->right )
1138 {
1139 /* never print data outside the limits */
1140 memset (place, 0, evenlines);
1141 place += evenlines;
1142 } else {
1143 if ( even_pre_blanklines > 0) {
1144 /* first pre_blanklines lines are blank */
1145 memset (place, 0, even_pre_blanklines) ;
1146 place += even_pre_blanklines ;
1147 }
1148 for (j = 0; j < even_non_blanklines; j++) {
1149 int index = ((j * 2) + start_even ) * data_width + left + x;
1150 #ifdef DEBUG
1151 if (!( index < data_size && index >= 0) ){
1152 DPRINTF("index=%d, datasize= %d = %d x %d\n",
1153 index, data_size, data_width, swath_limits->non_blanklines);
1154 }
1155 assert ( index < data_size && index >= 0 );
1156 #endif
1157 *place++ = data[index];
1158 }
1159 if ( even_post_blanklines > 0 ) {
1160 /* last post_blanklines lines are blank */
1161 memset (place, 0, even_post_blanklines) ;
1162 place += even_post_blanklines ;
1163 }
1164 }
1165 } else {
1166 memset (place, 0, evenlines);
1167 place += evenlines;
1168 }
4401169
441 assert (( even_pre_blanklines + odd_pre_blanklines +
442 even_non_blanklines + odd_non_blanklines +
443 even_post_blanklines + odd_post_blanklines ) == numlines );
1170 if (i < width) {
1171 x = i ;
1172 if( left + x < page_limit->left || left + x >= page_limit->right ) {
1173 /* never print data outside the limits */
1174 memset (place, 0, evenlines);
1175 place += evenlines;
1176 } else {
1177 if ( odd_pre_blanklines > 0) {
1178 /* first pre_blanklines lines are blank */
1179 memset (place, 0, odd_pre_blanklines) ;
1180 place += odd_pre_blanklines ;
1181 }
1182 for (j = 0; j < odd_non_blanklines; j++) {
1183 int index = ((j * 2) + start_odd ) * data_width + left + x;
1184 #ifdef DEBUG
1185 if (!( index < data_size && index >= 0) ){
1186 DPRINTF("index=%d, datasize= %d = %d x %d\n",
1187 index, data_size, data_width, swath_limits->non_blanklines);
1188 }
1189 assert ( index < data_size && index >= 0 );
1190 #endif
1191 *place++ = data[index];
1192 }
1193 if ( odd_post_blanklines > 0 ){
1194 /* last post_blanklines lines are blank */
1195 memset (place, 0, odd_post_blanklines) ;
1196 place += odd_post_blanklines ;
1197 }
1198 }
1199 } else {
1200 memset (place, 0, evenlines);
1201 place += evenlines;
1202 }
1203 }
1204 /* place 0's in the last 12 columns */
1205 memset (place, 0, evenlines * 12);
1206 place += evenlines * 12;
1207 return place;
1208 }
1209
1210 unsigned char *
1211 l2r_black_sweep(unsigned char *place, unsigned char *data,
1212 int data_width, ppaSwathLimits_t * swath_limits)
1213 {
1214 int i, j , width, evenlines, oddlines;
1215
1216 int left = swath_limits->left;
1217 int right = swath_limits->right;
1218 int non_blanklines = swath_limits->non_blanklines;
1219 int pre_blanklines = swath_limits->pre_blanklines;
1220 int post_blanklines = swath_limits->post_blanklines;
1221 int even_non_blanklines, even_pre_blanklines, even_post_blanklines;
1222 int odd_non_blanklines, odd_pre_blanklines, odd_post_blanklines;
1223 int start_even, start_odd;
1224 ppaPageLimits_t * page_limit = &BlackPageLimits;
1225
1226 #ifdef DEBUG
1227 int data_size = data_width * swath_limits->non_blanklines;
1228 #endif
1229
1230 even_pre_blanklines = odd_pre_blanklines = pre_blanklines / 2 ;
1231 even_non_blanklines = odd_non_blanklines = non_blanklines / 2 ;
1232 even_post_blanklines = odd_post_blanklines = post_blanklines / 2 ;
1233
1234 start_even= 0;
1235 start_odd = 1;
1236
1237 if ( (pre_blanklines %2 == 0) &&
1238 !(non_blanklines % 2 == 0) &&
1239 !(post_blanklines % 2 == 0)) {
1240 even_non_blanklines++ ;
1241 odd_post_blanklines++;
1242 start_even= 0;
1243 start_odd = 1;
1244 }
1245 if ( !(pre_blanklines %2 == 0) &&
1246 !(non_blanklines % 2 == 0) &&
1247 (post_blanklines % 2 == 0)) {
1248 even_pre_blanklines++;
1249 odd_non_blanklines++;
1250 start_even= 1;
1251 start_odd = 0;
1252 }
1253 if ( !(pre_blanklines %2 == 0) &&
1254 (non_blanklines % 2 == 0) &&
1255 !(post_blanklines % 2 == 0)) {
1256 even_pre_blanklines++;
1257 odd_post_blanklines++;
1258 start_even= 1;
1259 start_odd = 0;
1260 }
1261
1262 width = right - left ;
1263 evenlines = even_pre_blanklines + even_non_blanklines + even_post_blanklines;
1264 oddlines = odd_pre_blanklines + odd_non_blanklines + odd_post_blanklines;
1265
1266 assert ( oddlines == evenlines );
1267
1268 /* place 0's in the first 12 columns */
1269 memset (place, 0, evenlines * 12);
1270 place += evenlines * 12;
1271
1272 for (i = 0; i < width + 12; i++) {
1273 int x;
1274 if (i < width) {
1275 x = i;
1276 if( left + x < page_limit->left || left + x >= page_limit->right ) {
1277 /* never print data outside the limits */
1278 memset (place, 0, evenlines);
1279 place += evenlines;
1280 } else {
1281 if ( odd_pre_blanklines > 0) {
1282 /* first pre_blanklines lines are blank */
1283 memset (place, 0, odd_pre_blanklines) ;
1284 place += odd_pre_blanklines ;
1285 }
1286 for (j = 0; j < odd_non_blanklines; j++){
1287 int index = ((j * 2) + start_odd) * data_width + left + x;
1288 #ifdef DEBUG
1289 if (!( index < data_size && index >= 0) ){
1290 DPRINTF("index=%d, datasize= %d = %d x %d\n",
1291 index, data_size, data_width, swath_limits->non_blanklines);
1292 }
1293 assert ( index < data_size && index >= 0 );
1294 #endif
1295 *place++ = data[index];
1296 }
1297 if ( odd_post_blanklines > 0 ){
1298 /* last post_blanklines lines are blank */
1299 memset (place, 0, odd_post_blanklines) ;
1300 place += odd_post_blanklines ;
1301 }
1302 }
1303 } else {
1304 memset (place, 0, evenlines);
1305 place += evenlines;
1306 }
4441307
445 if (pre_blanklines)
446 {
447 DPRINTF("cut_im_black_swath: offset %d; add pre_blanklines=%d lines\n",
448 sweep_offset, pre_blanklines);
449 }
450 if (post_blanklines)
451 {
452 DPRINTF("cut_im_black_swath: offset %d; add post_blanklines=%d lines\n",
453 sweep_offset, post_blanklines);
454 }
455
456
457 /* change sweep params */
458 /* ensures at least 4 bytes sweep width */
459 right +=3;
460 left-- ;
461 p_width8 = right - left;
462
1308 if (i >= 12){
1309 x = i - 12;
1310 if( left + x < page_limit->left || left + x >= page_limit->right ) {
1311 /* never print data outside the limits */
1312 memset (place, 0, evenlines);
1313 place += evenlines;
1314 } else {
1315 if ( even_pre_blanklines > 0) {
1316 /* first pre_blanklines lines are blank */
1317 memset (place, 0, even_pre_blanklines) ;
1318 place += even_pre_blanklines ;
1319 }
1320 for (j = 0; j < even_non_blanklines; j++) {
1321 int index = ((j * 2) + start_even) * data_width + left + x;
1322 #ifdef DEBUG
1323 if (!( index < data_size && index >= 0) ){
1324 DPRINTF("index=%d, datasize= %d = %d x %d\n",
1325 index, data_size, data_width, swath_limits->non_blanklines);
1326 }
1327 assert ( index < data_size && index >= 0 );
1328 #endif
1329 *place++ = data[index];
1330 }
1331 if ( even_post_blanklines > 0 ){
1332 /* last post_blanklines lines are blank */
1333 memset (place, 0, even_post_blanklines) ;
1334 place += even_post_blanklines ;
1335 }
1336 }
1337 } else {
1338 memset (place, 0, evenlines);
1339 place += evenlines;
1340 }
1341 }
1342 /* place 0's in the last 12 columns */
1343 memset (place, 0, evenlines * 12);
1344 place += evenlines * 12;
1345
1346 return place;
1347 }
1348
1349 int
1350 cut_im_color_swath (image_t *image, ppaPrinter_t *printer,
1351 ppaSweepData_t *sweep_data[4])
1352 {
1353 unsigned char *data[4], *ppa, *place, *maxplace;
1354 int j, k;
1355 int width, byte_width =(image->width / 2 + 7) / 8;
1356 int vpos_shift=600; /* "vertical position" = line number - vpos_shift */
1357 int sweep_dir, sweep_vpos;
1358 int horizpos;
1359 int maxlines = 64; /* fixed by design of print head */
1360 ppaSwathLimits_t Swath_Limits;
1361 ppaSwathLimits_t *swath_limits = &Swath_Limits;
1362 ppaPageLimits_t *page_limit = &ColorPageLimits;
1363
1364 place = NULL;
1365 ppa = NULL;
1366 maxplace = NULL;
1367
1368 /* safeguard against the user freeing these */
1369 for (k = 0; k < gMaxPass; k++) {
1370 sweep_data[k]->nozzle_data = NULL;
1371 sweep_data[k]->image_data = NULL;
1372 }
1373
1374 DPRINTF ("byte_width * 3 * maxlines = %d\n", byte_width * 3 * maxlines);
1375 for (k = 0; k < gMaxPass; k++) {
1376 if ((data[k] = malloc ( byte_width * 3 * maxlines + 8)) == NULL){
1377 snprintf(syslog_message,message_size,"cut_im_color_swath(): %s",
1378 gMessages[E_CS_BADMALLOC]);
1379 wrap_syslog (LOG_CRIT,"%s",syslog_message);
1380 return 0;
1381 }
1382 }
1383 /* read the image data from the input file */
1384 {
1385 int retval;
1386 retval = read_color_image(data, image, printer, byte_width,
1387 vpos_shift, maxlines, swath_limits);
1388 if (retval != 2) {
1389 for (k = 0; k < gMaxPass; k++)
1390 free (data[k]);
1391 return retval;
1392 }
4631393
464 if ((ppa = malloc ((p_width8 + 24) * numlines)) == NULL)
465 {
466 snprintf(syslog_message,message_size,"cut_im_black_swath(): %s",
467 gMessages[E_CS_BADPPAMALLOC]);
1394 }
1395 /* analysis of the image is now complete */
1396
1397 /* now determine vertical position of swath */
1398 sweep_vpos = swath_limits->last_line + 2 * swath_limits->post_blanklines;
1399 sweep_vpos += printer->ColBwOffsY ;
1400 /* subtract that 600 dot adjustment here */
1401 sweep_vpos -= vpos_shift;
1402
1403 /* printing in the leftmost and rightmost bytes of the color
1404 * swath leads to problems, so expand the swath width to avoid
1405 * using these locations. Nothing will ever get printed in these
1406 * expanded ends of the swath. (They are either whitespace,
1407 * or outside the limits, where data is rejected below)
1408 */
1409 swath_limits->left -= 2;
1410 swath_limits->right += 3;
1411 /* enforce a minimum swath width of 8 bytes */
1412 if ( swath_limits->right - swath_limits->left < 8 ) {
1413 if (swath_limits->right > page_limit->left + 8 )
1414 swath_limits->left = swath_limits->right - 8 ;
1415 else
1416 swath_limits->right = swath_limits->left + 8 ;
1417 }
1418
1419 /* fix sweep direction (right_to_left or left_to_right) */
1420 sweep_dir = unknown;
1421 if (gCalibrate && !gUnimode) {
1422 /* legacy pnm2ppa-1.04 method for choosing sweep direction */
1423 if (prev_color_dir == unknown &&
1424 prev_black_dir == unknown )
1425 sweep_dir = left_to_right;
1426 else if ( prev_black_vpos > prev_color_vpos &&
1427 prev_black_vpos < sweep_vpos ) {
1428 if (prev_black_dir == left_to_right)
1429 sweep_dir = right_to_left;
1430 else
1431 sweep_dir = left_to_right;
1432 } else {
1433 if (prev_color_dir == left_to_right)
1434 sweep_dir = right_to_left;
1435 else
1436 sweep_dir = left_to_right;
1437 }
1438 } else if (!gUnimode && gMaxPass % 2){
1439 int opposite_dir = unknown;
1440 /* the correct sweep direction is not yet known, and must be
1441 guessed from sweep_vpos and the previous history
1442 (only for gMaxPass == 1) */
1443
1444 if (current_swath){
1445 if (prev_black_dir != unknown &&
1446 prev_black_vpos < sweep_vpos
1447 && current_swath->vertical_pos < prev_black_vpos )
1448 opposite_dir = prev_black_dir;
1449 else
1450 opposite_dir = current_swath->direction;
1451 } else {
1452 /* must be at beginning of page, when prev is still NULL */
1453 if (prev_black_dir != unknown )
1454 opposite_dir = prev_black_dir;
1455 else /* this is the first time data was found */
1456 opposite_dir= right_to_left;
1457 }
1458 if (opposite_dir == left_to_right)
1459 sweep_dir = right_to_left;
1460 else if (opposite_dir == right_to_left)
1461 sweep_dir = left_to_right;
1462 }
1463
1464 /* create sweep_data for gMaxPass sweeps of the color print head */
1465
1466 for (k = 0; k < gMaxPass; k++) {
1467 sweep_data[k]->direction = sweep_dir;
1468 if(!gUnimode && !(gMaxPass %2 ) && !gCalibrate) {
1469 if( k %2 )
1470 sweep_data[k]->direction = right_to_left;
1471 else
1472 sweep_data[k]->direction = left_to_right;
1473 }
1474 if (gUnimode){
1475 if (gPixmapMode)
1476 sweep_data[k]->direction = left_to_right;
1477 else
1478 sweep_data[k]->direction = right_to_left;
1479 }
1480
1481 assert ( sweep_data[k]->direction != unknown );
1482 sweep_data[k]->vertical_pos = sweep_vpos;
1483 sweep_data[k]->in_color = true;
1484 sweep_data[k]->image_data = NULL;
1485 sweep_data[k]->first_data_line = swath_limits->first_line;
1486 sweep_data[k]->last_data_line = swath_limits->last_line;
1487 sweep_data[k]->pre_blanklines = swath_limits->pre_blanklines;
1488 sweep_data[k]->post_blanklines = swath_limits->post_blanklines;
1489
1490 /* create sweep image_data */
1491 width = swath_limits->right - swath_limits->left + 3;
1492 if ((ppa = malloc ( width * swath_limits->numlines * 3)) == NULL){
1493 snprintf(syslog_message,message_size,"cut_im_color_swath(): %s",
1494 gMessages[E_CS_BADPPAMALLOC]);
1495 wrap_syslog (LOG_CRIT,"%s",syslog_message);
1496
1497 for (j = k ; j < gMaxPass; j++)
1498 free (data[j]); /* free unprocessed data */
1499 for (j = 0; j < k; j++){
1500 free (sweep_data[j]->image_data);
1501 free (sweep_data[j]->nozzle_data);
1502 }
1503 return 0;
1504 }
1505 place = ppa;
1506 if (sweep_data[k]->direction == right_to_left)
1507 maxplace = r2l_color_sweep(place, data[k], byte_width,
1508 swath_limits);
1509 else /* sweep direction is left-to-right */
1510 maxplace = l2r_color_sweep(place, data[k], byte_width,
1511 swath_limits);
1512 free (data[k]); /* finished with data[k] */
1513 sweep_data[k]->image_data = ppa;
1514 sweep_data[k]->data_size = maxplace - ppa;
1515
1516 /*
1517 left and right limits of sweep
1518 (looks like some tweaks have been made!)
1519 */
1520
1521 horizpos = (swath_limits->left - 7 ) * 8 * 2;
1522 horizpos += printer->ColBwOffsX - 600;
1523 horizpos += (sweep_data[k]->direction == left_to_right) ? 2 : 12 ;
1524
1525 /*correct bidirectional shearing*/
1526 if (sweep_data[k]->direction == right_to_left )
1527 horizpos += printer->r2l_col_offset ;
1528
1529 sweep_data[k]->left_margin = horizpos;
1530 sweep_data[k]->right_margin = horizpos + 0x74 + (width - 2 ) * 2 * 8;
1531 /* 0x74 used to be "printer->color_marg_diff" */
1532
1533 DPRINTF("sweep data: left_margin = %d, right margin = %d\n",
1534 sweep_data[k]->left_margin, sweep_data[k]->right_margin);
1535
1536 if (!color_nozzle_data(sweep_data[k], swath_limits->numlines)){
1537 DPRINTF("color_nozzle_data: malloc failed");
1538 for (j=k; j < gMaxPass; j++)
1539 free(data[j]);
1540 for (j=0; j <= k; j++)
1541 free(sweep_data[k]->image_data);
1542 for (j = 0; j < k; j++)
1543 free(sweep_data[j]->nozzle_data);
1544 return 0;
1545 }
1546 prev_color_vpos = sweep_data[k]->vertical_pos;
1547 prev_color_dir = sweep_data[k]->direction;
1548 }
1549 DPRINTF ("cut_im_color_swath: created swath, return 2\n");
1550 return 2;
1551 }
1552
1553
1554 int
1555 read_color_image( unsigned char *data[], image_t *image,
1556 ppaPrinter_t *printer, int byte_width,
1557 int vpos_shift, int maxlines,
1558 ppaSwathLimits_t *swath_limits)
1559 {
1560 int i, j;
1561 int numlines;
1562 int left, right;
1563 int non_blanklines = 0, pre_blanklines = 0, post_blanklines = 0 ;
1564 int min_vpos;
1565 BOOLEAN got_nonblank;
1566 ppaPageLimits_t *page_limit = &ColorPageLimits;
1567 BOOLEAN colorline = true;;
1568
1569 /*
1570 Flashing lights happen on the HP820 if difference of consecutive
1571 vertical_pos of (different ink ?) sweeps
1572 is -3, -2, -1, 1 , 2 or 3!
1573 */
1574
1575 /* are there any circumstances which require that
1576 this swath has the same vertical_pos as current_swath?
1577 assume not, for the moment.
1578 */
1579 min_vpos = image->colorCurLine - vpos_shift + printer->ColBwOffsY;
1580 if (current_swath && !current_swath->in_color ) {
1581 if(min_vpos < current_swath->vertical_pos + 4)
1582 min_vpos = current_swath->vertical_pos + 4;
1583 }
1584 if (waiting_black) {
1585 if(min_vpos < waiting_black->vertical_pos + 4)
1586 min_vpos = waiting_black->vertical_pos + 4;
1587 }
1588
1589
1590 /* eat all lines that are below the lower margin */
1591 if (image->colorCurLine >= page_limit->bottom ) {
1592 while (image->colorCurLine < image->height)
1593 if (!im_color_readline (image, data, 0)){
1594 snprintf(syslog_message,message_size,"read_color_image(): %s",
1595 gMessages[E_CS_BADBOTMARG]);
4681596 wrap_syslog (LOG_CRIT,"%s",syslog_message);
469
470 for (k = 0; k < gMaxPass; k++)
471 {
472 free (data[k]);
1597 return 0;
1598 }
1599 DPRINTF (" read_color_image: return 1 on line %d\n", __LINE__);
1600 return 1;
1601 }
1602
1603
1604 left = page_limit->right - 1;
1605 right = page_limit->left;
1606
1607 got_nonblank = false;
1608 numlines = 0;
1609 pre_blanklines = 0;
1610 post_blanklines = 0;
1611 /* eat all beginning blank lines and then up to maxlines or lower margin */
1612 while (
1613 ( image->colorCurLine + (2* pre_blanklines) < page_limit->bottom ) &&
1614 ( (numlines + pre_blanklines + post_blanklines) < maxlines)
1615 && (got_nonblank ||
1616 ((image->buflines < MAXBUFFLINES) || (image->buftype == color)))){
1617
1618 if (!im_color_readline (image, data, byte_width * 3 * numlines)) {
1619 snprintf(syslog_message,message_size,"read_color_image(): %s",
1620 gMessages[E_CS_BADNEXTLINE]);
1621 wrap_syslog (LOG_CRIT,"%s",syslog_message);
1622 return 0;
1623 }
1624 colorline = image->LineType[image->colorCurLine - 2] & COLORLINE;
1625 if (!got_nonblank){
1626 if (colorline) {
1627 for (i = page_limit->left * 3; i < page_limit->right * 3; i++){
1628 if ((data[gMaxPass - 1][i])){
1629 left = i / 3;
1630 got_nonblank = true;
1631 right = left;
1632 for (j = page_limit->right * 3 - 1; j > left * 3 + 2; j--) {
1633 if ((data[gMaxPass - 1][j])){
1634 right = j / 3;
1635 break;
1636 }
1637 }
1638 break;
4731639 }
474 return 0;
475 }
476
477 place = ppa;
478
479
480 /* always left-to-right if gUnimode is true */
481 if (gUnimode)
482 sweep_data->direction = left_to_right;
483 else if ((b_vpos > c_vpos) || (c_vpos > sweep_data->vertical_pos))
484 {
485 if (b_dir == left_to_right)
486 sweep_data->direction = right_to_left;
487 else
488 sweep_data->direction = left_to_right;
489 } else {
490 if (c_dir == left_to_right)
491 sweep_data->direction = right_to_left;
492 else
493 sweep_data->direction = left_to_right;
494 }
495
496 DPRINTF("cut_im_black_swath: prev b_left %d b_right %d b_vpos %d b_dir %d\n",
497 b_left, b_right, b_vpos, b_dir);
498 DPRINTF("cut_im_black_swath: cur left %d right %d vpos %d dir %d\n",
499 left, right, sweep_data->vertical_pos, sweep_data->direction);
500 b_left = left;
501 b_right = right;
502 b_vpos = sweep_data->vertical_pos;
503 b_dir = sweep_data->direction;
504 DPRINTF("cut_im_black_swath: c_left %d c_right %d c_vpos %d c_dir %d\n",
505 c_left, c_right, c_vpos, c_dir);
506
507 /* place 0's in the first 12 columns */
508 memset (place, 0, numlines / 2 * 12);
509 place += numlines / 2 * 12;
510
511 if (sweep_data->direction == left_to_right)
512 DPRINTF ("black: sweep_data->direction == left_to_right\n");
513 else if (sweep_data->direction == right_to_left)
514 DPRINTF ("black: sweep_data->direction == right_to_left\n");
515 else
516 DPRINTF ("black: sweep_data->direction == *** ERROR: NOT SET! \n");
517
518 if (sweep_data->direction == right_to_left) /* right-to-left */
519 {
520 for (i = p_width8 + 11; i >= 0; i--)
521 {
522 int x ;
523 if (i >= 12 )
524 {
525 x = i - 12;
526 if( left + x < left_limit || left + x >= right_limit )
527 {
528 /* never print data outside the limits */
529 memset (place, 0, numlines / 2);
530 place += numlines / 2;
531 }
532 else
533 {
534 if ( even_pre_blanklines > 0)
535 {
536 /* first pre_blanklines lines are blank */
537 memset (place, 0, even_pre_blanklines) ;
538 place += even_pre_blanklines ;
539 }
540 for (j = 0; j < even_non_blanklines; j++)
541 {
542 *place++ = data[0][((j * 2) + start_even ) * width8 + left + x];
543 }
544 if ( even_post_blanklines > 0 )
545 {
546 /* last post_blanklines lines are blank */
547 memset (place, 0, even_post_blanklines) ;
548 place += even_post_blanklines ;
549 }
550 }
551 }
552 else
553 {
554 memset (place, 0, numlines / 2);
555 place += numlines / 2;
556 }
557
558 if (i < p_width8)
559 {
560 x = i ;
561 if( left + x < left_limit || left + x >= right_limit )
562 {
563 /* never print data outside the limits */
564 memset (place, 0, numlines / 2);
565 place += numlines / 2;
566 }
567 else
568 {
569 if ( odd_pre_blanklines > 0)
570 {
571 /* first pre_blanklines lines are blank */
572 memset (place, 0, odd_pre_blanklines) ;
573 place += odd_pre_blanklines ;
574 }
575 for (j = 0; j < odd_non_blanklines; j++)
576 {
577 *place++ = data[0][((j * 2) + start_odd ) * width8 + left + x];
578 }
579 if ( odd_post_blanklines > 0 )
580 {
581 /* last post_blanklines lines are blank */
582 memset (place, 0, odd_post_blanklines) ;
583 place += odd_post_blanklines ;
584 }
585 }
586 }
587 else
588 {
589 memset (place, 0, numlines / 2);
590 place += numlines / 2;
591 }
1640 }
1641 }
1642 if(got_nonblank) {
1643 /* begin a new swath;, nonblank pixels occur in
1644 * bytes "left" through "right", inclusive,
1645 * where
1646 * page_limit->left <= left <= right < page_limit->right.
1647 * This range will be expanded if necessary
1648 * as the swath is constructed
1649 */
1650 DPRINTF("read_color_image: begin swath, line %d\n",
1651 image->colorCurLine ) ;
1652
1653 numlines = 1;
1654 non_blanklines = 1;
1655 swath_limits->first_line = image->colorCurLine;
1656 /* We assume this is true! */
1657 assert (image->colorCurLine - vpos_shift + printer->ColBwOffsY
1658 + -1 + ( 2 * maxlines) >= min_vpos);
1659 }
1660 } else {
1661 /* find left-most nonblank */
1662 if (colorline) {
1663 for (i = page_limit->left * 3; i < left * 3; i++) {
1664 if ((data[gMaxPass - 1][byte_width * 3 * numlines + i])){
1665 left = i / 3;
1666 break;
5921667 }
593 }
594 else /* sweep_data->direction == left_to_right */
595 {
596 for (i = 0; i < p_width8 + 12; i++)
597 {
598 int x;
599 if (i < p_width8)
600 {
601 x = i;
602 if( left + x < left_limit || left + x >= right_limit )
603 {
604 /* never print data outside the limits */
605 memset (place, 0, numlines / 2);
606 place += numlines / 2;
607 }
608 else
609 {
610 if ( odd_pre_blanklines > 0)
611 {
612 /* first pre_blanklines lines are blank */
613 memset (place, 0, odd_pre_blanklines) ;
614 place += odd_pre_blanklines ;
615 }
616 for (j = 0; j < odd_non_blanklines; j++)
617 {
618 *place++ = data[0][((j * 2) + start_odd) * width8 + left + x];
619 }
620 if ( odd_post_blanklines > 0 )
621 {
622 /* last post_blanklines lines are blank */
623 memset (place, 0, odd_post_blanklines) ;
624 place += odd_post_blanklines ;
625 }
626 }
627 }
628 else
629 {
630 memset (place, 0, numlines / 2);
631 place += numlines / 2;
632 }
633
634 if (i >= 12)
635 {
636 x = i - 12;
637 if( left + x < left_limit || left + x >= right_limit )
638 {
639 /* never print data outside the limits */
640 memset (place, 0, numlines / 2);
641 place += numlines / 2;
642 }
643 else
644 {
645 if ( even_pre_blanklines > 0)
646 {
647 /* first pre_blanklines lines are blank */
648 memset (place, 0, even_pre_blanklines) ;
649 place += even_pre_blanklines ;
650 }
651 for (j = 0; j < even_non_blanklines; j++)
652 {
653 *place++ = data[0][((j * 2) + start_even) * width8 + left + x];
654 }
655 if ( even_post_blanklines > 0 )
656 {
657 /* last post_blanklines lines are blank */
658 memset (place, 0, even_post_blanklines) ;
659 place += even_post_blanklines ;
660 }
661 }
662 }
663 else
664 {
665 memset (place, 0, numlines / 2);
666 place += numlines / 2;
667 }
1668 }
1669 /* find right-most nonblank */
1670 for (j = page_limit->right * 3 - 1 ; j > right * 3 + 2 ; j--){
1671 if ((data[gMaxPass - 1][byte_width * 3 * numlines + j])){
1672 right = j / 3;
1673 break;
6681674 }
669 }
670
671 /* done with data */
672 for (k = 0; k < gMaxPass; k++)
673 {
674 if (data[k] != NULL)
675 {
676 free (data[k]);
677 }
678 }
679
680 /* place 0's in the last 12 columns */
681 memset (place, 0, numlines / 2 * 12);
682 place += numlines / 2 * 12;
683 maxplace = place;
684
685 /* create sweep data */
686 sweep_data->image_data[0] = ppa;
687 sweep_data->data_size = maxplace - ppa;
688 sweep_data->in_color = false;
689
690 horzpos = left * 8 ;
691
692 horzpos += (sweep_data->direction == left_to_right) ? 1 : 0;
693
694 if (sweep_data->direction == right_to_left )
695 horzpos += printer->r2l_bw_offset ;/* correct bidirectional shearing */
696
697 hp2 = horzpos + (p_width8 + 24) * 8;
698
699
700 sweep_data->left_margin = horzpos;
701 sweep_data->right_margin = hp2 + printer->marg_diff;
702
703 for (i = 0; i < 2; i++)
704 {
705 nozzles[i].DPI = 600;
706 nozzles[i].pins_used_d2 = numlines / 2;
707 nozzles[i].unused_pins_p1 = 301 - numlines;
708 nozzles[i].first_pin = 1;
709 if (i == 0)
710 {
711 nozzles[i].left_margin = horzpos + printer->marg_diff;
712 nozzles[i].right_margin = hp2 + printer->marg_diff;
713 if (sweep_data->direction == right_to_left)
714 nozzles[i].nozzle_delay = 0;
715 else
716 nozzles[i].nozzle_delay = 6; //6
717 }
718 else
719 {
720 nozzles[i].left_margin = horzpos;
721 nozzles[i].right_margin = hp2;
722 if (sweep_data->direction == right_to_left)
723 nozzles[i].nozzle_delay = 2;
724 else
725 nozzles[i].nozzle_delay = 0;
726 }
727 }
728
729 sweep_data->nozzle_data_size = 2;
730 sweep_data->nozzle_data = malloc (sizeof (nozzles));
731 if (sweep_data->nozzle_data == NULL)
732 return 0;
733 memcpy (sweep_data->nozzle_data, nozzles, sizeof (nozzles));
734
735 return 2;
1675 }
1676 }
1677 numlines++;
1678 if (colorline)
1679 non_blanklines = numlines;
1680 }
1681 }
1682
1683 if ((image->buflines >= MAXBUFFLINES) && (image->buftype == bitmap)){
1684 DPRINTF
1685 ("read_color_image: exceeding buffer size: image.buflines=%d, MAX=%d\n",
1686 image->buflines, MAXBUFFLINES);
1687 if ((!got_nonblank))
1688 return 3;
1689 }
1690
1691
1692 if ((!got_nonblank)){
1693 /* eat all lines that are below the lower margin */
1694 if (image->colorCurLine >= page_limit->bottom){
1695 while (image->colorCurLine < image->height)
1696 if (!im_color_readline (image, data, 0)){
1697 snprintf(syslog_message,message_size,"read_color_image(): %s",
1698 gMessages[E_CS_BADBOTMARG]);
1699 wrap_syslog (LOG_CRIT,"%s",syslog_message);
1700 return 0;
1701 }
1702 DPRINTF
1703 ("read_color_image: return 1 on line %d; ccl: %d; height: %d\n",
1704 __LINE__, image->colorCurLine, page_limit->bottom );
1705 return 1;
1706 }
1707 return 0;
1708 /* error, since didn't get to lower margin, yet blank */
1709 }
1710
1711 /*
1712 remove any blank lines at end of swath;
1713 */
1714
1715 swath_limits->last_line = image->colorCurLine;
1716 swath_limits->last_line += 2*(non_blanklines - numlines);
1717 numlines = non_blanklines;
1718
1719 post_blanklines = 0;
1720 if(swath_limits->last_line - vpos_shift + printer->ColBwOffsY < min_vpos)
1721 post_blanklines = min_vpos + vpos_shift - printer->ColBwOffsY
1722 - swath_limits->last_line;
1723
1724 numlines += post_blanklines;
1725 pre_blanklines = numlines % 2;
1726 numlines += pre_blanklines;
1727
1728 DPRINTF("read_color_image: end swath, line %d numlines=%d= "
1729 " (%d,%d,%d) left=%d right=%d\n",
1730 image->colorCurLine, numlines,
1731 pre_blanklines, non_blanklines, post_blanklines,
1732 left, right) ;
1733
1734 swath_limits->left = left;
1735 swath_limits->right = right;
1736 swath_limits->numlines = numlines;
1737 swath_limits->non_blanklines = non_blanklines;
1738 swath_limits->pre_blanklines = pre_blanklines;
1739 swath_limits->post_blanklines = post_blanklines;
1740
1741 return 2;
7361742 }
1743
1744 int
1745 color_nozzle_data(ppaSweepData_t * sweep_data, int numlines)
1746 {
1747 int i;
1748 ppaNozzleData_t nozzles[6];
1749
1750 /* create nozzle data for sweep */
1751
1752 for (i = 0; i < 6; i++){
1753 nozzles[i].DPI = 300;
1754 nozzles[i].pins_used_d2 = numlines / 2;
1755 nozzles[i].unused_pins_p1 = 65 - numlines;
1756 nozzles[i].first_pin = 1;
1757 if (i == 0){
1758 nozzles[i].left_margin = sweep_data->left_margin + 0x74;
1759 nozzles[i].right_margin = sweep_data->right_margin;
1760 if (sweep_data->direction == right_to_left)
1761 nozzles[i].nozzle_delay = 0;
1762 else
1763 nozzles[i].nozzle_delay = 0;
1764 }
1765 if (i == 1){
1766 nozzles[i].left_margin = sweep_data->left_margin + 0x64;
1767 nozzles[i].right_margin = sweep_data->right_margin - 0x10;
1768 if (sweep_data->direction == right_to_left)
1769 nozzles[i].nozzle_delay = 0;
1770 else
1771 nozzles[i].nozzle_delay = 0;
1772 }
1773 if (i == 2){
1774 nozzles[i].left_margin = sweep_data->left_margin + 0x3A;
1775 nozzles[i].right_margin = sweep_data->right_margin -0x3A;
1776 if (sweep_data->direction == right_to_left)
1777 nozzles[i].nozzle_delay = 0x0A;
1778 else
1779 nozzles[i].nozzle_delay = 0x0A;
1780 }
1781 if (i == 3){
1782 nozzles[i].left_margin = sweep_data->left_margin + 0x3A;
1783 nozzles[i].right_margin = sweep_data->right_margin - 0x3A;
1784 if (sweep_data->direction == right_to_left)
1785 nozzles[i].nozzle_delay = 0x0A;
1786 else
1787 nozzles[i].nozzle_delay = 0x0A;
1788
1789 }
1790 if (i == 4){
1791 nozzles[i].left_margin = sweep_data->left_margin + 0x10;
1792 nozzles[i].right_margin = sweep_data->right_margin - 0x64;
1793 if (sweep_data->direction == right_to_left)
1794 nozzles[i].nozzle_delay = 0x04;
1795 else
1796 nozzles[i].nozzle_delay = 0x04;
1797
1798 }
1799 if (i == 5){
1800 nozzles[i].left_margin = sweep_data->left_margin;
1801 nozzles[i].right_margin = sweep_data->right_margin - 0x74;
1802 if (sweep_data->direction == right_to_left)
1803 nozzles[i].nozzle_delay = 0x04;
1804 else
1805 nozzles[i].nozzle_delay = 0x04;
1806
1807 }
1808 }
1809
1810 sweep_data->nozzle_data_size = 6;
1811 sweep_data->nozzle_data = malloc (sizeof (nozzles));
1812 if (sweep_data->nozzle_data == NULL)
1813 return 0;
1814 memcpy (sweep_data->nozzle_data, nozzles, sizeof (nozzles));
1815 return 2;
1816 }
1817
1818
1819 #define GET_USABLE(A,i) (!(A[i] & 0x1))
1820 #define GET_COLOR(A,i) ((A[i] >> 1) & 0x3);
1821 #define GET_ODD(A,i) ((A[i] >> 3) & 0x1);
1822 #define GET_X(A,i) ((A[i] >> 4));
7371823
7381824 #define UNUSABLE 1
7391825 #define CYAN (0<<1)
7451831 #define XPOS(x) ((x)<<XSHIFT)
7461832
7471833
1834
7481835 /* number of "special" columns at left of sweep */
7491836 /* different versions for left-to-right and right-to-left sweeps */
7501837 static int Right_size = 42;
7921879 CYAN | ODD | XPOS (7),
7931880 CYAN | EVEN | XPOS (8)
7941881 };
795 static int Right_r2l[] = {
796 UNUSABLE,
797 UNUSABLE,
798 UNUSABLE,
799 CYAN | EVEN | XPOS (0),
800 UNUSABLE,
801 CYAN | EVEN | XPOS (1),
802 CYAN | ODD | XPOS (0),
803 UNUSABLE,
804 UNUSABLE,
805 CYAN | EVEN | XPOS (2),
806 CYAN | ODD | XPOS (1),
807 UNUSABLE,
808 UNUSABLE,
809 CYAN | EVEN | XPOS (3),
810 CYAN | ODD | XPOS (2),
811 MAGENTA | EVEN | XPOS (0),
812 UNUSABLE,
813 CYAN | EVEN | XPOS (4),
814 CYAN | ODD | XPOS (3),
815 UNUSABLE,
816 MAGENTA | EVEN | XPOS (1),
817 MAGENTA | ODD | XPOS (0),
818 CYAN | EVEN | XPOS (5),
819 CYAN | ODD | XPOS (4),
820 UNUSABLE,
821 UNUSABLE,
822 MAGENTA | EVEN | XPOS (2),
823 MAGENTA | ODD | XPOS (1),
824 CYAN | EVEN | XPOS (6),
825 CYAN | ODD | XPOS (5),
826 UNUSABLE,
827 UNUSABLE,
828 MAGENTA | EVEN | XPOS (3),
829 MAGENTA | ODD | XPOS (2),
830 CYAN | EVEN | XPOS (7),
831 CYAN | ODD | XPOS (6),
832 YELLOW | EVEN | XPOS (0),
833 UNUSABLE,
834 MAGENTA | EVEN | XPOS (4),
835 MAGENTA | ODD | XPOS (3),
836 CYAN | EVEN | XPOS (8),
837 CYAN | ODD | XPOS (7)
838 };
1882
8391883
8401884 /* number of "special" columns at left of sweep */
8411885 static int Left_size = 32;
8741918 CYAN | ODD | XPOS (1)
8751919 };
8761920
1921
1922 unsigned char *
1923 l2r_color_sweep(unsigned char *place, unsigned char *data,
1924 int data_width, ppaSwathLimits_t * swath_limits)
1925 {
1926 int i, j , width, evenlines, oddlines;
1927
1928 int left = swath_limits->left;
1929 int right = swath_limits->right;
1930 int non_blanklines = swath_limits->non_blanklines;
1931 int pre_blanklines = swath_limits->pre_blanklines;
1932 int post_blanklines = swath_limits->post_blanklines;
1933 int even_non_blanklines, even_pre_blanklines, even_post_blanklines;
1934 int odd_non_blanklines, odd_pre_blanklines, odd_post_blanklines;
1935 int start_even, start_odd;
1936 ppaPageLimits_t * page_limit = &ColorPageLimits;
1937
1938 #ifdef DEBUG
1939 int data_size = data_width * 3 * swath_limits->non_blanklines;
1940 #endif
1941
1942
1943 even_pre_blanklines = odd_pre_blanklines = pre_blanklines / 2 ;
1944 even_non_blanklines = odd_non_blanklines = non_blanklines / 2 ;
1945 even_post_blanklines = odd_post_blanklines = post_blanklines / 2 ;
1946
1947 start_even= 0;
1948 start_odd = 1;
1949
1950 if ( (pre_blanklines %2 == 0) &&
1951 !(non_blanklines % 2 == 0) &&
1952 !(post_blanklines % 2 == 0)) {
1953 even_non_blanklines++ ;
1954 odd_post_blanklines++;
1955 start_even= 0;
1956 start_odd = 1;
1957 }
1958 if ( !(pre_blanklines %2 == 0) &&
1959 !(non_blanklines % 2 == 0) &&
1960 (post_blanklines % 2 == 0)){
1961 even_pre_blanklines++;
1962 odd_non_blanklines++;
1963 start_even= 1;
1964 start_odd = 0;
1965 }
1966 if ( !(pre_blanklines %2 == 0) &&
1967 (non_blanklines % 2 == 0) &&
1968 !(post_blanklines % 2 == 0)){
1969 even_pre_blanklines++;
1970 odd_post_blanklines++;
1971 start_even= 1;
1972 start_odd = 0;
1973 }
1974
1975 width = right - left ;
1976 evenlines = even_pre_blanklines + even_non_blanklines + even_post_blanklines;
1977 oddlines = odd_pre_blanklines + odd_non_blanklines + odd_post_blanklines;
1978
1979 assert ( oddlines == evenlines );
1980
1981 for (i = 0; i < (width + 1) * 6 ; i++) {
1982 int color, x, odd, y;
1983 j = (width + 1) * 6 - 1 - i ;
1984 if (i < Left_size){
1985 if (!GET_USABLE (Left_l2r, i)){
1986 memset (place, 0x00, evenlines);
1987 place += evenlines;
1988 continue;
1989 }
1990 color = GET_COLOR (Left_l2r, i);
1991 odd = GET_ODD (Left_l2r, i);
1992 x = GET_X (Left_l2r, i);
1993 } else if ( j < Right_size ){
1994 if (!GET_USABLE (Right_l2r, j)){
1995 memset (place, 0x00, evenlines);
1996 place += evenlines;
1997 continue;
1998 }
1999 color = GET_COLOR (Right_l2r, j);
2000 odd = GET_ODD (Right_l2r, j);
2001 x = width -3 - GET_X (Right_l2r,j);
2002 } else {
2003 color = (i / 2 - 15) % 3;
2004 odd = i % 2;
2005 x = (i - 24) / 6 - 1 + odd + (color == 0 ? 0 :/* cyan */
2006 color == 1 ? 4 :/* magenta */
2007 8); /* yellow */
2008 }
2009 if (x + left < page_limit->left || x + left >= page_limit->right) {
2010 /* never print data that is outside the limits */
2011 memset (place, 0x00, evenlines);
2012 place += evenlines;
2013 } else {
2014 int new_pre_blanklines , new_non_blanklines , new_post_blanklines;
2015 int new_start;
2016 if (odd) {
2017 /* odd lines */
2018 new_pre_blanklines = odd_pre_blanklines ;
2019 new_non_blanklines = odd_non_blanklines ;
2020 new_post_blanklines = odd_post_blanklines ;
2021 new_start = start_odd;
2022 } else {
2023 /* even lines */
2024 new_pre_blanklines = even_pre_blanklines ;
2025 new_non_blanklines = even_non_blanklines ;
2026 new_post_blanklines = even_post_blanklines ;
2027 new_start = start_even;
2028 }
2029 if ( new_pre_blanklines > 0 ) {
2030 /* first pre_blanklines lines are blank */
2031 memset (place, 0x00, new_pre_blanklines ) ;
2032 place += new_pre_blanklines ;
2033 }
2034 for (y = 0; y < new_non_blanklines; y++) {
2035 int index = ((y * 2 + new_start) * data_width * 3 +
2036 (x + left ) * 3 + color);
2037 #ifdef DEBUG
2038 if (!( index < data_size && index >= 0) ){
2039 DPRINTF("index=%d, datasize= %d = %d x %d\n",
2040 index, data_size, data_width, swath_limits->non_blanklines);
2041 }
2042 assert ( index < data_size && index >= 0 );
2043 #endif
2044 *place++ = data[index];
2045 }
2046 if ( new_post_blanklines > 0 ){
2047 /* last post_blanklines lines are blank */
2048 memset(place, 0x00, new_post_blanklines) ;
2049 place += new_post_blanklines ;
2050 }
2051 }
2052 }
2053 return place;
2054 }
2055
2056 static int Right_r2l[] = {
2057 UNUSABLE,
2058 UNUSABLE,
2059 UNUSABLE,
2060 CYAN | EVEN | XPOS (0),
2061 UNUSABLE,
2062 CYAN | EVEN | XPOS (1),
2063 CYAN | ODD | XPOS (0),
2064 UNUSABLE,
2065 UNUSABLE,
2066 CYAN | EVEN | XPOS (2),
2067 CYAN | ODD | XPOS (1),
2068 UNUSABLE,
2069 UNUSABLE,
2070 CYAN | EVEN | XPOS (3),
2071 CYAN | ODD | XPOS (2),
2072 MAGENTA | EVEN | XPOS (0),
2073 UNUSABLE,
2074 CYAN | EVEN | XPOS (4),
2075 CYAN | ODD | XPOS (3),
2076 UNUSABLE,
2077 MAGENTA | EVEN | XPOS (1),
2078 MAGENTA | ODD | XPOS (0),
2079 CYAN | EVEN | XPOS (5),
2080 CYAN | ODD | XPOS (4),
2081 UNUSABLE,
2082 UNUSABLE,
2083 MAGENTA | EVEN | XPOS (2),
2084 MAGENTA | ODD | XPOS (1),
2085 CYAN | EVEN | XPOS (6),
2086 CYAN | ODD | XPOS (5),
2087 UNUSABLE,
2088 UNUSABLE,
2089 MAGENTA | EVEN | XPOS (3),
2090 MAGENTA | ODD | XPOS (2),
2091 CYAN | EVEN | XPOS (7),
2092 CYAN | ODD | XPOS (6),
2093 YELLOW | EVEN | XPOS (0),
2094 UNUSABLE,
2095 MAGENTA | EVEN | XPOS (4),
2096 MAGENTA | ODD | XPOS (3),
2097 CYAN | EVEN | XPOS (8),
2098 CYAN | ODD | XPOS (7)
2099 };
2100
2101
8772102 /* the final odd yellow swing buffer doesnt fit in right-to-left
8782103 * color sweeps. Instead of redesigning the structure of the Left of
8792104 * the sweep (If it works, dont fix it ...)
8822107 */
8832108
8842109 static int Left_r2l[] = {
885 UNUSABLE,//YELLOW | ODD | XPOS (0), //this data doesnt fit, what to do?
2110 UNUSABLE,/*YELLOW | ODD | XPOS (0), this data doesnt fit, what to do?*/
8862111 YELLOW | ODD | XPOS (1),
8872112 YELLOW | EVEN | XPOS (0),
8882113 YELLOW | ODD | XPOS (2),
9162141 CYAN | EVEN | XPOS (0)
9172142 };
9182143
919 #define GET_USABLE(A,i) (!(A[i] & 0x1))
920 #define GET_COLOR(A,i) ((A[i] >> 1) & 0x3);
921 #define GET_ODD(A,i) ((A[i] >> 3) & 0x1);
922 #define GET_X(A,i) ((A[i] >> 4));
923
924 int
925 cut_im_color_swath (image_t *image, ppaPrinter_t *printer, int maxlines,
926 ppaSweepData_t *sweep_data)
2144
2145 unsigned char *
2146 r2l_color_sweep(unsigned char *place, unsigned char *data,
2147 int data_width, ppaSwathLimits_t * swath_limits)
9272148 {
928 unsigned char *data[4], *ppa, *place, *maxplace;
929 int width8, p_width8;
930 int k, i, j, left , right, numlines;
931 int left_limit, right_limit, bottom_limit, top_limit ;
932 int top_vpos , bottom_vpos, sweep_offset ;
933 int non_blanklines, pre_blanklines, post_blanklines ;
934 int even_non_blanklines, even_pre_blanklines, even_post_blanklines ;
935 int odd_non_blanklines, odd_pre_blanklines, odd_post_blanklines ;
936 BOOLEAN at_bottom ;
2149 int i, j , width, evenlines, oddlines;
2150
2151 int left = swath_limits->left;
2152 int right = swath_limits->right;
2153 int non_blanklines = swath_limits->non_blanklines;
2154 int pre_blanklines = swath_limits->pre_blanklines;
2155 int post_blanklines = swath_limits->post_blanklines;
2156 int even_non_blanklines, even_pre_blanklines, even_post_blanklines;
2157 int odd_non_blanklines, odd_pre_blanklines, odd_post_blanklines;
9372158 int start_even, start_odd;
938 int vpos_shift=600; /* "vertical position" = line number - vpos_shift */
939
940 BOOLEAN got_nonblank;
941 int horzpos, hp2;
942 ppaNozzleData_t nozzles[6];
943
944 /* maxlines needs to be even */
945 assert( !(maxlines % 2 ));
946
947 place = NULL;
948 ppa = NULL;
949 maxplace = NULL;
950
951 /* safeguard against the user freeing these */
952 for (k = 0; k < gMaxPass; k++) //mocho
953 {
954 sweep_data->image_data[k] = NULL;
955 }
956 sweep_data->nozzle_data = NULL;
957
958 /* read the data from the input file */
959 width8 = (image->width / 2 + 7) / 8;
960 DPRINTF ("width8 * 3 * maxlines = %d\n", width8 * 3 * maxlines);
961 for (k = 0; k < gMaxPass; k++) //mocho
962 {
963 if ((data[k] = malloc (width8 * 3 * maxlines + 8)) == NULL)
964 {
965 snprintf(syslog_message,message_size,"cut_im_color_swath(): %s",
966 gMessages[E_CS_BADMALLOC]);
967 wrap_syslog (LOG_CRIT,"%s",syslog_message);
968 return 0;
969 }
970 }
971
972 /* protect against weird margin settings */
973
974 left_limit = printer->left_margin / 2 / 8;
975 if ( left_limit < 0 )
976 left_limit = 0 ;
977 right_limit = (gWidth - printer->right_margin) / 2 / 8;
978 if ( right_limit > width8 )
979 right_limit = width8 ;
980 bottom_limit = gHeight - printer->bottom_margin ;
981 if ( bottom_limit > gHeight)
982 bottom_limit = gHeight ;
983 if ( bottom_limit < 0 )
984 bottom_limit = 0;
985 top_limit = printer->top_margin ;
986 if ( top_limit < 0 )
987 top_limit = 0 ;
988 if ( top_limit > bottom_limit )
989 top_limit = bottom_limit ;
990
991
992 /* ignore lines that are above the upper margin */
993 while (image->colorCurLine < top_limit )
994 if (!im_color_readline (image, data, 0))
995 {
996 snprintf(syslog_message,message_size,"cut_im_color_swath(): %s",
997 gMessages[E_CS_BADTOPMARG]);
998 wrap_syslog (LOG_CRIT,"%s",syslog_message);
999
1000 for (k = 0; k < gMaxPass; k++) // mocho
1001 {
1002 free (data[k]);
1003 }
1004 return 0;
1005 }
1006
1007 /* eat all lines that are below the lower margin */
1008 if (image->colorCurLine >= bottom_limit )
1009 {
1010 while (image->colorCurLine < image->height)
1011 if (!im_color_readline (image, data, 0))
1012 {
1013 snprintf(syslog_message,message_size,"cut_im_color_swath(): %s",
1014 gMessages[E_CS_BADBOTMARG]);
1015 wrap_syslog (LOG_CRIT,"%s",syslog_message);
1016
1017 for (k = 0; k < gMaxPass; k++)
1018 {
1019 free (data[k]); //mocho
1020 }
1021 return 0;
1022 }
1023 for (k = 0; k < gMaxPass; k++)
1024 {
1025 free (data[k]); //mocho
1026 }
1027 DPRINTF (" cut_im_color_swath: return 1 on line %d\n", __LINE__);
1028 return 1;
1029 }
1030
1031
1032 left = right_limit - 1;
1033 right = left_limit;
1034
1035 got_nonblank = false;
1036 numlines = 0;
1037 pre_blanklines = 0;
1038 post_blanklines = 0;
1039 at_bottom = false ;
1040 sweep_offset = 0;
1041 /* eat all beginning blank lines and then up to maxlines or lower margin */
1042 while (
1043 ( image->colorCurLine + (2* pre_blanklines) < bottom_limit ) &&
1044 ( (numlines + pre_blanklines + post_blanklines) < maxlines)
1045 && (got_nonblank ||
1046 ((image->buflines < MAXBUFFLINES) || (image->buftype == color))))
1047 {
1048 if (!im_color_readline (image, data, width8 * 3 * numlines)) //mocho
1049 {
1050 snprintf(syslog_message,message_size,"cut_im_color_swath(): %s",
1051 gMessages[E_CS_BADNEXTLINE]);
1052 wrap_syslog (LOG_CRIT,"%s",syslog_message);
1053
1054 for (k = 0; k < gMaxPass; k++)
1055 {
1056 free (data[k]); //mocho
1057 }
1058 return 0;
1059 }
1060 if (!got_nonblank)
1061 {
1062 for (i = left_limit * 3; i < right_limit * 3; i++)
1063 {
1064 if ((data[gMaxPass - 1][i]))
1065 {
1066 left = i / 3;
1067 got_nonblank = true;
1068 right = left;
1069 for (j = right_limit * 3 - 1; j > left * 3 + 2; j--)
1070 {
1071 if ((data[gMaxPass - 1][j]))
1072 {
1073 right = j / 3;
1074 break;
1075 }
1076 }
1077 /* begin a new swath;, nonblank pixels occur in
1078 * bytes "left" through "right", inclusive,
1079 * where
1080 * left_limit <= left <= right < right_limit.
1081 * This range will be expanded if necessary
1082 * as the swath is constructed
1083 */
1084 DPRINTF("cut_im_color_swath: begin swath, line %d\n",
1085 image->colorCurLine ) ;
1086
1087 /* vertical position of top of swath */
1088 top_vpos = image->colorCurLine - vpos_shift + printer->ColBwOffsY ;
1089
1090 /* predicted vertical position of bottom of swath */
1091 bottom_vpos = top_vpos + 2* ( maxlines - 1);
1092 if ( bottom_vpos > bottom_limit - vpos_shift + printer->ColBwOffsY )
1093 {
1094 at_bottom = true;
1095 bottom_vpos = bottom_limit - vpos_shift + printer->ColBwOffsY ;
1096 /* make sure we are at least 20 dots below the previous
1097 color swath vertical position (this is only
1098 a possible problem if we are at the bottom limit)*/
1099 if ( ( c_vpos + 21 - bottom_vpos )/2 > 0)
1100 {
1101 post_blanklines += (c_vpos + 21 - bottom_vpos) /2 ;
1102 bottom_vpos += 2 * post_blanklines ;
1103 }
1104 }
1105
1106 DPRINTF("cut_im_color_swath: shifted bottom_limit=%d, bottom_vpos=%d\n",
1107 bottom_limit - vpos_shift, bottom_vpos) ;
1108
1109 /* sweep_offset is the difference in vertical position
1110 of consecutive color and black sweeps.
1111 Flashing lights happen on the HP820 if this
1112 is -3, -2, -1, 1 , 2 or 3! */
1113
1114 /* compare to last black vpos */
1115 sweep_offset = bottom_vpos - b_vpos ;
1116
1117 if ( ( sweep_offset >= -4 ) &&
1118 ( sweep_offset < 4 ) &&
1119 ( (sweep_offset !=0 ) || at_bottom ))
1120 {
1121 if ( (at_bottom) &&
1122 ( b_vpos + 2 * ((5 - sweep_offset ) / 2) < top_vpos + 2 * ( maxlines - 1 ) ) )
1123 {
1124 /* we are at bottom of page, and can add post_blanklines */
1125 post_blanklines += ( 5 - sweep_offset ) /2 ;
1126 }
1127 else
1128 {
1129 /* we are in the middle of the page ;
1130 add pre_blanklines to shift swath end up */
1131 if ( sweep_offset == 3 )
1132 {
1133 /* shift swath upward to vpos - 7 */
1134 pre_blanklines = 5;
1135 }
1136 else if ( sweep_offset == 2 )
1137 {
1138 /* shift swath upward to vpos - 6 */
1139 pre_blanklines = 4;
1140 }
1141 else if ( sweep_offset == 1 )
1142 {
1143 /* shift swath upward to vpos - 7 */
1144 pre_blanklines = 4;
1145 }
1146 else if ( sweep_offset == -1 )
1147 {
1148 /* shift swath upward to vpos -7 */
1149 pre_blanklines = 3;
1150 }
1151 else if ( sweep_offset == -2 )
1152 {
1153 /* shift swath upward to vpos -6 */
1154 pre_blanklines = 2;
1155 }
1156 else if ( sweep_offset == -3 )
1157 {
1158 /* shift swath upward to vpos - 7 */
1159 pre_blanklines = 2;
1160 }
1161 else if ( sweep_offset == -4 )
1162 {
1163 /* shift swath upward to vpos - 6 */
1164 pre_blanklines = 1;
1165 }
1166 }
1167 }
1168 /*will add pre_blanklines blank lines at the top of the swath
1169 and post_blanklines at the end of the swath.
1170 Note that allowance has been made for a possible
1171 extra post_blankline to compensate for odd numlines */
1172 break;
1173 }
1174 }
1175 }
1176
1177 if (got_nonblank)
1178 {
1179 /* find left-most nonblank */
1180 for (i = left_limit * 3; i < left * 3; i++)
1181 {
1182 // fprintf(stderr, "left: %d ", i);
1183 if ((data[gMaxPass - 1][width8 * 3 * numlines + i]))
1184 {
1185 left = i / 3;
1186 break;
1187 }
1188 }
1189 /* find right-most nonblank */
1190 for (j = right_limit * 3 - 1 ; j > right * 3 + 2 ; j--)
1191 {
1192 // fprintf(stderr, "right: %d ", i);
1193 if ((data[gMaxPass - 1][width8 * 3 * numlines + j]))
1194 {
1195 right = j / 3;
1196 break;
1197 }
1198 }
1199 numlines++;
1200 }
1201 }
1202
1203 if ((image->buflines >= MAXBUFFLINES) && (image->buftype == bitmap))
1204 {
1205 DPRINTF
1206 ("cut_im_color_swath: exceeding buffer size: image.buflines=%d, MAX=%d\n",
1207 image->buflines, MAXBUFFLINES);
1208 if ((!got_nonblank))
1209 {
1210 for (k = 0; k < gMaxPass; k++)
1211 free (data[k]);
1212 return 3;
1213 }
1214 }
1215
1216
1217 if ((!got_nonblank))
1218 {
1219 /* eat all lines that are below the lower margin */
1220 if (image->colorCurLine >= bottom_limit)
1221 {
1222 while (image->colorCurLine < image->height)
1223 if (!im_color_readline (image, data, 0))
1224 {
1225 snprintf(syslog_message,message_size,"cut_im_color_swath(): %s",
1226 gMessages[E_CS_BADBOTMARG]);
1227 wrap_syslog (LOG_CRIT,"%s",syslog_message);
1228
1229 for (k = 0; k < gMaxPass; k++)
1230 {
1231 free (data[k]); //mocho
1232 }
1233 return 0;
1234 }
1235 for (k = 0; k < gMaxPass; k++)
1236 {
1237 free (data[k]); //mocho
1238 }
1239 DPRINTF
1240 ("cut_im_color_swath: return 1 on line %d; ccl: %d; height: %d\n",
1241 __LINE__, image->colorCurLine, bottom_limit );
1242 return 1;
1243 }
1244 for (k = 0; k < gMaxPass; k++)
1245 {
1246 free (data[k]); //mocho
1247 }
1248 return 0;
1249 /* error, since didn't get to lower margin, yet blank */
1250 }
1251
1252 sweep_data->vertical_pos = image->colorCurLine + printer->ColBwOffsY ;
1253
1254 /* subtract that 600 dot adjustment here */
1255 sweep_data->vertical_pos -= vpos_shift;
1256
1257 DPRINTF("cut_im_color_swath: end swath, line %d numlines=%d left=%d right=%d\n",
1258 image->colorCurLine, numlines, left, right ) ;
1259
1260
1261
1262 /* calculate number of blank lines added at top and bottom of swath */
1263
1264 non_blanklines = numlines ;
1265 numlines += pre_blanklines ;
1266 if ( (numlines + post_blanklines) % 2 )
1267 post_blanklines++ ;
1268 numlines += post_blanklines ;
1269 assert (maxlines >= numlines );
1270 sweep_data->vertical_pos += 2 * post_blanklines ;
1271
1272
1273 even_pre_blanklines = odd_pre_blanklines = pre_blanklines / 2 ;
1274 even_non_blanklines = odd_non_blanklines = non_blanklines / 2 ;
1275 even_post_blanklines = odd_post_blanklines = post_blanklines / 2 ;
1276
2159 ppaPageLimits_t * page_limit = &ColorPageLimits;
2160
2161 #ifdef DEBUG
2162 int data_size = data_width * 3 * swath_limits->non_blanklines;
2163 #endif
2164
2165
2166 even_pre_blanklines = odd_pre_blanklines = pre_blanklines / 2 ;
2167 even_non_blanklines = odd_non_blanklines = non_blanklines / 2 ;
2168 even_post_blanklines = odd_post_blanklines = post_blanklines / 2 ;
2169
2170 start_even= 0;
2171 start_odd = 1;
2172
2173 if ( (pre_blanklines %2 == 0) &&
2174 !(non_blanklines % 2 == 0) &&
2175 !(post_blanklines % 2 == 0)) {
2176 even_non_blanklines++ ;
2177 odd_post_blanklines++;
12772178 start_even= 0;
12782179 start_odd = 1;
1279
1280 if ( (pre_blanklines %2 == 0) &&
1281 !(non_blanklines % 2 == 0) &&
1282 !(post_blanklines % 2 == 0))
1283 {
1284 even_non_blanklines++ ;
1285 odd_post_blanklines++;
1286 start_even= 0;
1287 start_odd = 1;
1288 }
1289 if ( !(pre_blanklines %2 == 0) &&
1290 !(non_blanklines % 2 == 0) &&
1291 (post_blanklines % 2 == 0))
1292 {
1293 even_pre_blanklines++;
1294 odd_non_blanklines++;
1295 start_even= 1;
1296 start_odd = 0;
1297 }
1298 if ( !(pre_blanklines %2 == 0) &&
1299 (non_blanklines % 2 == 0) &&
1300 !(post_blanklines % 2 == 0))
1301 {
1302 even_pre_blanklines++;
1303 odd_post_blanklines++;
1304 start_even= 1;
1305 start_odd = 0;
1306 }
1307
1308
1309 assert ( numlines % 2 == 0);
1310 assert (( even_pre_blanklines +
1311 even_non_blanklines +
1312 even_post_blanklines ) == numlines/2 );
1313 assert (( odd_pre_blanklines +
1314 odd_non_blanklines +
1315 odd_post_blanklines ) == numlines/2 );
1316
1317
1318 if (pre_blanklines)
1319 {
1320 DPRINTF("cut_im_color_swath: offset %d; add pre_blanklines=%d lines\n",
1321 sweep_offset, pre_blanklines);
1322 }
1323 if (post_blanklines)
1324 {
1325 DPRINTF("cut_im_color_swath: offset %d; add post_blanklines=%d lines\n",
1326 sweep_offset, post_blanklines);
1327 }
1328
1329
1330 /* printing in the leftmost and rightmost bytes of the color
1331 * swath leads to problems, so expand the swath width to avoid
1332 * using these locations. Nothing will ever get printed in these
1333 * expanded ends of the swath. (They are either whitespace,
1334 * or outside the limits, where data is rejected below)
1335 */
1336 left -= 2;
1337 right += 3;
1338 p_width8 = right - left ;
1339
1340 /* enforce a minimum swath width of 8 bytes */
1341 if ( p_width8 < 8 )
1342 {
1343 if (left > left_limit + 8 )
1344 left = left - 8 + p_width8 ;
1345 else
1346 right = right + 8 - p_width8 ;
1347 }
1348 p_width8 = right - left ;
1349
1350 /* always left-to-right if gUnimode is true */
1351 if (gUnimode)
1352 sweep_data->direction = left_to_right;
1353 else if ((b_vpos > c_vpos) && (b_vpos < sweep_data->vertical_pos))
1354 {
1355 if (b_dir == left_to_right)
1356 sweep_data->direction = right_to_left;
1357 else
1358 sweep_data->direction = left_to_right;
1359 } else
1360 {
1361 if (c_dir == left_to_right)
1362 sweep_data->direction = right_to_left;
1363 else
1364 sweep_data->direction = left_to_right;
1365 }
1366
1367 DPRINTF("cut_im_color_swath: b_left %d b_right %d b_vpos %d b_dir %d\n",
1368 b_left, b_right, b_vpos, b_dir);
1369 DPRINTF("cut_im_color_swath: prev c_left %d c_right %d c_vpos %d c_dir %d\n",
1370 c_left, c_right, c_vpos, c_dir);
1371 DPRINTF("cut_im_color_swath: cur left %d right %d vpos %d dir %d\n",
1372 left, right, sweep_data->vertical_pos, sweep_data->direction);
1373 c_left = left;
1374 c_right = right;
1375 c_vpos = sweep_data->vertical_pos;
1376 c_dir = sweep_data->direction;
1377
1378
1379 for (k = 0; k < gMaxPass; k++)
1380 {
1381 if ((ppa = malloc ( (p_width8 + 3 ) * numlines * 3)) == NULL)
1382 {
1383 snprintf(syslog_message,message_size,"cut_im_color_swath(): %s",
1384 gMessages[E_CS_BADPPAMALLOC]);
1385 wrap_syslog (LOG_CRIT,"%s",syslog_message);
1386
1387 for (k = 0; k < gMaxPass; k++)
1388 free (data[k]);
1389 return 0;
1390 }
1391
1392 place = ppa;
1393
1394 if (sweep_data->direction == right_to_left)
1395 {
1396 for (i = (p_width8 + 1) * 6 - 1 ; i >= 0; i--)
1397 {
1398 int color, x, odd, y ;
1399 j = (p_width8 + 1) * 6 - 1 - i ;
1400 if (i < Left_size )
1401 {
1402 if (!GET_USABLE (Left_r2l, i))
1403 {
1404 memset (place, 0x00, numlines / 2);
1405 place += numlines / 2;
1406 continue;
1407 }
1408 odd = GET_ODD (Left_r2l, i );
1409 color = GET_COLOR (Left_r2l, i);
1410 x = GET_X (Left_r2l, i );
1411 }
1412 else if (j < Right_size )
1413 {
1414 if (!GET_USABLE (Right_r2l,j))
1415 {
1416 memset (place, 0x00, numlines / 2);
1417 place += numlines / 2;
1418 continue;
1419 }
1420 color = GET_COLOR (Right_r2l, j);
1421 odd = GET_ODD (Right_r2l, j);
1422 x = p_width8 - 3 - GET_X (Right_r2l, j);
1423 }
1424 else
1425 {
1426 color = (i / 2 - 15) % 3;
1427 odd = (i + 1) % 2;
1428 x = (i - 24) / 6 - 1 + odd + (color == 0 ? 0 :/* cyan */
1429 color == 1 ? 4 :/* magenta */
1430 8); /* yellow */
1431 }
1432 if (x + left < left_limit || x + left >= right_limit)
1433 {
1434 /* never print data that is outside the limits */
1435 memset (place, 0x00, numlines / 2);
1436 place += numlines / 2;
1437 }
1438 else
1439 {
1440 int new_pre_blanklines , new_non_blanklines , new_post_blanklines;
1441 int new_start;
1442 if (odd)
1443 {
1444 /* odd lines */
1445 new_pre_blanklines = odd_pre_blanklines ;
1446 new_non_blanklines = odd_non_blanklines ;
1447 new_post_blanklines = odd_post_blanklines ;
1448 new_start = start_odd;
1449 }
1450 else
1451 {
1452 /* even lines */
1453 new_pre_blanklines = even_pre_blanklines ;
1454 new_non_blanklines = even_non_blanklines ;
1455 new_post_blanklines = even_post_blanklines ;
1456 new_start = start_even;
1457 }
1458 if ( new_pre_blanklines > 0 )
1459 {
1460 /* first pre_blanklines lines are blank */
1461 memset(place, 0x00, new_pre_blanklines ) ;
1462 place += new_pre_blanklines ;
1463 }
1464 for (y = 0; y < new_non_blanklines ; y++)
1465 {
1466 int index ;
1467 index = ( (y * 2 + new_start) * width8 * 3 +
1468 (x + left ) * 3 + color ) ;
1469
1470 if (index >= (width8 * 3 * maxlines ))
1471 {
1472 DPRINTF ("index out of range! index = %d\n", index);
1473 index = (width8 * 3 * maxlines ) - 1;
1474 }
1475
1476 assert ( index < width8 * 3 * maxlines && index >= 0 );
1477 *place++ = data[k][index];
1478 }
1479 if ( new_post_blanklines > 0 )
1480 {
1481 /* last post_blanklines lines are blank */
1482 memset(place, 0x00, new_post_blanklines ) ;
1483 place += new_post_blanklines ;
1484 }
1485 }
2180 }
2181 if ( !(pre_blanklines %2 == 0) &&
2182 !(non_blanklines % 2 == 0) &&
2183 (post_blanklines % 2 == 0)){
2184 even_pre_blanklines++;
2185 odd_non_blanklines++;
2186 start_even= 1;
2187 start_odd = 0;
2188 }
2189 if ( !(pre_blanklines %2 == 0) &&
2190 (non_blanklines % 2 == 0) &&
2191 !(post_blanklines % 2 == 0)){
2192 even_pre_blanklines++;
2193 odd_post_blanklines++;
2194 start_even= 1;
2195 start_odd = 0;
2196 }
2197
2198 width = right - left ;
2199
2200 evenlines = even_pre_blanklines + even_non_blanklines + even_post_blanklines;
2201 oddlines = odd_pre_blanklines + odd_non_blanklines + odd_post_blanklines;
2202
2203 assert ( oddlines == evenlines );
2204
2205 for (i = (width + 1) * 6 - 1 ; i >= 0; i--) {
2206 int color, x, odd, y ;
2207 j = (width + 1) * 6 - 1 - i ;
2208 if (i < Left_size ){
2209 if (!GET_USABLE (Left_r2l, i)){
2210 memset (place, 0x00, evenlines);
2211 place += evenlines;
2212 continue;
2213 }
2214 odd = GET_ODD (Left_r2l, i );
2215 color = GET_COLOR (Left_r2l, i);
2216 x = GET_X (Left_r2l, i );
2217 } else if (j < Right_size ) {
2218 if (!GET_USABLE (Right_r2l,j)) {
2219 memset (place, 0x00, evenlines);
2220 place += evenlines;
2221 continue;
2222 }
2223 color = GET_COLOR (Right_r2l, j);
2224 odd = GET_ODD (Right_r2l, j);
2225 x = width - 3 - GET_X (Right_r2l, j);
2226 } else {
2227 color = (i / 2 - 15) % 3;
2228 odd = (i + 1) % 2;
2229 x = (i - 24) / 6 - 1 + odd + (color == 0 ? 0 :/* cyan */
2230 color == 1 ? 4 :/* magenta */
2231 8); /* yellow */
2232 }
2233 if (x + left < page_limit->left || x + left >= page_limit->right){
2234 /* never print data that is outside the limits */
2235 memset (place, 0x00, evenlines);
2236 place += evenlines;
2237 } else {
2238 int new_pre_blanklines , new_non_blanklines , new_post_blanklines;
2239 int new_start;
2240 if (odd) {
2241 /* odd lines */
2242 new_pre_blanklines = odd_pre_blanklines ;
2243 new_non_blanklines = odd_non_blanklines ;
2244 new_post_blanklines = odd_post_blanklines ;
2245 new_start = start_odd;
2246 } else {
2247 /* even lines */
2248 new_pre_blanklines = even_pre_blanklines ;
2249 new_non_blanklines = even_non_blanklines ;
2250 new_post_blanklines = even_post_blanklines ;
2251 new_start = start_even;
2252 }
2253 if ( new_pre_blanklines > 0 ) {
2254 /* first pre_blanklines lines are blank */
2255 memset(place, 0x00, new_pre_blanklines ) ;
2256 place += new_pre_blanklines ;
2257 }
2258 for (y = 0; y < new_non_blanklines ; y++) {
2259 int index = ( (y * 2 + new_start) * data_width * 3 +
2260 (x + left ) * 3 + color ) ;
2261 #ifdef DEBUG
2262 if (!( index < data_size && index >= 0) ){
2263 DPRINTF("index=%d, datasize= %d = %d x %d\n",
2264 index, data_size, data_width, swath_limits->non_blanklines);
2265 }
2266 assert ( index < data_size && index >= 0 );
2267 #endif
2268 *place++ = data[index];
2269 }
2270 if ( new_post_blanklines > 0 ){
2271 /* last post_blanklines lines are blank */
2272 memset(place, 0x00, new_post_blanklines ) ;
2273 place += new_post_blanklines ;
14862274 }
1487
1488 }
1489 else /* sweep direction is left-to-right */
1490 {
1491 for (i = 0; i < (p_width8 + 1) * 6 ; i++)
1492 {
1493 int color, x, odd, y;
1494 j = (p_width8 + 1) * 6 - 1 - i ;
1495 if (i < Left_size)
1496 {
1497 if (!GET_USABLE (Left_l2r, i))
1498 {
1499 memset (place, 0x00, numlines / 2);
1500 place += numlines / 2;
1501 continue;
1502 }
1503 color = GET_COLOR (Left_l2r, i);
1504 odd = GET_ODD (Left_l2r, i);
1505 x = GET_X (Left_l2r, i);
1506 }
1507 else if ( j < Right_size )
1508 {
1509 if (!GET_USABLE (Right_l2r, j))
1510 {
1511 memset (place, 0x00, numlines / 2);
1512 place += numlines / 2;
1513 continue;
1514 }
1515 color = GET_COLOR (Right_l2r, j);
1516 odd = GET_ODD (Right_l2r, j);
1517 x = p_width8 -3 - GET_X (Right_l2r,j);
1518 }
1519 else
1520 {
1521 color = (i / 2 - 15) % 3;
1522 odd = i % 2;
1523 x = (i - 24) / 6 - 1 + odd + (color == 0 ? 0 :/* cyan */
1524 color == 1 ? 4 :/* magenta */
1525 8); /* yellow */
1526 }
1527 if (x + left < left_limit || x + left >= right_limit)
1528 {
1529 /* never print data that is outside the limits */
1530 memset (place, 0x00, numlines / 2);
1531 place += numlines / 2;
1532 }
1533 else
1534 {
1535 int new_pre_blanklines , new_non_blanklines , new_post_blanklines;
1536 int new_start;
1537 if (odd)
1538 {
1539 /* odd lines */
1540 new_pre_blanklines = odd_pre_blanklines ;
1541 new_non_blanklines = odd_non_blanklines ;
1542 new_post_blanklines = odd_post_blanklines ;
1543 new_start = start_odd;
1544 }
1545 else
1546 {
1547 /* even lines */
1548 new_pre_blanklines = even_pre_blanklines ;
1549 new_non_blanklines = even_non_blanklines ;
1550 new_post_blanklines = even_post_blanklines ;
1551 new_start = start_even;
1552 }
1553 if ( new_pre_blanklines > 0 )
1554 {
1555 /* first pre_blanklines lines are blank */
1556 memset (place, 0x00, new_pre_blanklines ) ;
1557 place += new_pre_blanklines ;
1558 }
1559 for (y = 0; y < new_non_blanklines; y++)
1560 {
1561 int index ;
1562 index = ((y * 2 + new_start) * width8 * 3 +
1563 (x + left ) * 3 + color);
1564
1565 if (index >= (width8 * 3 * maxlines + 8))
1566 {
1567 DPRINTF ("index out of range! index = %d\n",index);
1568 index = (width8 * 3 * maxlines + 8) - 1;
1569 }
1570
1571 assert ( index < width8 * 3 * maxlines + 8 && index >= 0 );
1572 *place++ = data[k][index];
1573 }
1574 if ( new_post_blanklines > 0 )
1575 {
1576 /* last post_blanklines lines are blank */
1577 memset(place, 0x00, new_post_blanklines) ;
1578 place += new_post_blanklines ;
1579 }
1580 }
1581 }
1582 }
1583 maxplace = place;
1584
1585 /* create sweep data */
1586 sweep_data->image_data[k] = ppa;
1587 }
1588
1589 sweep_data->data_size = maxplace - ppa;
1590 sweep_data->in_color = true;
1591
1592 horzpos = (left - 7) * 8 * 2 + printer->ColBwOffsX - 600 ;
1593
1594 horzpos += (sweep_data->direction == left_to_right) ? 2 : 12 ;
1595
1596 if (sweep_data->direction == right_to_left )
1597 horzpos += printer->r2l_col_offset ; /*correct bidirectional shearing*/
1598
1599 hp2 = 16 + horzpos + p_width8 * 2 * 8;
1600 sweep_data->left_margin = horzpos;
1601 sweep_data->right_margin = hp2 + 0x74; /* printer->color_marg_diff */
1602
1603 DPRINTF("sweep data: left_margin = %d, right margin = %d\n",
1604 sweep_data->left_margin, sweep_data->right_margin);
1605
1606 for (i = 0; i < 6; i++)
1607 {
1608 nozzles[i].DPI = 300;
1609 nozzles[i].pins_used_d2 = numlines / 2;
1610 nozzles[i].unused_pins_p1 = 65 - numlines;
1611 nozzles[i].first_pin = 1;
1612 if (i == 0)
1613 {
1614 nozzles[i].left_margin = horzpos + 0x74;
1615 nozzles[i].right_margin = hp2 + 0x74;
1616 if (sweep_data->direction == right_to_left)
1617 nozzles[i].nozzle_delay = 0;
1618 else
1619 nozzles[i].nozzle_delay = 0;
1620 }
1621 if (i == 1)
1622 {
1623 nozzles[i].left_margin = horzpos + 0x64;
1624 nozzles[i].right_margin = hp2 + 0x64;
1625 if (sweep_data->direction == right_to_left)
1626 nozzles[i].nozzle_delay = 0;
1627 else
1628 nozzles[i].nozzle_delay = 0;
1629 }
1630 if (i == 2)
1631 {
1632 nozzles[i].left_margin = horzpos + 0x3A;
1633 nozzles[i].right_margin = hp2 + 0x3A;
1634 if (sweep_data->direction == right_to_left)
1635 nozzles[i].nozzle_delay = 0x0A;
1636 else
1637 nozzles[i].nozzle_delay = 0x0A;
1638 }
1639 if (i == 3)
1640 {
1641 nozzles[i].left_margin = horzpos + 0x3A;
1642 nozzles[i].right_margin = hp2 + 0x3A;
1643 if (sweep_data->direction == right_to_left)
1644 nozzles[i].nozzle_delay = 0x0A;
1645 else
1646 nozzles[i].nozzle_delay = 0x0A;
1647
1648 }
1649 if (i == 4)
1650 {
1651 nozzles[i].left_margin = horzpos + 0x10;
1652 nozzles[i].right_margin = hp2 + 0x10;
1653 if (sweep_data->direction == right_to_left)
1654 nozzles[i].nozzle_delay = 0x04;
1655 else
1656 nozzles[i].nozzle_delay = 0x04;
1657
1658 }
1659 if (i == 5)
1660 {
1661 nozzles[i].left_margin = horzpos + 0x00;
1662 nozzles[i].right_margin = hp2 + 0x00;
1663 if (sweep_data->direction == right_to_left)
1664 nozzles[i].nozzle_delay = 0x04;
1665 else
1666 nozzles[i].nozzle_delay = 0x04;
1667
1668 }
1669 }
1670
1671 sweep_data->nozzle_data_size = 6;
1672 sweep_data->nozzle_data = malloc (sizeof (nozzles));
1673 if (sweep_data->nozzle_data == NULL)
1674 return 0;
1675 memcpy (sweep_data->nozzle_data, nozzles, sizeof (nozzles));
1676
1677 DPRINTF ("cut_im_color_swath: return 2 on line %d\n", __LINE__);
1678
1679 for (k = 0; k < gMaxPass; k++)
1680 free (data[k]);
1681
1682 return 2;
1683
1684 }
1685
1686 /*
1687
1688 Here, we should call cut_im_black_swath and cut_im_color_swath to begin.
1689
1690 Then, we need to determine which of these swaths comes earlier on the page
1691 and print it first. Then we should re-call the appropriate cut_im_*_swath
1692 function to refill that buffer and repeat this procedure.
1693
1694 */
1695
1696
1697 int
1698 ppa_print_page (ppaPrinter_t *printer, image_t *image)
1699 {
1700 ppaSweepData_t sweeps[3], *curblack, *curcolor, *prev, *tmp;
1701 int reload[2] = { 1, 1 };
1702 int done[2] = { 0, 0 };
1703 int k,found[2];
1704 int firstfound;
1705 int color_maxlines=64, black_maxlines=300;
1706
1707
1708 /* note: a full-size (all nozzles) color swath is 64 even lines (300dpi);
1709 a full-size (all nozzles) black swath is 300 lines (150 even + 150 odd);
1710 is is necessary to restrict black swath to 128 lines (64 even + 64 odd)
1711 on some printer models, when printing in dual inks, color+black ?
1712 HP7x0: NO, but there is some artifact at the begining of
1713 each black swath that does not immediately follow a black
1714 swath. (see the calibrate_ppa --align output....)
1715 so leave the setting at 128 in gColorMode for now.
1716 (duncan, 2000-10-24)
1717 HP820: YES flashes lights ... (maybe it will work if what
1718 produces the artifacts on HP7x0 is fixed..?)
1719 HP1000: ?
1720 */
1721
1722 switch (printer->version)
1723 {
1724 case HP7X0:
1725 black_maxlines=300;
1726 color_maxlines=64;
1727 if (gColorMode)
1728 black_maxlines = color_maxlines * 2 ;
1729 break;
1730 case HP820:
1731 black_maxlines=300;
1732 color_maxlines=64;
1733 if (gColorMode)
1734 black_maxlines = color_maxlines * 2 ;
1735 break;
1736 case HP1000:
1737 black_maxlines=300;
1738 color_maxlines=64;
1739 if (gColorMode)
1740 black_maxlines = color_maxlines * 2 ;
1741 break;
1742 default:
1743 break;
1744 }
1745
1746 DPRINTF("ppa_print_page(): black_maxlines=%d, color_blacklines=%d\n",
1747 black_maxlines, color_maxlines );
1748
1749 /* initialize vertical position markers, etc. */
1750 c_vpos = b_vpos = 0;
1751
1752 firstfound=0;
1753
1754 curblack = &sweeps[0];
1755 curcolor = &sweeps[1];
1756
1757 prev = NULL;
1758
1759 DPRINTF ("ppa_print_page: chkpt 1\n");
1760
1761
1762
1763 /* note: the bidirectional print sweep code is not
1764 quite perfect as not every right-to-left sweep gets
1765 followed by a left-to-right sweep. However, the empirical
1766 choices below for the initialization of
1767 sweeps[2].direction seem to make the opposite direction
1768 sweeps come after each other, most of the time. Different
1769 choices were needed in gColorMode and !gColorMode... (duncan)
1770 */
1771
1772
1773 sweeps[0].direction = left_to_right;
1774 sweeps[0].next = NULL;
1775 sweeps[1].direction = left_to_right;
1776 sweeps[1].next = NULL;
1777 sweeps[2].direction = right_to_left;
1778 sweeps[2].next = NULL;
1779
1780 if ( !gColorMode)
1781 {
1782 done[1] = 1;
1783 sweeps[0].direction = right_to_left;
1784 sweeps[1].direction = left_to_right;
1785 sweeps[2].direction = left_to_right;
1786 }
1787
1788 sweeps[1].next = NULL;
1789 found[0]=found[1]=0;
1790
1791 while (!done[0] || !done[1])
1792 {
1793
1794 DPRINTF("ppa_print_page: statistics follows\n");
1795 DPRINTF("done[0]=%d\tdone[1]=%d\nreload[0]=%d\treload[1]=%d\nfound[0]=%d\tfound[1]=%d\n",
1796 done[0],done[1],reload[0],reload[1],found[0],found[1]);
1797
1798 if (reload[0])
1799 {
1800 reload[0] = 0;
1801
1802 switch (cut_im_black_swath (image, printer, black_maxlines, curblack))
1803 {
1804 case 0:
1805 snprintf(syslog_message,message_size,"ppa_print_page(): %s cut_im_black_swath()",
1806 gMessages[E_CS_ERROR]);
1807 wrap_syslog (LOG_CRIT,"%s",syslog_message);
1808 return 1;
1809 break;
1810 case 1:
1811 done[0] = 1;
1812 break;
1813 case 2:
1814 found[0]=1;
1815 if (!firstfound)
1816 {
1817 firstfound=1;
1818 curcolor->direction=right_to_left;
1819 }
1820 break;
1821 case 3:
1822 reload[0]=1;
1823 found[0]=0;
1824 break;
1825 default:
1826 snprintf(syslog_message,message_size,"ppa_print_page(): %s",
1827 gMessages[E_CS_BADSWITCH]);
1828 wrap_syslog (LOG_CRIT,"%s",syslog_message);
1829 return 1;
1830 }
1831 }
1832 if (reload[1] && !done[1])
1833 {
1834 reload[1] = 0;
1835 switch (cut_im_color_swath (image, printer, color_maxlines, curcolor))
1836 {
1837 case 0:
1838 snprintf(syslog_message,message_size, "ppa_print_page(): %s cut_im_color_swath()",
1839 gMessages[E_CS_ERROR]);
1840 wrap_syslog (LOG_CRIT,"%s",syslog_message);
1841 break;
1842 return 1;
1843 case 1:
1844 DPRINTF("ppa_print_page: cut_im_color_swath returned 1\n");
1845 done[1] = 1;
1846 break;
1847 case 2:
1848 found[1]=1;
1849 if (!firstfound)
1850 {
1851 firstfound=1;
1852 curblack->direction=right_to_left;
1853 }
1854 break;
1855 case 3:
1856 reload[1]=1;
1857 found[1]=0;
1858 break;
1859 default:
1860 snprintf(syslog_message,message_size,"ppa_print_page(): %s ",
1861 gMessages[E_CS_BADSWITCH]);
1862 wrap_syslog (LOG_CRIT,"%s",syslog_message);
1863 return 1;
1864 }
1865 }
1866
1867 if (done[0] && done[1])
1868 break;
1869
1870 if ( (!done[0] && found[0] &&
1871 (done[1] || !found[1] || curblack->vertical_pos < curcolor->vertical_pos)) )
1872
1873 {
1874 DPRINTF("ppa_print_page: chkpt 2\n");
1875
1876 reload[0] = 1;
1877 DPRINTF("ppa_print_page: chkpt 3\n");
1878 if (prev)
1879 {
1880 prev->next = curblack;
1881 DPRINTF("ppa_print_sweep 1\n");
1882 ppa_print_sweep (printer, prev);
1883 for (k = 0; k < gMaxPass; k++)
1884 free (prev->image_data[k]);
1885 free (prev->nozzle_data);
1886 }
1887 else
1888 prev = &sweeps[2];
1889
1890 /* move the current sweep into the 'prev' position */
1891 tmp = curblack;
1892 curblack = prev;
1893 prev = tmp;
1894 }
1895 else
1896 if ( (!done[1] && found[1]) ) // && (done[0] || !found[0] ||curblack->vertical_pos > curcolor->vertical_pos)))
1897 {
1898 DPRINTF("ppa_print_page: chkpt 4 \n");
1899
1900 reload[1] = 1;
1901
1902 if (prev)
1903 {
1904 prev->next = curcolor;
1905 DPRINTF("ppa_print_sweep 2\n");
1906 ppa_print_sweep (printer, prev);
1907 for (k = 0; k < gMaxPass; k++)
1908 free (prev->image_data[k]);
1909 free (prev->nozzle_data);
1910 }
1911 else
1912 prev = &sweeps[2];
1913
1914 tmp = curcolor;
1915 curcolor = prev;
1916 prev = tmp;
1917 }
1918 }
1919
1920 DPRINTF ("ppa_print_page: chkpt 5\n");
1921
1922 if (prev)
1923 {
1924 DPRINTF ("ppa_print_page: chkpt 6 about to clear prev\n");
1925
1926 prev->next = NULL;
1927 DPRINTF ("ppa_print_sweep 3\n");
1928 ppa_print_sweep (printer, prev);
1929 for (k = 0; k < gMaxPass; k++)
1930 free (prev->image_data[k]);
1931 free (prev->nozzle_data);
1932 DPRINTF ("ppa_print_page: chkpt 7 cleared prev\n");
1933 }
1934
1935 DPRINTF ("ppa_print_page: chkpt 8 Finish.\n");
1936
1937 for (k=0; k < gMaxPass; k++)
1938 free(image->buffer[k]);
1939
1940 return 0;
1941 }
2275 }
2276 }
2277 return place ;
2278 }
2279
5656
5757 #ifdef __PNM2PPA_C__
5858
59 // we only initialise the once
59 /* we only initialise the once */
6060
6161 printerDefault_t gPrinterDefaults[] = {
6262 {
133133
134134 for (i = -255; i < 256; i++)
135135 {
136 err_coeff_e[i] = i * 8 / dd; //8
137 err_coeff_se[i] = i * 5 / dd; //5
138 err_coeff_s[i] = i * 8 / dd; //8
139 err_coeff_sw[i] = i * 4 / dd; //4
136 err_coeff_e[i] = i * 8 / dd;
137 err_coeff_se[i] = i * 5 / dd;
138 err_coeff_s[i] = i * 8 / dd;
139 err_coeff_sw[i] = i * 4 / dd;
140140 }
141141 }
142142
223223
224224 if (!gGammaMode)
225225 {
226 // yet another fine mocho fix! :-)
227226 br = R / 2;
228227 bg = G / 2;
229228 bb = B / 2;
230 //d = ((2.0 + (float)R / 256.0) * R * R + 4 * G * G + (2 + (255.0 - (float)R) / 256.0) * B * B)*0.7;
231
229 #if 0
230 d = ((2.0 + (float)R / 256.0) * R * R + 4 * G * G + (2 + (255.0 - (float)R) / 256.0) * B * B)*0.7;
231 #endif
232232 if (gMaxPass == 4)
233233 {
234234 d = (R * R + G * G + B * B) * 1.3;
246246 /* this is for the special case when gamma.ppm is
247247 * being generated.
248248 */
249 d = 2147483647; //just a large initial value
249 d = 2147483647; /* just a large initial value */
250250 }
251251
252252 #ifdef CHECK_HASHING
298298
299299 {
300300
301 //rmean = ((int) R + (int) hp_pal[4-x][4-y][4-z][0]) / 2;
301 #if 0
302 rmean = ((int) R + (int) hp_pal[4-x][4-y][4-z][0]) / 2;
303 #endif
302304
303305 r =
304306 (int) R - (int) hp_pal[4 - x][4 - y][4 -
312314 (int) B - (int) hp_pal[4 - x][4 - y][4 -
313315 z]
314316 [2];
315
316 //d1 = (2.0 + (float)rmean / 256.0) * r * r +
317 // 4 * g * g +
318 // (2 + (255.0 - (float)rmean) / 256.0) * b * b;
319
317 #if 0
318 d1 = (2.0 + (float)rmean / 256.0) * r * r +
319 4 * g * g +
320 (2 + (255.0 - (float)rmean) / 256.0) * b * b;
321 #endif
320322 d1 = /* 0.5 * */ r * r + g * g + b * b;
321323
322324 /* the next test also excludes "too dark"
359361
360362 if ( true /* || (bx==0 && by==0 && bz==0) */ )
361363 {
362 // careful! floats cannot be compared easily
364 /* careful! floats cannot be compared easily */
363365 if (!(d == 0.0) && ((i + 8) < image->width * 3))
364366 {
365367
453455 void
454456 HT_Black_Dither (image_t *image, unsigned char *line)
455457 {
456 int i, j, k, i_max;
457
458 unsigned int halftone[5][5] = {
459 {120, 180, 450, 270, 30},
458 int i, j = 0, k, i_max;
459
460 unsigned int halftone_3[5][5] = {
461 {120, 180, 450, 270, 30},
460462 {240, 510, 720, 600, 330},
461463 {420, 630, 750, 660, 390},
462464 {360, 570, 690, 540, 210},
463 {60, 300, 480, 150, 90}
465 { 60, 300, 480, 150, 90}
464466 };
465467
466 i_max = image->width * 3;
467 j = 0;
468 unsigned int halftone[5][5] = {
469 { 40, 60, 150, 90, 10},
470 { 80, 170, 240, 200, 110},
471 {140, 210, 250, 220, 130},
472 {120, 190, 230, 180, 70},
473 { 20, 100, 160, 50, 30}
474 };
475
468476 k = image->bufferCurLine % 5;
469 for (i = 0; i < i_max; i += 3)
470 {
471
472 /* make black pixels come in pairs */
473 if ( !(i % 6) && (i + 3) != i_max )
474 {
475 if (!line[i] && !line[i + 1] && !line[i + 2] )
476 line[i + 3] = line [i + 4] = line[i + 5] = 0;
477 else
478 if (!line[i + 3] && !line[i + 4] && !line[i + 5] )
479 line[i] = line [i + 1] = line[i + 2] = 0;
480 }
481
482
483 if ( line[i] + line[i + 1] + line[i + 2] < halftone[j][k])
484 {
485 line[i] = line[i + 1] = line[i + 2] = 0;
486 }
487
488 else
489 {
490 line[i] = line[i + 1] = line[i + 2] = 255;
491 }
492 if (j == 4)
493 j = 0;
494 else
477
478 if (gByteCount == 3)
479 {
480 i_max = image->width * 3;
481 for (i = 0; i < i_max ; i += 3)
482 {
483 /* make black pixels come in pairs */
484 if ( !(i % 6) && (i + 3) != i_max )
485 {
486 if (!line[i] && !line[i + 1] && !line[i + 2] )
487 line[i + 3] = line [i + 4] = line[i + 5] = 0;
488 else
489 if (!line[i + 3] && !line[i + 4] && !line[i + 5] )
490 line[i] = line [i + 1] = line[i + 2] = 0;
491 }
492
493
494 if (line[i] + line[i + 1] + line[i + 2] < halftone_3[j][k])
495 line[i] = line[i + 1] = line[i + 2] = 0;
496 else
497 line[i] = line[i + 1] = line[i + 2] = 255;
498
495499 j++;
496 }
500 j %= 4;
501 }
502 }
503 else /* gByteCount = 1 */
504 {
505 i_max = image->width;
506 for (i = 0; i < i_max ; i++)
507 {
508 /* make black pixels come in pairs */
509 if ( !(i % 2) && (i + 1) != i_max )
510 {
511 if (!line[i])
512 line[i + 1] = 0;
513 else
514 if (!line[i + 1] )
515 line[i] = 0;
516 }
517
518 if (line[i] < halftone[j][k])
519 line[i] = 0;
520 else
521 line[i] = 255;
522
523 j++;
524 j %= 4;
525
526 }
527 }
497528 }
498529
499530 void
55 http://sourceforge.net/projects/pnm2ppa (Updated for pnm2ppa-1.02 and
66 later.)
77
8 OOvveerrvviieeww ooff PPrriinntteerr CCaalliibbrraattiioonn..
8 Overview of Printer Calibration.
99
1010 There are three main tasks you may need to carry out to fine-tune your
1111 PPA printer:
1212
13 +o Adjust the x-offset and y-offset to ccoorrrreeccttllyy cceenntteerr tthhee pprriinntteedd
14 ppaaggee oonn tthhee ppaappeerr
15
16 +o Adjust the relative offsets between black and colored ink printing
17 - tthhiiss sshhoouulldd bbee ddoonnee eeaacchh ttiimmee yyoouu rreeppllaaccee aann iinnkk ccaarrttrriiddggee.
18
19 +o Match the colors of printed images to some other output device -
20 this is ccoolloorr ccoorrrreeccttiioonn and is described in COLOR.html (or
13 o Adjust the x-offset and y-offset to correctly center the printed
14 page on the paper
15
16 o Adjust the relative offsets between black and colored ink printing
17 - this should be done each time you replace an ink cartridge.
18
19 o Match the colors of printed images to some other output device -
20 this is color correction and is described in COLOR.html (or
2121 COLOR.txt).
2222
2323 These instructions assume that you are already able to print
3232 system and distribution you use.
3333
3434
35 ((11)) CCeenntteerriinngg tthhee pprriinntteedd ppaaggee oonn tthhee ppaappeerr..
36
37 This is done by adjusting the x-offset and y-offset parameters xxooffffsseett
38 and yyooffffsseett in the pnm2ppa configuration file (usually
35 (1) Centering the printed page on the paper.
36
37 This is done by adjusting the x-offset and y-offset parameters xoffset
38 and yoffset in the pnm2ppa configuration file (usually
3939 /etc/pnm2ppa.conf). The parameters are given in units of 1/600 inch;
4040 increasing xoffset moves the image to the right, and increasing
4141 yoffset moves it downwards. These offsets now have default values
4848
4949 There are two ways to check the offsets.
5050
51 +o either uussiinngg tthhee ""calibrate_ppa" program.
52
53 +o or pprriinnttiinngg aa ssuuiittaabbllee tteesstt ppaaggee.
51 o either using the "calibrate_ppa" program.
52
53 o or printing a suitable test page.
5454
5555
5656 The "calibrate_ppa" program is a stand-alone program distributed with
9090
9191
9292
93
94 ((22)) CCaalliibbrraattiinngg tthhee XX aanndd YY CCoolloorr HHeeaadd OOffffsseettss..
93 (2) Calibrating the X and Y Color Head Offsets.
9594
9695 The color ink offsets now have to be calibrated with respect to the
9796 black ink. Because the relative position of the two ink cartridges
98 can move slightly, tthhiiss mmuusstt bbee ddoonnee wwhheenneevveerr aann iinnkk ccaarrttrriiddggee iiss
99 rreemmoovveedd aanndd rreeppllaacceedd.
97 can move slightly, this must be done whenever an ink cartridge is
98 removed and replaced.
10099
101100 To print an alignment calibration pattern on a4 paper, run
102101
105104
106105
107106
108
109107 On the printed page, there are four alignment patterns, corresponding
110 to configuration file parameters CCoollOOffffssXX, CCoollOOffffssYY, ccoolloorrsshheeaarr and
111 bbllaacckksshheeaarr. The central alignment patterns, labelled "0" should be
108 to configuration file parameters ColOffsX, ColOffsY, colorshear and
109 blackshear. The central alignment patterns, labelled "0" should be
112110 perfectly aligned. If they are not, first correct the shearing
113 patterns, (see below). Then identify the best-aligned CCoollOOffffssXX and
114 CCoollOOffffssYY patterns, and add or subtract the positive or negative
111 patterns, (see below). Then identify the best-aligned ColOffsX and
112 ColOffsY patterns, and add or subtract the positive or negative
115113 number below the pattern from the value in the configuration file.
116114
117115 Check the result by printing the alignment test pattern:
118116
119117
120118 calibrate_ppa --test | pnm2ppa -fd -i - -o - | lpr -l
121
122119
123120
124121
131128
132129 On the printout you see several images:
133130
134 +o top left, you see a square with both black and colored items.
131 o top left, you see a square with both black and colored items.
135132 These should align correctly, or you have to change your settings.
136133
137 +o You see a large vertical bar, and also a horizontal bar. On the
134 o You see a large vertical bar, and also a horizontal bar. On the
138135 sides of the vertical bar there are a blue and a green line.
139136 These should align with the 0 mark.
140137
141 +o You also see a small vertical, and horizontal, bar, with a red bar
138 o You also see a small vertical, and horizontal, bar, with a red bar
142139 on its side.
143140
144141 If these items do NOT line up, you should take the following steps:
145142
146 +o (1) take for the large bar the number of the tickmark just smaller
143 o (1) take for the large bar the number of the tickmark just smaller
147144 than the place where the green and blue lines point to. The minor
148145 tick marks are 25 points.
149146
150 +o (2) To this number, add the number of the tick mark at which a red
147 o (2) To this number, add the number of the tick mark at which a red
151148 tick mark exactly lines up. This might not work if the offsets are
152149 way off; in that case, apply the correction of step 1, and print
153150 again.
154151
155 +o (3) Add the horizontal offset to the value of CCoollOOffffssXX, and the
156 vertical offset to the value of CCoollOOffffssYY in the configuration file.
152 o (3) Add the horizontal offset to the value of ColOffsX, and the
153 vertical offset to the value of ColOffsY in the configuration file.
157154
158155 Now you can print test.ps again to see whether this procedure worked.
159156
160157
161 SShheeaarriinngg aaddjjuussttmmeennttss
158 Shearing adjustments
162159
163160 If bidirectional printing causes "shearing" of vertical lines
164161 (horizontal offsets of those parts of the line printed by left-to-
165162 right print-head sweeps relative to those printed on right-to-left
166163 sweeps) you can make small adjustments (in 1/600 inch) units using the
167 bbllaacckksshheeaarr and ccoolloorrsshheeaarr parameters in the configuration file. You
168 can also suppress bidirectional printing with a uunniimmooddee 11
164 blackshear and colorshear parameters in the configuration file. You
165 can also suppress bidirectional printing with a unimode 1
169166 configuration file entry.
170167
171168 The third and fourth lines on the color head offset calibration page
175172 best-aligned pattern from the colorshear and blackshear values in the
176173 configuration file.
177174
178 CClleeaanniinngg tthhee PPrriinntt HHeeaaddss
175 Cleaning the Print Heads
179176
180177 You can use calibrate_ppa to clean the print heads by printing
181178 patterns that exercise all the ink nozzles:
186183
187184
188185
189
190186 The first of these commands prints a cleaning pattern with colored
191187 ink, the second uses black ink.
192188
193189
194 OOtthheerr aaddjjuussttmmeennttss
195
196 The parameter bbllaacckknneessss adjusts the number of black ink drops printed
190 Other adjustments
191
192 The parameter blackness adjusts the number of black ink drops printed
197193 per pixel. It takes values 1, 2, 3, or 4 (2 is the default). Other
198194 values, like 0, suppress black ink.
199195
203199
204200
205201
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
55 printing. http://sourceforge.net/projects/pnm2ppa (Updated for
66 pnm2ppa-1.0 and later.)
77
8 OOvveerrvviieeww ooff CCoolloorr ccoorrrreeccttiioonn..
8 Overview of Color correction.
99
1010 Color Pixmap input to pnm2ppa (ppm format, produced by the ghostscript
1111 output devices ppmraw or ppm) specifies the color of a pixel as three
1313 pnm2ppa converts these to relative amounts of Cyan, Magenta and Yellow
1414 ink drops printed on the page.
1515
16 CCoolloorr ccoorrrreeccttiioonn allows the user to attempt to match the printed
16 Color correction allows the user to attempt to match the printed
1717 colors to some reference colors, such as those displayed on the
1818 terminal, or those printed on a different printer, or those printed
1919 on the same printer with a different driver (such as the Win9x
2222
2323 The color output from pnm2ppa can be controlled in two ways:
2424
25 +o by a color correction "gamma" file, if it is installed. By
25 o by a color correction "gamma" file, if it is installed. By
2626 default this file is /etc/pnm2ppa.gamma, but it may also be
2727 specified with the pnm2ppa option
2828 pnm2ppa ... -F gammafile ... .
2929
30 +o if there is no gamma file, by three values specified by keywords
30 o if there is no gamma file, by three values specified by keywords
3131 ( either GammaR, GammaG, GammaB or RedGammaIdx, BlueGammaIdx,
3232 GreenGammaIdx) in the pnm2ppa configuration file.
3333
3434
35 pnm2ppa will carry out ""ccoolloorr ccoorrrreeccttiioonn"", unless it is called with
36 the ----nnooGGaammmmaa command line option. However, unless you set up a color
35 pnm2ppa will carry out "color correction", unless it is called with
36 the --noGamma command line option. However, unless you set up a color
3737 correction scheme, the default color correction does not change any
3838 colors.
3939
5656 pnm2ppa are not very user-friendly. If you can improve them, please
5757 help!.
5858
59 CCoolloorr ccoorrrreeccttiioonn wwiitthh ""ggaammmmaa"" vvaalluueess iinn tthhee ccoonnffiigguurraattiioonn ffiillee..
59 Color correction with "gamma" values in the configuration file.
6060
6161 The PixMap (ppa) format specifies colors by an intensity for each
6262 primary color, Red, Green and Blue, in the range 0-255, so (0,0,0) is
8989
9090
9191
92
9392 (replace /dev/lp0 by whatever printer device your PPA printer uses, or
9493 use ... -o - | lpr -l , etc.). Note also that as pnm2ppa is not
9594 receiving any ghostscript input to tell it the paper size, this must
110109
111110
112111
113
114112 This will produce the PixMap file as gamma.ppm in the current direc-
115113 tory.
116114
128126
129127
130128
131
132129 (i.e., no color correction). Enter your modified values for these in
133130 the pnm2ppa configuration file (usually /etc/pnm2ppa.conf).
134131
135 The actual Gamma value is then 11..00 -- 00..003333**((CCoolloorr))GGaammmmaaIIddxx ;
132 The actual Gamma value is then 1.0 - 0.033*(Color)GammaIdx ;
136133
137134 To color-correct with respect to another printer (or the Win9x
138135 drivers), you must manage to print gamma.ppm on that other device,
140137 device; the top line is the same uncorrected color data as
141138 gamma.ppm.)
142139
143 CCoolloorr ccoorrrreeccttiioonn uussiinngg aa ""ggaammmmaa ffiillee""..
140 Color correction using a "gamma file".
144141
145142 A "gamma correction file" is a binary file containing 3 x 256 numbers,
146143 which are lookup tables of corrected red green and blue color
156153 Currently, there are two available tools for constructing a gamma
157154 correction file:
158155
159 +o A graphical utility ppagammacorrect is available in the PPA Color
156 o A graphical utility ppagammacorrect is available in the PPA Color
160157 Correction Utilities section of the pnm2ppa web page
161158 http://sourceforge.net/projects/pnm2ppa, (but at the time of
162159 writing, this appears to be frozen in early stages of development,
163160 with little documentation, and may not be fully functional).
164161
165 +o A working procedure is given in
162 o A working procedure is given in
166163 http://download.sourceforge.net/pnm2ppa/color-calibrate-1.0.tar.gz,
167 which is made available by Klamer Schutte. TThhiiss iiss tthhee mmeetthhoodd
168 rreeccoommmmeennddeedd bbyy mmaannyy uusseerrss..
164 which is made available by Klamer Schutte. This is the method
165 recommended by many users.
169166
170167
171168
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
0 pnp2ppa-1.12, November 2002.
1
02 Overview
13 --------
24 This file contains some quick notes on installation in general.
5 For more information on pnm2ppa, see INSTALL.REDHAT.txt or
6 INSTALL.REDHAT.html, which (despite its name) has a lot of
7 non-RedHat-specific information.
8
39
410 Compilation
511 -----------
713
814 make
915
10 If you have NetBSD or FreeBSD, you'll need to edit the Makefile to include
11 an additional library (libgnugetopt) which pnm2ppa requires.
12 Also edit the Makefile to select compilation for BeOS.
16 If you have MacOS X, NetBSD, or FreeBSD, you'll need to edit the
17 Makefile to include an additional library (libgnugetopt) which pnm2ppa
18 requires.
19
20 Also edit the Makefile to select compilation for BeOS, or on Solaris.
21
22 You may also edit the Makefile to suppress use of the system log
23 (use the -D__NO_SYSLOG__ compiler option)
1324
1425 There is some internationalization (i18n) of the system log messages.
1526 Edit the Makefile to choose a language other than English.
27
28 If you wish to do any further development of pnm2ppa, or study how it works
29 so you can write a PPA backend to some other print system such as gimp-print,
30 there is a useful tool called parse_vlink (and some documentation)
31 that can be built in the ppa_protocol subdirectory.
1632
1733 Installation
1834 ------------
2541
2642 The other binary created, pnm2ppa, is a converter from a PNM
2743 image to a stream of PPA data that can be sent directly to the printer.
28 The PNM image *must* have a resolution of 600 dpi. These files can be
29 generated with ghostscript. The binary-output pbmraw, pgmraw, ppmraw devices
44 The PNM image will be aasumed to have a resolution of 600 dpi (or 300dpi
45 if the --dpi300 command line option is used). (Input at higher/lower
46 resolutions will print with an incorrect larger/smaller size, if it
47 is within the allowed page size limits.) These files can be generated
48 with ghostscript. The binary-output pbmraw, pgmraw, ppmraw devices
3049 are supported (the text-output pbm, pgm, ppm devices are also supported, but
3150 the raw devices are MUCH faster!).
3251
4564
4665 *** IMPORTANT ***
4766
48 You **MUST** now edit /etc/pnm2ppa.conf to at least remove the line
49 "version ERROR", and choose the correct printer version (720, 820, 1000, etc)
50 before you can do anything with pnm2ppa.
67 The default configuration file /etc/pnm2ppa.conf sets the printer model to
68 "version 0" (NULL printer). Unless you use the -v command line option
69 to set the printer model (as is usually done by CUPS, lprNG, etc. scripts that
70 call pnm2ppa), you must edit the configuration file to change this line and
71 choose the correct printer version (720, 820, 1000, etc).
72 If the printer version is unspecified, it defaults to "720" (valid for
73 HP710C/712C/720C/722C).
5174
52 Other things you can do are docunented in the sample configuration
75 Other things you can do are documented in the sample configuration
5376 file /etc/pnm2ppa.conf
5477
5578
101124
102125 You can set up printer filters. See the documentation for
103126 your print spooler for information on how to do that.
127
104128 The subdirectory lpd of the pnm2ppa distribution contains a
105129 printer description file "printcap" and so filters to go with it.
106130 See the README.lpd file there.
131
132 The subdirectory ppaSet of the pnm2ppa distribution contains a
133 software to help configuring the printer (and better, for each user in the
134 system), for both GTK and ncurses. Just see README file there. This
135 software is fully compatible with the previous one, not a replacement.
107136
108137
109138 On some Linux distributions, (RedHat, Mandrake, ... etc.), packages
113142 in the pnm2ppa source distribution.
114143
115144
116 Recent versions of printtool/rhs-printfilters support pnm2ppa.
145 Note: the "foomatic" data base at http://www.linuxprint.org now supports
146 pnm2ppa, and produces scripts for configuring lpd-based systems. RedHat
147 use this system since RedHat 7.2
148
149
150 An older printfilter system for lpd systems that also supports pnm2ppa is
151 apsfilter (http://www.apsfilter.org).
117152
118153 ---------------
119154
127162 ----------------
128163
129164 (C) CUPS ("Common Unix Printing System")
130 An experimental system for generating a CUPS driver is online at
131 http://www.linuxprinting.org
132165
133 See http;//sourceforge.net/projects/CUPS
134 We do need a CUPS driver for pnm2ppa. If you figure it out,
135 please contribute it!
166 pnm2ppa is now integrated into the CUPS printing system:
167 see http://www.cups.org. The "cupsomatic" scripts from the
168 http://www.linuxprinting.org site support pnm2ppa on CUPS.
169
170
171 "ppaSet": a Graphical User Interface for configuring pnm2ppa:
172 -------------------------------
173 There is also a new graphical (gtk-based) utility for creating
174 a pnm2ppa.conf configuration file and also can act as a front end to the
175 calibration utility calibrate_ppa. It is written by Javier Sedano,
176 and called ppaSet. Find it at http://sourceforge.net/projects/pnm2ppa.
136177
137178
138179
139
140
141
142
143
144
145
00 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
11 <HTML>
22 <HEAD>
3 <META NAME="GENERATOR" CONTENT="SGML-Tools 1.0.9">
3 <META NAME="GENERATOR" CONTENT="LinuxDoc-Tools 0.9.16">
44 <TITLE>PPA Printer-Support RPM Packages for MANDRAKE Linux distributions.</TITLE>
55
66
1313 <H1>PPA Printer-Support RPM Packages for MANDRAKE Linux distributions.</H1>
1414
1515 <H2>The pnm2ppa project team
16 <A HREF="mailto:ppa-rpms@sourceforge.net">ppa-rpms@users.sourceforge.net</A></H2>v0.1 Nov 11, 2000
17 <P><HR>
16 <A HREF="mailto:ppa-rpms@sourceforge.net">ppa-rpms@users.sourceforge.net</A></H2>v0.2 June 11, 2002
17 <HR>
1818 <EM>Information about using pnm2ppa with Mandrake. (Updated for pnm2ppa-1.04 and later.)</EM>
1919 <HR>
20 <P><B> Mandrake-specific issues.</B>
20 <P><B> Mandrake-specific issues.</B></P>
2121 <P>See the document
2222 <A HREF="file:INSTALL.REDHAT.html">INSTALL.REDHAT.html</A>
2323 for installation and setup. That document is written
2424 for Red Hat; note the Mandrake-specific differences
25 listed below,
25 listed below,</P>
26 <P><B> To update <CODE>pnm2ppa</CODE>
27 in any recent Mandrake release (7.2 or later) from v1.04 to v1.10,
28 the simplest procedure may be
29 just to compile pnm2ppa from tarball source and replace the Mandake binaries
30 <CODE>/usr/bin/pnm2ppa</CODE> and <CODE>/usr/bin/calibrate_ppa</CODE> with
31 the new versions. They should function as drop-in replacements,
32 with the same user interface, but improved image quality.
33 (You may also wish to use the newer <CODE>pnm2ppa.conf</CODE> configuration
34 file template).</B></P>
35
36
37
38
2639 <P>
2740 <UL>
2841 <LI> Mandrake 7.0 and earlier has incompatible and non-functional
5871 and appears to now have its own printer configuration tool, but still
5972 includes <CODE>pnm2ppa</CODE> support in <CODE>rhs-printfilters</CODE>.</LI>
6073 </UL>
74 </P>
6175 <HR>
6276 Next
6377 Previous
00 PPA Printer-Support RPM Packages for MANDRAKE Linux distri-
11 butions.
22 The pnm2ppa project team ppa-rpms@users.sourceforge.net
3 v0.1 Nov 11, 2000
3 v0.2 June 11, 2002
44
55 Information about using pnm2ppa with Mandrake. (Updated for
66 pnm2ppa-1.04 and later.)
77
8 MMaannddrraakkee--ssppeecciiffiicc iissssuueess..
8 Mandrake-specific issues.
99
1010 See the document INSTALL.REDHAT.html for installation and setup. That
1111 document is written for Red Hat; note the Mandrake-specific
1212 differences listed below,
1313
14 To update pnm2ppa in any recent Mandrake release (7.2 or later) from
15 v1.04 to v1.10, the simplest procedure may be just to compile pnm2ppa
16 from tarball source and replace the Mandake binaries /usr/bin/pnm2ppa
17 and /usr/bin/calibrate_ppa with the new versions. They should
18 function as drop-in replacements, with the same user interface, but
19 improved image quality. (You may also wish to use the newer
20 pnm2ppa.conf configuration file template).
1421
15 +o Mandrake 7.0 and earlier has incompatible and non-functional
22
23
24 o Mandrake 7.0 and earlier has incompatible and non-functional
1625 pnm2ppa support which must be replaced. Please use printtool to
1726 delete any installed PPA printers BEFORE upgrading rhs-
1827 printfilters. (If you forget to do this, and printtool will not
1928 start after the update, delete or move your /etc/printcap file.)
2029 Install the pnm2ppa RPM package. Then update rhs-printfilters with
2130 rhs-printfilters-1.58-4ppa5mdk.i386.rpm from
22 http://sourceforge.net/projects/pnm2ppa. (Do NNOOTT use rhs-
31 http://sourceforge.net/projects/pnm2ppa. (Do NOT use rhs-
2332 printfilters-1.57-4ppa4.i386.rpm which is for RedHat systems only.)
2433
25 +o Mandrake-7.1 supplies a pnm2ppa RPM and has support for it in rhs-
34 o Mandrake-7.1 supplies a pnm2ppa RPM and has support for it in rhs-
2635 printfilters. Mandrake 7.1 has a configuration tool DrakConf for
2736 setting up printers, which may be an interface to printtool. Some
2837 users have reported difficulties with this. In that case, just use
2938 printtool to configure the printer.
3039
31 +o Mandrake-7.2 does not have a separate pnm2ppa RPM package, but has
40 o Mandrake-7.2 does not have a separate pnm2ppa RPM package, but has
3241 added pnm2ppa to the ghostscript RPM package. This creates
3342 difficulties for updating pnm2ppa with the RPM package from
3443 http://sourceforge.net/projects/pnm2ppa. You will get reported
4150
4251
4352
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
00 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
11 <HTML>
22 <HEAD>
3 <META NAME="GENERATOR" CONTENT="SGML-Tools 1.0.9">
3 <META NAME="GENERATOR" CONTENT="LinuxDoc-Tools 0.9.16">
44 <TITLE>PPA Printer-Support RPM Packages for Red Hat Linux and Compatible Distributions</TITLE>
55
66
1313 <H1>PPA Printer-Support RPM Packages for Red Hat Linux and Compatible Distributions</H1>
1414
1515 <H2>The pnm2ppa project team
16 <A HREF="mailto:ppa-rpms@sourceforge.net">ppa-rpms@users.sourceforge.net</A></H2>v0.27, Nov 11, 2000
17 <P><HR>
16 <A HREF="mailto:ppa-rpms@sourceforge.net">ppa-rpms@users.sourceforge.net</A></H2>v0.30, July 9, 2002
17 <HR>
1818 <EM>Information and installation instructions
1919 to accompany pnm2ppa packages for Red Hat Linux available at
2020 <A HREF="http://sourceforge.net/projects/pnm2ppa">http://sourceforge.net/projects/pnm2ppa</A>
21 (Updated for pnm2ppa-1.04 and later.)
21 (Updated for pnm2ppa-1.10 and Red Hat 6.2 or later.)
2222 See the &quot;Troubleshooting&quot; section at the end of
2323 this document for
2424 fixes to some reported problems</EM>
2525 <HR>
26 <P><B> Overview of HP's PPA DeskJet Printers.</B>
26 <P><B> Overview of HP's PPA DeskJet Printers.</B></P>
2727 <P>Most of Hewlett-Packard's DeskJet(tm) printers use the PCL3 command language,
28 and are currently supported by Ghostscript drivers. However, a few models,
28 and are currently supported by Ghostscript drivers. However, a few legacy
29 models,
2930 namely
3031 <UL>
31 <LI> <EM>DeskJet 710C Series</EM>: HP DeskJet 710C, 712C</LI>
32 <LI> <EM>DeskJet 720C Series</EM>: HP DeskJet 720C, 722C</LI>
32 <LI> <EM>DeskJet 710C Series</EM>: HP DeskJet 710C, 712C
33 <EM>(discontinued)</EM></LI>
34 <LI> <EM>DeskJet 720C Series</EM>: HP DeskJet 720C, 722C
35 <EM>(discontinued)</EM></LI>
3336 <LI> <EM>DeskJet 820C Series</EM>: HP DeskJet 820Cxi, 820Cse
3437 <EM>(discontinued)</EM></LI>
3538 <LI> <EM>DeskJet 1000C Series</EM>: HP DeskJet 1000Cxi, 1000Cse
3639 <EM>(discontinued)</EM></LI>
3740 </UL>
41 </P>
3842 <P>feature &quot;Host-based&quot; printing,
3943 and use HP's proprietary
4044 PPA (<EM>Printer Performance Architecture</EM>) protocol,
4145 instead of PCL. The two models in each series are physically
4246 identical;
43 they just come with different bundled Windows software.
44 The 820C and 1000C series are discontinued at this time (January 2000).
47 they just came with different bundled Windows software.
48 All PPA printers are now discontinued from HP's product lines,
49 but may still be found as second-hand legacy items.</P>
4550 <P>PPA printers rely on software running on the
4651 host CPU to carry out the low-level processing
4752 of printer output that would be done by hardware in
4853 a standard PCL printer. The relation of PPA printers to PCL printers
4954 is analogous to the relation between &quot;Winmodems&quot; and true modems.
50 <P>Unfortunately, HP only supplies Windows software drivers for PPA printers,
55 Presumably, the idea at the time was that this would allow cheaper hardware
56 to be used, but the decline in hardware prices probably meant that
57 the savings were not significant, and PPA printing seems to have been
58 abandoned.</P>
59 <P>Unfortunately, HP only supplied Windows software drivers for PPA printers,
5160 and have indicated that it is unlikely that
5261 they will ever make the proprietary PPA specs public.
5362 This is apparently because of concerns that
5867 damage the printer by sending it
5968 bad sequences of PPA commands, which is not the case for PCL commands,
6069 and it seems that HP do not wish to take any responsibility for such damage by
61 encouraging unofficial PPA programming.)
62 <P>In fact,
63 the decline in hardware component prices has meant that the anticipated
64 cost-savings through using host-based PPA instead of printer-based PCL
65 are less than expected, and two of the PPA printer series
66 (820C, 1000C) have been phased out, and replaced by similar PCL printers
67 in HP's product line. The 710C and 720C series are still being sold
68 at this time of writing. <B> All other currently-offered
69 DeskJet models appear to be standard PCL3
70 printers.</B>
71 <P>
72 <P>Many Linux users may have inadvertently purchased PPA DeskJet models,
73 mistaking them for PCL3 DeskJets, for which independently-produced
74 Linux drivers have long
75 been available. Fortunately, a reverse engineering effort,
70 encouraging unofficial PPA programming.)</P>
71 <P>In the past, Linux users often inadvertently purchased PPA DeskJet models,
72 mistaking them for PCL3 DeskJets, which have traditionally
73 been well-supported
74 by Linux drivers.
75 Fortunately, a reverse engineering effort,
7676 started in 1998 by Tim Norman,
77 <A HREF="http://www.normsoft.com/ppa">http://www.normsoft.com/ppa</A>
77 and continued by the <EM>pnm2ppa</EM> project at
78 <A HREF="http://pnm2ppa.sourceforge.net">http://pnm2ppa.sourceforge.net</A>,
7879 and
79 <A HREF="http://pnm2ppa.sourceforge.net">http://pnm2ppa.sourceforge.net</A>,
80 and continued by the <EM>pnm2ppa</EM> project at
8180 <A HREF="http://sourceforge.net/projects/pnm2ppa">http://sourceforge.net/projects/pnm2ppa</A>
8281 has managed to produce drivers that provide basic printing
8382 functionality for these PPA printers under Linux and other
84 Unices.
85 <P>
86 <P>
87 <P>
88 <P><B> The pnm2ppa driver for color printing with PPA printers.</B>
83 Unices. While HP have recently begun to release their own Linux
84 drivers for PCL3 DeskJets, they have not included drivers for their legacy
85 PPA printers in this effort.</P>
86 <P>The <CODE>pnm2ppa</CODE> driver has been stable since v1.04, released
87 October 2000, with no known reproducible bugs, except that image printing
88 quality was not so good. This version has been distributed with
89 Red Hat, and other Linux distributions. v1.10, released July 2002,
90 contains a lot of changes that improve image quality, in particular
91 by improved bidirectional printing, and
92 always printing black on top of color.</P>
93 <P>A better improvement would be for someone to make a PPA backend to
94 <A HREF="http://gimp-print.sourceforge.net">gimp-print</A>, using
95 <CODE>pnm2ppa</CODE> as a guide for how to send data to PPA printers.
96 But, since PPA printers are now &quot;legacy&quot; hardware, and
97 <CODE>pnm2ppa</CODE> appears to
98 work fine for most printing tasks, it is unlikely that any new developers will
99 be interested in doing this, and there is currently no further development
100 anticipated. The project is currently in &quot;low-maintenance mode&quot;.</P>
101
102 <P><B> The pnm2ppa driver for color printing with PPA printers.</B></P>
89103 <P>Color printing with PPA printers is supported by the
90104 <EM><CODE>pnm2ppa</CODE></EM> driver which is the successor to the older
91105 black-and-white-only driver
92 <A HREF="http://pnm2ppa.sourceforge.net/files/pbm2ppa-0.8.6.tar.gz">pbm2ppa-0.8.6</A> developed by Tim Norman.
93 <P>
106 <A HREF="http://pnm2ppa.sourceforge.net/files/pbm2ppa-0.8.6.tar.gz">pbm2ppa-0.8.6</A> developed by Tim Norman. </P>
94107 <P><CODE>pnm2ppa</CODE>
95 can translate <EM>portable anymap</EM> (<EM>pnm</EM>)
108 translates <EM>portable anymap</EM> (<EM>pnm</EM>)
96109 format images into a stream of PPA instructions which can be sent to the
97110 printer. In the driver name,
98111 &quot;<EM>pnm</EM>&quot; stands for the superset
99112 of <EM>three</EM> image formats:
100113 <EM>ppm</EM> (portable &quot;pixmap&quot; format for color images),
101114 <EM>pgm</EM> (portable &quot;greymap&quot; format for greyscale images),
102 and <EM>pbm</EM> (portable &quot;bitmap&quot; format for black and white images).
115 and <EM>pbm</EM> (portable &quot;bitmap&quot; format for black and white images).</P>
103116 <P>Ghostscript has a number of &quot;output devices&quot; that
104117 produce pnm format output from postscript or pdf input.
105118 These come in <EM>plain</EM> (text) and <EM>raw</EM>
118131 The last two output devices are switches that try to analyze the
119132 image, and select an appropriate format; however, they are not
120133 recommended for routine use, as they may inconsistently choose the format.
121 The <CODE>ghostscript-5.10</CODE>
122 package supplied with Red Hat 6.x distributions provides all these
123 devices; older versions may not. To see the list of available
134 The <CODE>ghostscript</CODE>
135 packages supplied with all recent Red Hat distributions provides all these
136 devices. To see the list of available
124137 ghostscript output devices, type the command line
125138 <BLOCKQUOTE><CODE>
126139 <PRE>
130143
131144 if the required <CODE>ppmraw</CODE> or
132145 <CODE>pbmraw</CODE> devices are not shown, you will have to upgrade your
133 version of ghostscript.
146 version of ghostscript.</P>
134147 <P>The data must be streamed directly from ghostscript to
135148 <CODE>pnm2ppa</CODE> to the (local) printer without being
136149 stored in any intermediate
137150 file: one ppm-format (color) US Letter size page is represented
138151 by 3x5100x6600 Bytes (100MB) in binary format and four times this amount in
139 text format.
140 <P>
152 text format. </P>
153
141154 <P>An example of
142155 a command line for printing a postscript
143156 file <CODE>file.ps</CODE> using <CODE>gs</CODE> (ghostscript) and <CODE>pnm2ppa</CODE> is
157170 The <CODE>pnm2ppa</CODE> option <CODE>--eco</CODE> specifies &quot;EconoFast&quot;
158171 mode, for a lower quality output which uses less ink, and prints faster,
159172 and <CODE>-v 720</CODE> specifies the PPA printer as belonging
160 to the DeskJet 720C series.
173 to the DeskJet 720C series.</P>
161174 <P>
175 <UL>
176 <LI> <CODE>pnm2ppa</CODE> expects that the input resolution is 600dpi
177 (or 300dpi if it is called with the <CODE>pnm2ppa --dpi300 ...</CODE>option).
178 This corresponds to the <CODE>gs -r600 ...</CODE> or
179 <CODE>gs -r300 ... </CODE> ghostscript options.
180 If other higher/lower input resolutions are used, the size of
181 the printed image will be larger/smaller, provided it is
182 within the printer's allowed size range.</LI>
183 </UL>
184 </P>
162185 <P>Obviously, it would be impractical to type such a command each time
163 one wished to print something, so in addition to the <CODE>pnm2ppa</CODE>
164 driver itself, an enhanced version of Red Hat's <CODE>rhs-printfilters</CODE>
165 RPM package is provided; after this is installed, the PPA printer
166 can be managed like other standard printers with the Red Hat
167 <CODE>printtool</CODE> utility. The postscript file can then be printed with
186 one wished to print something, and since RedHat 6.2, printfilter
187 support for <CODE>pnm2ppa</CODE> is built into Red Hat's printer
188 configuration scheme, so after configuration,
168189 the simple command
169190 <BLOCKQUOTE><CODE>
170191 <PRE>
171192 lpr file.ps
172193 </PRE>
173194 </CODE></BLOCKQUOTE>
174 <P>
175 <UL>
176 <LI><EM>However, if you wish to print to paper sizes supported by ghostscript,
177 but not supported by the Red Hat <CODE>printtool</CODE> utility, you can
195
196 should successfully print a postscript file.
197 However, in case you wish to check if something
198 is misconfigured in the print filters, you can use a script like the
199 above one to bypass them and check that the printer is working.
200 <UL>
201 <LI><EM>Also, if you wish to print to paper sizes supported by ghostscript,
202 but not supported by the Red Hat Printer configuration utilities, you can
178203 use scripts like the one above.
179204 The HP 710C, 720C, and 820C series support paper sizes from
180205 3&quot;x3&quot; to 8.5&quot;x14&quot;, while the 1000C
181206 supports 4&quot;x6&quot; to 13&quot;x19&quot;.</EM></LI>
182207 </UL>
183 <P>
208 </P>
209
184210 <P><B> Available RPM packages.</B>
185 <P>A RPM package for <CODE>pnm2ppa</CODE> is part of the Red Hat Linux
211 A RPM package for <CODE>pnm2ppa</CODE> is part of the Red Hat Linux
186212 distribution starting with Red Hat 6.2.
187213 You will also find a RPM package for the latest release of
188214 <CODE>pnm2ppa</CODE>
189215 at
190 <A HREF="http://sourceforge.net/projects/pnm2ppa">http://sourceforge.net/projects/pnm2ppa</A>.
216 <A HREF="http://sourceforge.net/projects/pnm2ppa">http://sourceforge.net/projects/pnm2ppa</A>. </P>
191217 <P>The latest version at the time
192218 of writing is
193 <CODE>pnm2ppa-1.04-1.i386.rpm</CODE>, and is built on
194 Red Hat 6.2. If you are running a different release
219 <CODE>pnm2ppa-1.10-1rh7x.i386.rpm</CODE>, and is built on
220 Red Hat 7.3, or
221 <CODE>pnm2ppa-1.10-1rh62.i386.rpm</CODE>, built on
222 Red Hat 6.2.
223 If you are running a different release
195224 of Red Hat (or a different Linux distribution)
196225 you may need to download and rebuild the source RPM
197 <CODE>pnm2ppa-1.04-1.src.rpm</CODE> instead:
198 <BLOCKQUOTE><CODE>
199 <PRE>
200 rpm --rebuild pnm2ppa-1.04-1.src.rpm
226 <CODE>pnm2ppa-1.10-1.src.rpm</CODE> instead:
227 <BLOCKQUOTE><CODE>
228 <PRE>
229 rpm --rebuild pnm2ppa-1.10-1.src.rpm
201230 </PRE>
202231 </CODE></BLOCKQUOTE>
203232
204233 (You must be <CODE>root</CODE> to do this, and have the necessary
205234 compilers installed; on Red Hat, the rebuilt binary RPM will be created in
206 the directory <CODE>/usr/src/redhat/RPMS/i386/</CODE>.)
235 the directory <CODE>/usr/src/redhat/RPMS/i386/</CODE>.)</P>
207236 <P>Red Hat 6.2 and later also includes support for configuring your
208 printer to use <CODE>pnm2ppa</CODE> using <CODE>printtool</CODE>
209 and <CODE>rhs-printfilters</CODE>.
210 If you are using Red Hat 6.1 and earlier,you will need to
211 update the <CODE>rhs-printfilters</CODE> that came with the distribution
212 to the
213 <CODE>rhs-printfilters-1.57-4ppa4.i386.rpm</CODE> also available at
214 <A HREF="http://sourceforge.net/projects/pnm2ppa">http://sourceforge.net/projects/pnm2ppa</A>.
215 (This is designed to work only with <CODE>printtool-3.43</CODE> and earlier.)
216 <P>
217 <P>Note: If you are using Red Hat 6.2, you may wish to update the
218 print filter support that it comes with. The <CODE>pnm2ppa-1.04-1</CODE>
237 printer to use <CODE>pnm2ppa</CODE>.
238 (Information necessary for configuring
239 <CODE>pnm2ppa</CODE> on older Red Hat releases has been removed from
240 this document; for this, see the documentation that came with
241 <CODE>pnm2ppa-1.04</CODE>, or update your RedHat distribution.)
242 Note: If you are still using Red Hat 6.2, you may wish to update the
243 print filter support for <CODE>pnm2ppa</CODE> that comes with it.
244 The <CODE>pnm2ppa-1.10-1rh62*</CODE>
219245 RPM package supplies the necessary files that you can use.
220246 After installing this RPM, see
221 <CODE>/usr/lib/rhs/rhs-printfilters/README.ppa</CODE> for details.
222 <P>
223 <P><B> Installing the <CODE>pnm2ppa</CODE> RPM package and setting up the PPA printer.</B>
247 <CODE>/usr/lib/rhs/rhs-printfilters/README.ppa</CODE> for details.</P>
248
249 <P><B> Installing the <CODE>pnm2ppa</CODE> RPM package and setting up the PPA printer.</B></P>
224250 <P>To install the RPM package, you must log in as the system administrator,
225 <CODE>root</CODE>.
251 <CODE>root</CODE>. </P>
226252 <P>Now begin the installation. First install the <CODE>pnm2ppa</CODE> RPM:
227253 <BLOCKQUOTE><CODE>
228254 <PRE>
229 rpm -Uvh pnm2ppa-1.04-1.i386.rpm
230 </PRE>
231 </CODE></BLOCKQUOTE>
232
233 The <CODE>pnm2ppa</CODE> executable gets installed in <CODE>/usr/bin/</CODE>.
234 <P>If you are using a 2.2.x kernel,
235 (e.g. Red Hat 6.x)
236 it will be able to autodetect
255 rpm -Uvh pnm2ppa-1.10-1*.i386.rpm
256 </PRE>
257 </CODE></BLOCKQUOTE>
258
259 The <CODE>pnm2ppa</CODE> executable gets installed in <CODE>/usr/bin/</CODE>.</P>
260 <P>The Linux kernel will be able to autodetect
237261 IEEE-1284 devices like PPA printers, provided they are attached
238262 to the parallel port with a bidirectional IEEE-1284 cable. (If your
239263 printer works under Windows, you have the correct cable.)
240 (Note that older (2.0.x) kernels do not have this autoprobe facility.)
241264 A script <CODE>detect_ppa</CODE> is provided by the <CODE>pnm2ppa</CODE>
242265 RPM: just type
243266 <BLOCKQUOTE><CODE>
247270 </CODE></BLOCKQUOTE>
248271
249272 to confirm that your Printer is found.
250 <P>It is possible (especially on Red Hat 6.1) that you will have to add
251 a line
252 <BLOCKQUOTE><CODE>
253 <PRE>
254 alias parport_lowlevel parport_pc
255 </PRE>
256 </CODE></BLOCKQUOTE>
257
258 to the file <CODE>/etc/conf.modules</CODE> for the printer to be found (this is
259 a parallel port recognition issue, not specific to PPA printers.
260 and a known &quot;gotcha&quot; on Red Hat 6.1).
261273 A typical message from the printer, which will
262274 be displayed if autodetection is successful, is:
263275 <BLOCKQUOTE><CODE>
271283 </CODE></BLOCKQUOTE>
272284
273285 A list of PPA printers found, and the parallel ports to which they are
274 attached, will also be shown.
275 <P>
286 attached, will also be shown.</P>
287
276288 <P>At this point it is useful to test that your printer is working, by
277289 printing a test page using the supplied script <CODE>test_ppa</CODE>
278290 which the RPM has installed. You will need to know your
279291 printer model (710, 712, 720, 722, 820, 1000), your paper size
280292 (letter, legal, a4) and the printer port the printer is attached to.
281293 If it is attached to the primary parallel port, this is
282 <EM><CODE>/dev/lp1</CODE></EM> under older 2.0.x kernels, and (usually)
283 <EM><CODE>/dev/lp0</CODE></EM> under newer 2.2.x kernels, as in Red Hat 6.x.
294 (usually) <EM><CODE>/dev/lp0</CODE></EM>.
284295 Type
285296 <BLOCKQUOTE><CODE>
286297 <PRE>
296307 <UL>
297308 <LI> <EM><EM>Tip:</EM>
298309 The </EM><CODE>test_ppa</CODE><EM> script
299 does not use the print filters that
300 will be installed by the </EM><CODE>rhs-printfilters</CODE><EM> RPM, so it is
310 does not use the Red Hat print filters, so it is
301311 useful when troubleshooting, for testing if any printing problems are
302312 associated with the basic printer installation, or with the
303313 configuration of the print filters.</EM></LI>
304314 </UL>
305 <P>
306 <P><B> Installing the PPA-enhanced <CODE>rhs-printfilters</CODE> RPM package (if needed).</B>
307 <P>
308 <UL>
309 <LI><EM>This step is NOT needed on Red Hat 6.2 or later.</EM></LI>
310 </UL>
311 <P>The <CODE>rhs-printfilters</CODE> rpm distributed with
312 Red Hat 6.1 does not support <CODE>pnm2ppa</CODE>,
313 If you use an older distribution, you will first have to replace their
314 <CODE>rhs-printfilters</CODE> RPM with the PPA-enhanced version from the
315 pnm2ppa project.
316 <P>Once you have confirmed you have a working printer, install the
317 RPM <CODE>rhs-printfilters-1.57-4ppa4.i386.rpm</CODE>
318 <BLOCKQUOTE><CODE>
319 <PRE>
320 rpm -Uvh rhs-printfilters-1.57-4ppa4.i386.rpm
321 </PRE>
322 </CODE></BLOCKQUOTE>
323 <P><B> Configuring the print filters with <CODE>printtool</CODE>.</B>
324 <P>Now start the &quot;<EM>Red Hat Linux Print System Manager</EM>&quot;
315 </P>
316
317 <P><B> Configuring the print filters.</B></P>
318 <P>Note: Red Hat 7.3 now features either CUPS or LPRng printer management.
319 The configuration tools should be able to configure <CODE>pnm2ppa</CODE>,
320 using the information about it taken from the Linux Printer Database.
321 Apart from the addition of a new <CODE>--dpi300</CODE> option
322 to accept 300dpi input (useful for printing PNM output from 300dpi scanners),
323 there have been no changes in the pnm2ppa command line since the pnm2ppa-1.0
324 release, so the configuration scripts are stable. (They
325 can only use the default 600dpi input mode.)</P>
326 <P>Since Red Hat 7.1, there is a graphical
327 printer configuration utility <CODE>printconf-gui</CODE>. In Red Hat 6.2 and
328 7.0, the older configuration utility called <CODE>printtool</CODE> is used.
329 In either case,
330 start the &quot;<EM>Red Hat Linux Print System Manager</EM>&quot;
325331 (as root) to
326332 configure the printer, either
327 by clicking on the printer icon in Red Hat's &quot;control-panel&quot;, or just
328 typing
333 by clicking on the printer icon in Red Hat's &quot;control-panel&quot;,
334 or just typing
329335 <BLOCKQUOTE><CODE>
330336 <PRE>
331337 printtool
332338 </PRE>
333339 </CODE></BLOCKQUOTE>
334340
335 In the Print System Manager window, click on <EM>Add</EM>, then
341 which also starts <CODE>printconf-gui</CODE> in the newer Red Hat releases.</P>
342
343 <P><B> Configuring the print filters with the Red Hat 6.2/7.0 printtool</B></P>
344 <P>(Skip this section unless you are still using Red Hat 6.2 or 7.0)</P>
345 <P>The following description is for the older <CODE>printtool</CODE> that
346 is used by Red Hat 6.2/7.0. The printer configuration utility
347 <CODE>printconf-gui</CODE> for Red Hat 7.1 and later
348 is a little different, as it is based on the <EM>foomatic</EM> printer
349 configuration database which contains entries for <CODE>pnm2ppa</CODE>
350 (but not the older <CODE>pbm2ppa</CODE>). You should be able to easily figure out
351 what to do: it can configure all <CODE>pnm2ppa</CODE> command-line options in the
352 <EM>Driver Options</EM> screen.</P>
353 <P>In the Red Hat 6.2/7.0 Print System Manager window, click on <EM>Add</EM>, then
336354 in the &quot;Add a Printer Entry&quot;, select <EM>Local Printer</EM>, and
337355 click <EM>Ok</EM>. Hopefully, the port on which the printer is attached
338356 will be listed as &quot;Detected&quot; (<EM>if not,
339357 fix the problem before continuing</EM>, perhaps by
340358 adding the line &quot;<CODE>alias parport_lowlevel parport_pc</CODE>&quot;
341 to <CODE>/etc/conf.modules</CODE>), as mentioned above.
359 to <CODE>/etc/conf.modules</CODE>).
342360 You will now have to &quot;<EM>edit
343361 the local printer entry</EM>&quot; for the PPA printer. Click on
344362 <EM>Select</EM> to chose the &quot;Input filter&quot;.
348366 <UL>
349367 <LI><B>HP DeskJet 1000 series (PPA)</B> (for 1000Cse, 1000Cxi models)</LI>
350368 <LI><B>HP DeskJet 710/720 series (PPA)</B> (for 710C, 712C, 720C, 722C models)</LI>
351 <LI><B>HP DeskJet 820 series (PPA)</B> (for 820Cse, 820Cxi models)
352 <UL>
353 <LI> If these entries do not show up, it may be because the older
354 <CODE>rhs-printfilters</CODE> package that you updated did not allow
355 the printer database <CODE>/usr/lib/rhs/rhs-printfilters/printerdb</CODE>
356 to be replaced. Try deleting or renaming the <CODE>printerdb</CODE>
357 file, and then reinstall
358 the PPA-enhanced <CODE>rhs-printfilters</CODE> RPM using
359 &quot;<CODE>rpm --force -Uvh rhs-printfilters*</CODE>&quot; </LI>
360 </UL>
361 </LI>
362 </UL>
363 <P>
364 <P>Select the appropriate
369 <LI><B>HP DeskJet 820 series (PPA)</B> (for 820Cse, 820Cxi models)</LI>
370 </UL>
371
372 Select the appropriate
365373 entry for your printer model. You will then be presented with
366374 various options:
367375 <UL>
451459 When you have made your choices, click on <EM>Ok</EM> to
452460 save your selections and close the &quot;Configure Filter&quot; screen,
453461 and then click on <EM>OK</EM> to close the &quot;Edit Local Printer Entry&quot;
454 screen.
462 screen.</P>
455463 <P>You are now back in the &quot;Red Hat Print System Manager&quot; screen;
456464 highlight the printer you just configured, and, in the <EM>Tests</EM>
457465 menu, choose <EM>Print Postscript test page</EM> to print a test page using
458466 the Red Hat print filters. If this printed correctly, your
459467 print system is set up to use the PPA printer, just like any of the other
460 printers that the Red Hat print filters support.
461 <P>
462 <P>
463 <P>
464 <P><B> Configuring pnm2ppa.conf and calibrating the printer. </B>
468 printers that the Red Hat print filters support.</P>
469
470
471
472 <P><B> Configuring pnm2ppa.conf and calibrating the printer. </B></P>
465473 <P>A number of printer parameters are set to reasonable default values
466474 for each of the printer models, but you may wish to &quot;fine tune&quot;
467475 or calibrate your printer. The default values can be overridden
468476 by entries in the configuration files, which by default are
469477 <CODE>/etc/pnm2ppa.conf</CODE> and <CODE>/etc/pbm2ppa.conf</CODE>.
470 At 600dpi, one pixel is 1/600 inch.
478 At 600dpi, one pixel is 1/600 inch. </P>
471479 <P>The user-adjustable parameters are:
472480 <UL>
473481 <LI> <B>verbose 1</B> and <B>silent 1</B>. These control
567575 can be used to switch of the various inks; this can be useful
568576 in troubleshooting and debugging <CODE>pnm2ppa</CODE>.</LI>
569577 </UL>
578 </P>
570579 <P>Use <CODE>test_ppa</CODE> to print various test pages
571 or calibration patterns to adjust the offsets.
580 or calibration patterns to adjust the offsets. </P>
572581 <P>If you wish to specify these
573582 parameters using the command-line options
574 described above, some of them can be
583 described above, in Red Hat 6.2/7.0 some of them can be
575584 entered in the &quot;extra GS options&quot; box using the Print System Manager
576585 (<CODE>printtool</CODE>), as described above.
577 <P>
578 <P>
579 <P><B> Utility programs for the printer.</B>
586 In Red Hat 7.1 and later, all command-line options can be set using the new
587 <CODE>printconf-gui</CODE> utility.</P>
588
589 <P><B> Utility programs for the printer.</B></P>
580590 <P>HP's Windows software provides a utility program
581591 that sends PPA commands to tell the printer to perform
582 taks like cleaning the printheads, etc. The codes for some
583 of these functions have already been reverse engineered.
584 There are proposals to add support for PPA printers to the
592 tasks like cleaning the printheads, etc. </P>
593 <P>On Red Hat Linux, You can use <CODE>test_ppa</CODE>
594 (which acts as a command-line front-end for
595 <CODE>calibrate_ppa</CODE>) to print head-cleaning patterns.</P>
596 <P>There is a graphical (gtk-based) tool
597 written by Javier Sedano
598 for creating
599 a <CODE>pnm2ppa.conf</CODE> file and acting as a front end to
600 <CODE>calibrate_ppa</CODE>.
601 This is called <CODE>ppaSet</CODE>, and a beta version of it can be found
602 in the same place as the <CODE>pnm2ppa-1.10</CODE> distribution
603 at
604 <A HREF="http://sourceforge.net/projects/pnm2ppa">http://sourceforge.net/projects/pnm2ppa</A></P>
605 <P>There was also at one time a proposal to add support for PPA printers to the
585606 PUP (Printer Utility Program) utility, which is
586607 also a project at
587608 <A HREF="http://www.sourceforge.net/project/?group_id=1118">http://www.sourceforge.net</A>.
588609 However, as of the time of writing, no PUP support
589 for PPA printers is available (volunteers, anyone?).
590 <P>
591 <P><B>Troubleshooting</B>
610 for PPA printers is available.</P>
611
612 <P><B>Troubleshooting</B></P>
592613 <P>The first thing to do is to look at the messages from <CODE>pnm2ppa</CODE>
593614 in the system log to see what is happening, whether <CODE>pnm2ppa</CODE>
594615 <B>actually received any input</B>, and if it was valid.
595616 <B> (You may need to enable system log messages in
596617 <CODE>/etc/pnm2ppa.conf</CODE>, see above.)</B>
597618 Maybe ghostscript failed to convert your postscript file into
598 PNM format: this is <B>not</B> a <CODE>pnm2ppa</CODE> problem!
599 Here are suggestions for dealing with problems that you may encounter.
619 PNM format: in that case the system log reports
620 <B>&quot;Fatal Error! Input image (pnm2ppa) is not a PNM image&quot;</B>.
621 (note: when this occured, older versions of <CODE>pnm2ppa</CODE> reported
622 <B>&quot;Input image is not a supported PNM format&quot;</B> which
623 may have been confusing).
624 This is because the input received by <CODE>pnm2ppa</CODE> was not a valid
625 PNM image, but instead ghostscript failed to produce any
626 PNM output at all, and its only output was probably just an error message.
627 This is <EM>not</EM> a <CODE>pnm2ppa</CODE> problem!</P>
628 <P>Here are suggestions for dealing with other problems that you may encounter.
600629 <UL>
601630 <LI><B> Printing fails in the middle of a print run</B>, perhaps
602631 when a figure embedded in the document is printing (in the latest
605634 reports that <CODE>read_line</CODE> could not read the image, and found EOF
606635 (end-of-file). This probably
607636 means that <CODE>ghostscript</CODE>'s &quot;ppmraw&quot; or
608 &quot;pgmraw&quot; output device failed for some reason,
609 usually leaving a core dump, without completing the
610 translation of the postscript to a pnm format.
637 &quot;pgmraw&quot; output device started correctly, but
638 failed for some reason before finishing the image conversion
639 from postscript to PNM format, usually leaving a core dump.
611640 (This has been seen to happen in ghostscript 5.10 ;
612641 upgrading to ghostscript 5.50 solved the problem.) If you cannot
613642 upgrade, try printing the document
614643 in black-and-white using the ghostscript &quot;pbmraw&quot; output device.</LI>
615 <LI><B>The <CODE>test_ppa</CODE> script works,
616 but you can't get <CODE>printtool</CODE> to make the printfilters work.</B>
617
618 You installed <CODE>pnm2ppa-1.0</CODE> and the PPA-enhanced
619 <CODE>rhs-printfilters</CODE> (earlier than v. 1.61) from the pnm2ppa
620 SourceForge page. You are using <CODE> printtool</CODE> v. 3.43 or earlier
621 and are probably a Mandrake user.
622 Solution: (a) use <CODE>printtool </CODE> to uninstall the PPA printer;
623 (b) delete (or rename) the printer database
624 <CODE>/usr/lib/rhs/rhs-printfilters/printerdb</CODE>, and reinstall
625 the <CODE>rhs-printfilters</CODE> RPM using the
626 &quot;<CODE>rpm --force ... </CODE>&quot;
627 option; (c) use <CODE>printtool</CODE> to add the
628 PPA printer again.
629 (Your previously-installed <CODE>rhs-printfilters</CODE> may have
630 resisted replacement of its <CODE>printerdb</CODE>).</LI>
631 <LI><B>You upgraded your RedHat (or compatible) Linux distribution
632 and your printfilters no longer work</B>.
633 You used to use a PPA-enhanced <CODE>rhs-printfilters</CODE> from the
634 pnm2ppa SourceForge site. You
635 upgraded your distribution to one using <CODE>printtool</CODE> v 3.44 or later
636 (e.g. RedHat 6.2).
637 Solution: Make sure that
638 <CODE>rhs-printfilters</CODE> has been updated to a version
639 1.61 or greater that came with your
640 upgraded distribution.
641 Use <CODE>printtool</CODE> to delete, and then add the
642 PPA printer
643 This will create a new printer configuration compatible
644 with your upgraded distribution.</LI>
645644 <LI><B>You printed an image file using a &quot;high quality&quot;
646645 printer setting, but it has visible horizontal lines
647646 on it </B>and printing under Windows(tm) 9x doesn't
649648 These are probably &quot;swath boundaries&quot;,
650649 showing the junction between different sweeps of the print head.
651650 Solution: using unidirectional printing (PPA option <CODE>--uni</CODE>,
652 or <CODE>unimode 1</CODE> in <CODE>/etc/pnm2ppa.conf</CODE>) helps a little, but
653 this problem requires an extensive
654 rewrite of part of pnm2ppa (<CODE>cutswath.c</CODE>)
655 for a satisfactory solution. (Volunteers welcome - see the TODO file in the
656 pnm2ppa docs (<CODE>/usr/doc/pnm2ppa*/TODO</CODE>)!) </LI>
651 or <CODE>unimode 1</CODE> in <CODE>/etc/pnm2ppa.conf</CODE>) helps a little.
652 <B>this problem is fixed in the pnm2ppa-1.10 release</B></LI>
657653 <LI>&quot;<B>Flashing light syndrome</B> &quot;.
658654 Your printer usually works, but you have found that some particular
659655 documents cause the printer to fail, and the lights on its panel
682678 <CODE>/etc/pnm2ppa.gamma</CODE>. See the file
683679 <A HREF="./COLOR.html">COLOR.html</A> (or COLOR.txt) for more information.</LI>
684680 </UL>
685
686 <P>
687 <P><B>Contacting the pnm2ppa project.</B>
681 </P>
682
683 <P><B>Contacting the pnm2ppa project.</B></P>
688684 <P>Send comments or corrections (about this document or the RPMS) to:
689 <A HREF="mailto:ppa-rpms@sourceforge.net">ppa-rpms@users.sourceforge.net</A><P>There are three mailing lists,
690 <EM>ppa.announce</EM> (announcements),
691 <EM>ppa.users</EM> (users helping users)
692 and <EM>ppa.devel</EM> (developers).
685 <A HREF="mailto:ppa-rpms@sourceforge.net">ppa-rpms@users.sourceforge.net</A></P>
686 <P>There are three mailing lists,
687 <EM>pnm2ppa-announce@lists.sourceforge.net</EM> (announcements),
688 <EM>pnm2ppa-users@lists.sourceforge.net</EM> (users helping users)
689 and <EM>pnm2ppa-devel@lists.sourceforge.net</EM> (developers).
693690 You can subscribe to them, or browse their
694691 archives, at
695 <A HREF="http://pnm2ppa.sourceforge.net">http://pnm2ppa.sourceforge.net/maillist.htm</A>.
696 <P>To contact the developers, subscribe to <EM>ppa.devel</EM> and post a message.
692 <A HREF="http://sourceforge.net/projects/pnm2ppa">http://sourceforge.net/projects/pnm2ppa</A>.
693 (The older pnm2ppa mailing lists died with the ListBot service)</P>
694 <P>To contact the developers, subscribe to <EM>ppa.devel</EM> and post a message.</P>
697695 <P>There are Public Forums for posting questions
698696 and comments
699697 at
700698 <A HREF="http://sourceforge.net/projects/pnm2ppa">http://sourceforge.net/projects/pnm2ppa</A>
701699 (but whether you get any help from these, depends on
702 whether anyone is reading them).
703 <P>
700 whether anyone is reading them (unlikely!)). </P>
701
704702 <HR>
705703 Next
706704 Previous
00 PPA Printer-Support RPM Packages for Red Hat Linux and Com-
11 patible Distributions
22 The pnm2ppa project team ppa-rpms@users.sourceforge.net
3 v0.27, Nov 11, 2000
3 v0.30, July 9, 2002
44
55 Information and installation instructions to accompany pnm2ppa pack-
66 ages for Red Hat Linux available at http://sourceforge.net/pro-
7 jects/pnm2ppa (Updated for pnm2ppa-1.04 and later.) See the "Trou-
8 bleshooting" section at the end of this document for fixes to some
9 reported problems
10
11 OOvveerrvviieeww ooff HHPP''ss PPPPAA DDeesskkJJeett PPrriinntteerrss..
7 jects/pnm2ppa (Updated for pnm2ppa-1.10 and Red Hat 6.2 or later.)
8 See the "Troubleshooting" section at the end of this document for
9 fixes to some reported problems
10
11 Overview of HP's PPA DeskJet Printers.
1212
1313 Most of Hewlett-Packard's DeskJet(tm) printers use the PCL3 command
1414 language, and are currently supported by Ghostscript drivers.
15 However, a few models, namely
16
17 +o _D_e_s_k_J_e_t _7_1_0_C _S_e_r_i_e_s: HP DeskJet 710C, 712C
18
19 +o _D_e_s_k_J_e_t _7_2_0_C _S_e_r_i_e_s: HP DeskJet 720C, 722C
20
21 +o _D_e_s_k_J_e_t _8_2_0_C _S_e_r_i_e_s: HP DeskJet 820Cxi, 820Cse _(_d_i_s_c_o_n_t_i_n_u_e_d_)
22
23 +o _D_e_s_k_J_e_t _1_0_0_0_C _S_e_r_i_e_s: HP DeskJet 1000Cxi, 1000Cse _(_d_i_s_c_o_n_t_i_n_u_e_d_)
24
25 feature "Host-based" printing, and use HP's proprietary PPA (_P_r_i_n_t_e_r
26 _P_e_r_f_o_r_m_a_n_c_e _A_r_c_h_i_t_e_c_t_u_r_e) protocol, instead of PCL. The two models
27 in each series are physically identical; they just come with different
28 bundled Windows software. The 820C and 1000C series are discontinued
29 at this time (January 2000).
15 However, a few legacy models, namely
16
17 o DeskJet 710C Series: HP DeskJet 710C, 712C (discontinued)
18
19 o DeskJet 720C Series: HP DeskJet 720C, 722C (discontinued)
20
21 o DeskJet 820C Series: HP DeskJet 820Cxi, 820Cse (discontinued)
22
23 o DeskJet 1000C Series: HP DeskJet 1000Cxi, 1000Cse (discontinued)
24
25 feature "Host-based" printing, and use HP's proprietary PPA (Printer
26 Performance Architecture) protocol, instead of PCL. The two models
27 in each series are physically identical; they just came with different
28 bundled Windows software. All PPA printers are now discontinued from
29 HP's product lines, but may still be found as second-hand legacy
30 items.
3031
3132 PPA printers rely on software running on the host CPU to carry out the
3233 low-level processing of printer output that would be done by hardware
3334 in a standard PCL printer. The relation of PPA printers to PCL
3435 printers is analogous to the relation between "Winmodems" and true
35 modems.
36
37 Unfortunately, HP only supplies Windows software drivers for PPA
36 modems. Presumably, the idea at the time was that this would allow
37 cheaper hardware to be used, but the decline in hardware prices
38 probably meant that the savings were not significant, and PPA printing
39 seems to have been abandoned.
40
41 Unfortunately, HP only supplied Windows software drivers for PPA
3842 printers, and have indicated that it is unlikely that they will ever
3943 make the proprietary PPA specs public. This is apparently because of
4044 concerns that publication of the specs might reveal crucial details of
4549 responsibility for such damage by encouraging unofficial PPA
4650 programming.)
4751
48 In fact, the decline in hardware component prices has meant that the
49 anticipated cost-savings through using host-based PPA instead of
50 printer-based PCL are less than expected, and two of the PPA printer
51 series (820C, 1000C) have been phased out, and replaced by similar PCL
52 printers in HP's product line. The 710C and 720C series are still
53 being sold at this time of writing. AAllll ootthheerr ccuurrrreennttllyy--ooffffeerreedd
54 DDeesskkJJeett mmooddeellss aappppeeaarr ttoo bbee ssttaannddaarrdd PPCCLL33 pprriinntteerrss..
55
56
57 Many Linux users may have inadvertently purchased PPA DeskJet models,
58 mistaking them for PCL3 DeskJets, for which independently-produced
59 Linux drivers have long been available. Fortunately, a reverse
60 engineering effort, started in 1998 by Tim Norman,
61 http://www.normsoft.com/ppa and http://pnm2ppa.sourceforge.net, and
62 continued by the _p_n_m_2_p_p_a project at
52 In the past, Linux users often inadvertently purchased PPA DeskJet
53 models, mistaking them for PCL3 DeskJets, which have traditionally
54 been well-supported by Linux drivers. Fortunately, a reverse
55 engineering effort, started in 1998 by Tim Norman, and continued by
56 the pnm2ppa project at http://pnm2ppa.sourceforge.net, and
6357 http://sourceforge.net/projects/pnm2ppa has managed to produce drivers
6458 that provide basic printing functionality for these PPA printers under
65 Linux and other Unices.
66 TThhee ppnnmm22ppppaa ddrriivveerr ffoorr ccoolloorr pprriinnttiinngg wwiitthh PPPPAA pprriinntteerrss..
59 Linux and other Unices. While HP have recently begun to release their
60 own Linux drivers for PCL3 DeskJets, they have not included drivers
61 for their legacy PPA printers in this effort.
62
63 The pnm2ppa driver has been stable since v1.04, released October
64 2000, with no known reproducible bugs, except that image printing
65 quality was not so good. This version has been distributed with Red
66 Hat, and other Linux distributions. v1.10, released July 2002,
67 contains a lot of changes that improve image quality, in particular by
68 improved bidirectional printing, and always printing black on top of
69 color.
70
71 A better improvement would be for someone to make a PPA backend to
72 gimp-print, using pnm2ppa as a guide for how to send data to PPA
73 printers. But, since PPA printers are now "legacy" hardware, and
74 pnm2ppa appears to work fine for most printing tasks, it is unlikely
75 that any new developers will be interested in doing this, and there is
76 currently no further development anticipated. The project is
77 currently in "low-maintenance mode".
78
79
80 The pnm2ppa driver for color printing with PPA printers.
6781
6882 Color printing with PPA printers is supported by the pnm2ppa driver
6983 which is the successor to the older black-and-white-only driver
7084 pbm2ppa-0.8.6 developed by Tim Norman.
7185
72
73 pnm2ppa can translate _p_o_r_t_a_b_l_e _a_n_y_m_a_p (_p_n_m) format images into a
74 stream of PPA instructions which can be sent to the printer. In the
75 driver name, "_p_n_m" stands for the superset of _t_h_r_e_e image formats: _p_p_m
76 (portable "pixmap" format for color images), _p_g_m (portable "greymap"
77 format for greyscale images), and _p_b_m (portable "bitmap" format for
86 pnm2ppa translates portable anymap (pnm) format images into a stream
87 of PPA instructions which can be sent to the printer. In the driver
88 name, "pnm" stands for the superset of three image formats: ppm
89 (portable "pixmap" format for color images), pgm (portable "greymap"
90 format for greyscale images), and pbm (portable "bitmap" format for
7891 black and white images).
7992
8093 Ghostscript has a number of "output devices" that produce pnm format
81 output from postscript or pdf input. These come in _p_l_a_i_n (text) and
82 _r_a_w (binary) variants. While pnm2ppa can now interpret both plain and
94 output from postscript or pdf input. These come in plain (text) and
95 raw (binary) variants. While pnm2ppa can now interpret both plain and
8396 raw pnm formats, there is no point in using the inefficient plain
84 formats: _a_l_w_a_y_s use the "raw" output devices, which are:
85
86 +o _p_p_m_r_a_w - raw pixmap format (color images);
87
88 +o _p_g_m_r_a_w - raw greymap format (greyscale images);
89
90 +o _p_b_m_r_a_w - raw bitmap format (black and white images);
91
92 +o _p_n_m_r_a_w - selects between ppm, pgm, and pbm raw formats;
93
94 +o _p_g_n_m_r_a_w - selects between pgm and pbm raw formats.
97 formats: always use the "raw" output devices, which are:
98
99 o ppmraw - raw pixmap format (color images);
100
101 o pgmraw - raw greymap format (greyscale images);
102
103 o pbmraw - raw bitmap format (black and white images);
104
105 o pnmraw - selects between ppm, pgm, and pbm raw formats;
106
107 o pgnmraw - selects between pgm and pbm raw formats.
95108
96109 The last two output devices are switches that try to analyze the
97110 image, and select an appropriate format; however, they are not
98111 recommended for routine use, as they may inconsistently choose the
99 format. The ghostscript-5.10 package supplied with Red Hat 6.x
100 distributions provides all these devices; older versions may not.
101 To see the list of available ghostscript output devices, type the
102 command line
112 format. The ghostscript packages supplied with all recent Red Hat
113 distributions provides all these devices. To see the list of
114 available ghostscript output devices, type the command line
103115
104116
105117 gs --help
106
107118
108119
109120
126137
127138
128139
129
130140 (all on a single line). In this example the paper size is explicitly
131 given to gs as _U_S _L_e_t_t_e_r (8.5"x11") size (letter); pnm2ppa no longer
141 given to gs as US Letter (8.5"x11") size (letter); pnm2ppa no longer
132142 needs to be told what the paper size is, and will read it from the
133143 gs output (and check that it is a permitted size for the printer
134144 type). The pnm2ppa option --eco specifies "EconoFast" mode, for a
136146 720 specifies the PPA printer as belonging to the DeskJet 720C series.
137147
138148
149 o pnm2ppa expects that the input resolution is 600dpi (or 300dpi if
150 it is called with the pnm2ppa --dpi300 ...option). This
151 corresponds to the gs -r600 ... or gs -r300 ... ghostscript
152 options. If other higher/lower input resolutions are used, the
153 size of the printed image will be larger/smaller, provided it is
154 within the printer's allowed size range.
155
139156 Obviously, it would be impractical to type such a command each time
140 one wished to print something, so in addition to the pnm2ppa driver
141 itself, an enhanced version of Red Hat's rhs-printfilters RPM package
142 is provided; after this is installed, the PPA printer can be managed
143 like other standard printers with the Red Hat printtool utility. The
144 postscript file can then be printed with the simple command
157 one wished to print something, and since RedHat 6.2, printfilter
158 support for pnm2ppa is built into Red Hat's printer configuration
159 scheme, so after configuration, the simple command
145160
146161
147162 lpr file.ps
148163
149164
150165
151
152
153 +o _H_o_w_e_v_e_r_, _i_f _y_o_u _w_i_s_h _t_o _p_r_i_n_t _t_o _p_a_p_e_r _s_i_z_e_s _s_u_p_p_o_r_t_e_d _b_y
154 _g_h_o_s_t_s_c_r_i_p_t_, _b_u_t _n_o_t _s_u_p_p_o_r_t_e_d _b_y _t_h_e _R_e_d _H_a_t printtool utility,
166 should successfully print a postscript file. However, in case you
167 wish to check if something is misconfigured in the print filters, you
168 can use a script like the above one to bypass them and check that the
169 printer is working.
170
171 o Also, if you wish to print to paper sizes supported by ghostscript,
172 but not supported by the Red Hat Printer configuration utilities,
155173 you can use scripts like the one above. The HP 710C, 720C, and
156174 820C series support paper sizes from 3"x3" to 8.5"x14", while the
157175 1000C supports 4"x6" to 13"x19".
158176
159177
160 AAvvaaiillaabbllee RRPPMM ppaacckkaaggeess..
161
162 A RPM package for pnm2ppa is part of the Red Hat Linux distribution
163 starting with Red Hat 6.2. You will also find a RPM package for the
164 latest release of pnm2ppa at http://sourceforge.net/projects/pnm2ppa.
165
166 The latest version at the time of writing is pnm2ppa-1.04-1.i386.rpm,
167 and is built on Red Hat 6.2. If you are running a different
168 release of Red Hat (or a different Linux distribution) you may need
169 to download and rebuild the source RPM pnm2ppa-1.04-1.src.rpm instead:
170
171
172 rpm --rebuild pnm2ppa-1.04-1.src.rpm
173
178 Available RPM packages. A RPM package for pnm2ppa is part of the
179 Red Hat Linux distribution starting with Red Hat 6.2. You will also
180 find a RPM package for the latest release of pnm2ppa at
181 http://sourceforge.net/projects/pnm2ppa.
182
183 The latest version at the time of writing is
184 pnm2ppa-1.10-1rh7x.i386.rpm, and is built on Red Hat 7.3, or
185 pnm2ppa-1.10-1rh62.i386.rpm, built on Red Hat 6.2. If you are running
186 a different release of Red Hat (or a different Linux distribution)
187 you may need to download and rebuild the source RPM
188 pnm2ppa-1.10-1.src.rpm instead:
189
190
191 rpm --rebuild pnm2ppa-1.10-1.src.rpm
174192
175193
176194
179197 directory /usr/src/redhat/RPMS/i386/.)
180198
181199 Red Hat 6.2 and later also includes support for configuring your
182 printer to use pnm2ppa using printtool and rhs-printfilters. If you
183 are using Red Hat 6.1 and earlier,you will need to update the rhs-
184 printfilters that came with the distribution to the rhs-
185 printfilters-1.57-4ppa4.i386.rpm also available at
186 http://sourceforge.net/projects/pnm2ppa. (This is designed to work
187 only with printtool-3.43 and earlier.)
188
189
190 Note: If you are using Red Hat 6.2, you may wish to update the print
191 filter support that it comes with. The pnm2ppa-1.04-1 RPM package
192 supplies the necessary files that you can use. After installing this
193 RPM, see /usr/lib/rhs/rhs-printfilters/README.ppa for details.
194
195
196 IInnssttaalllliinngg tthhee pnm2ppa RPM package and setting up the PPA printer.
200 printer to use pnm2ppa. (Information necessary for configuring
201 pnm2ppa on older Red Hat releases has been removed from this document;
202 for this, see the documentation that came with pnm2ppa-1.04, or update
203 your RedHat distribution.) Note: If you are still using Red Hat 6.2,
204 you may wish to update the print filter support for pnm2ppa that comes
205 with it. The pnm2ppa-1.10-1rh62* RPM package supplies the necessary
206 files that you can use. After installing this RPM, see
207 /usr/lib/rhs/rhs-printfilters/README.ppa for details.
208
209
210 Installing the pnm2ppa RPM package and setting up the PPA printer.
197211
198212 To install the RPM package, you must log in as the system
199213 administrator, root.
201215 Now begin the installation. First install the pnm2ppa RPM:
202216
203217
204 rpm -Uvh pnm2ppa-1.04-1.i386.rpm
205
218 rpm -Uvh pnm2ppa-1.10-1*.i386.rpm
206219
207220
208221
209222 The pnm2ppa executable gets installed in /usr/bin/.
210223
211 If you are using a 2.2.x kernel, (e.g. Red Hat 6.x) it will be able
212 to autodetect IEEE-1284 devices like PPA printers, provided they are
213 attached to the parallel port with a bidirectional IEEE-1284 cable.
214 (If your printer works under Windows, you have the correct cable.)
215 (Note that older (2.0.x) kernels do not have this autoprobe facility.)
216 A script detect_ppa is provided by the pnm2ppa RPM: just type
224 The Linux kernel will be able to autodetect IEEE-1284 devices like
225 PPA printers, provided they are attached to the parallel port with a
226 bidirectional IEEE-1284 cable. (If your printer works under Windows,
227 you have the correct cable.) A script detect_ppa is provided by the
228 pnm2ppa RPM: just type
217229
218230
219231 detect_ppa
220232
221233
222234
223
224 to confirm that your Printer is found.
225
226 It is possible (especially on Red Hat 6.1) that you will have to add a
227 line
228
229
230 alias parport_lowlevel parport_pc
231
232
233
234
235 to the file /etc/conf.modules for the printer to be found (this is a
236 parallel port recognition issue, not specific to PPA printers. and a
237 known "gotcha" on Red Hat 6.1). A typical message from the printer,
238 which will be displayed if autodetection is successful, is:
235 to confirm that your Printer is found. A typical message from the
236 printer, which will be displayed if autodetection is successful, is:
239237
240238
241239 CLASS:PRINTER;
246244
247245
248246
249
250247 A list of PPA printers found, and the parallel ports to which they are
251248 attached, will also be shown.
252249
256253 has installed. You will need to know your printer model (710, 712,
257254 720, 722, 820, 1000), your paper size (letter, legal, a4) and the
258255 printer port the printer is attached to. If it is attached to the
259 primary parallel port, this is /dev/lp1 under older 2.0.x kernels,
260 and (usually) /dev/lp0 under newer 2.2.x kernels, as in Red Hat 6.x.
261 Type
262
256 primary parallel port, this is (usually) /dev/lp0. Type
263257
264258 test_ppa
265
266259
267260
268261
270263 when prompted. You will then be asked whether to print a test page,
271264 an offset calibration page, or an alignment calibration page, etc.
272265
273 +o _T_i_p_: _T_h_e test_ppa _s_c_r_i_p_t _d_o_e_s _n_o_t _u_s_e _t_h_e _p_r_i_n_t _f_i_l_t_e_r_s _t_h_a_t _w_i_l_l
274 _b_e _i_n_s_t_a_l_l_e_d _b_y _t_h_e rhs-printfilters _R_P_M_, _s_o _i_t _i_s _u_s_e_f_u_l _w_h_e_n
275 _t_r_o_u_b_l_e_s_h_o_o_t_i_n_g_, _f_o_r _t_e_s_t_i_n_g _i_f _a_n_y _p_r_i_n_t_i_n_g _p_r_o_b_l_e_m_s _a_r_e
276 _a_s_s_o_c_i_a_t_e_d _w_i_t_h _t_h_e _b_a_s_i_c _p_r_i_n_t_e_r _i_n_s_t_a_l_l_a_t_i_o_n_, _o_r _w_i_t_h _t_h_e
277 _c_o_n_f_i_g_u_r_a_t_i_o_n _o_f _t_h_e _p_r_i_n_t _f_i_l_t_e_r_s_.
278
279
280 IInnssttaalllliinngg tthhee PPPPAA--eennhhaanncceedd rhs-printfilters RPM package (if needed).
281
282
283 +o _T_h_i_s _s_t_e_p _i_s _N_O_T _n_e_e_d_e_d _o_n _R_e_d _H_a_t _6_._2 _o_r _l_a_t_e_r_.
284
285 The rhs-printfilters rpm distributed with Red Hat 6.1 does not support
286 pnm2ppa, If you use an older distribution, you will first have to
287 replace their rhs-printfilters RPM with the PPA-enhanced version from
288 the pnm2ppa project.
289
290 Once you have confirmed you have a working printer, install the RPM
291 rhs-printfilters-1.57-4ppa4.i386.rpm
292
293
294 rpm -Uvh rhs-printfilters-1.57-4ppa4.i386.rpm
295
296
297
298
299 CCoonnffiigguurriinngg tthhee pprriinntt ffiilltteerrss wwiitthh printtool.
300
301 Now start the "_R_e_d _H_a_t _L_i_n_u_x _P_r_i_n_t _S_y_s_t_e_m _M_a_n_a_g_e_r" (as root) to
302 configure the printer, either by clicking on the printer icon in Red
303 Hat's "control-panel", or just typing
266 o Tip: The test_ppa script does not use the Red Hat print filters, so
267 it is useful when troubleshooting, for testing if any printing
268 problems are associated with the basic printer installation, or
269 with the configuration of the print filters.
270
271
272 Configuring the print filters.
273
274 Note: Red Hat 7.3 now features either CUPS or LPRng printer
275 management. The configuration tools should be able to configure
276 pnm2ppa, using the information about it taken from the Linux Printer
277 Database. Apart from the addition of a new --dpi300 option to accept
278 300dpi input (useful for printing PNM output from 300dpi scanners),
279 there have been no changes in the pnm2ppa command line since the
280 pnm2ppa-1.0 release, so the configuration scripts are stable. (They
281 can only use the default 600dpi input mode.)
282
283 Since Red Hat 7.1, there is a graphical printer configuration utility
284 printconf-gui. In Red Hat 6.2 and 7.0, the older configuration
285 utility called printtool is used. In either case, start the "Red Hat
286 Linux Print System Manager" (as root) to configure the printer, either
287 by clicking on the printer icon in Red Hat's "control-panel", or just
288 typing
304289
305290
306291 printtool
307292
308293
309294
310
311 In the Print System Manager window, click on _A_d_d, then in the "Add a
312 Printer Entry", select _L_o_c_a_l _P_r_i_n_t_e_r, and click _O_k. Hopefully, the
313 port on which the printer is attached will be listed as "Detected" (_i_f
314 _n_o_t_, _f_i_x _t_h_e _p_r_o_b_l_e_m _b_e_f_o_r_e _c_o_n_t_i_n_u_i_n_g, perhaps by adding the line
315 "alias parport_lowlevel parport_pc" to /etc/conf.modules), as men-
316 tioned above. You will now have to "_e_d_i_t _t_h_e _l_o_c_a_l _p_r_i_n_t_e_r _e_n_t_r_y" for
317 the PPA printer. Click on _S_e_l_e_c_t to chose the "Input filter". The
318 _C_o_n_f_i_g_u_r_e _F_i_l_t_e_r screen will open. Among the many printer entries in
319 the list "_P_r_i_n_t_e_r _T_y_p_e", you should find three entries
320
321 +o HHPP DDeesskkJJeett 11000000 sseerriieess ((PPPPAA)) (for 1000Cse, 1000Cxi models)
322
323 +o HHPP DDeesskkJJeett 771100//772200 sseerriieess ((PPPPAA)) (for 710C, 712C, 720C, 722C models)
324
325 +o HHPP DDeesskkJJeett 882200 sseerriieess ((PPPPAA)) (for 820Cse, 820Cxi models)
326
327 +o If these entries do not show up, it may be because the older rhs-
328 printfilters package that you updated did not allow the printer
329 database /usr/lib/rhs/rhs-printfilters/printerdb to be replaced.
330 Try deleting or renaming the printerdb file, and then reinstall
331 the PPA-enhanced rhs-printfilters RPM using "rpm --force -Uvh rhs-
332 printfilters*"
333
334
335 Select the appropriate entry for your printer model. You will then be
336 presented with various options:
337
338 +o The _D_r_i_v_e_r _D_e_s_c_r_i_p_t_i_o_n box contains information about the driver
295 which also starts printconf-gui in the newer Red Hat releases.
296
297
298 Configuring the print filters with the Red Hat 6.2/7.0 printtool
299
300 (Skip this section unless you are still using Red Hat 6.2 or 7.0)
301
302 The following description is for the older printtool that is used by
303 Red Hat 6.2/7.0. The printer configuration utility printconf-gui for
304 Red Hat 7.1 and later is a little different, as it is based on the
305 foomatic printer configuration database which contains entries for
306 pnm2ppa (but not the older pbm2ppa). You should be able to easily
307 figure out what to do: it can configure all pnm2ppa command-line
308 options in the Driver Options screen.
309
310 In the Red Hat 6.2/7.0 Print System Manager window, click on Add, then
311 in the "Add a Printer Entry", select Local Printer, and click Ok.
312 Hopefully, the port on which the printer is attached will be listed as
313 "Detected" (if not, fix the problem before continuing, perhaps by
314 adding the line "alias parport_lowlevel parport_pc" to
315 /etc/conf.modules). You will now have to "edit the local printer
316 entry" for the PPA printer. Click on Select to chose the "Input
317 filter". The Configure Filter screen will open. Among the many
318 printer entries in the list "Printer Type", you should find three
319 entries
320
321
322 o HP DeskJet 1000 series (PPA) (for 1000Cse, 1000Cxi models)
323
324 o HP DeskJet 710/720 series (PPA) (for 710C, 712C, 720C, 722C models)
325
326 o HP DeskJet 820 series (PPA) (for 820Cse, 820Cxi models)
327
328 Select the appropriate entry for your printer model. You will then
329 be presented with various options:
330
331 o The Driver Description box contains information about the driver
339332 (you may have to use the scrollbar at the right of the box to read
340333 it all).
341334
342 +o The _r_e_s_o_l_u_t_i_o_n box shows a single resolution (600x600). There are
335 o The resolution box shows a single resolution (600x600). There are
343336 no other choices.
344337
345 +o The _P_a_p_e_r _S_i_z_e box allows various choices (only _l_e_t_t_e_r, _l_e_g_a_l, and
346 _a_4 seem correspond to native paper sizes printed by the Red Hat
338 o The Paper Size box allows various choices (only letter, legal, and
339 a4 seem correspond to native paper sizes printed by the Red Hat
347340 print filters; the other choices, (a3, ledger, ...) appear to get
348341 resized by the print filters to print on US Letter size paper (?)
349 ). (Other paper sizes cannot be selected this way, but you _c_a_n
350 print to any papersize, _i_f _i_t _s_u_p_p_o_r_t_e_d _b_y _b_o_t_h _g_h_o_s_t_s_c_r_i_p_t _a_n_d _t_h_e
351 _p_r_i_n_t_e_r, using a script, as described above, that bypasses the
342 ). (Other paper sizes cannot be selected this way, but you can
343 print to any papersize, if it supported by both ghostscript and the
344 printer, using a script, as described above, that bypasses the
352345 RedHat printfilters.)
353346
354 +o The _C_o_l_o_r _D_e_p_t_h_/ _U_n_i_p_r_i_n_t _M_o_d_e box allows various selections of
347 o The Color Depth/ Uniprint Mode box allows various selections of
355348 color and print quality (These are achieved by using various
356 combinations of the pnm2ppa options _-_-_e_c_o (EconoFast mode), _-_p
357 (disable black ink cartridge) and _-_-_b_w (black and white printing
349 combinations of the pnm2ppa options --eco (EconoFast mode), -p
350 (disable black ink cartridge) and --bw (black and white printing
358351 only), without direct intervention by the user.) The choices (in
359352 the most recent printerdb database) are:
360353
361 +o Black and White, econofast mode (--bw --eco)
362
363 +o Black and White, normal quality (--bw)
364
365 +o Color, econofast mode (--eco --fd)
366
367 +o Color, normal quality (--eco)
368
369 +o Color, high quality
370
371 +o Color, normal quality, black ink disabled (-p --eco)
372
373 +o Color, high quality, black ink disabled (-p --uni)
354 o Black and White, econofast mode (--bw --eco)
355
356 o Black and White, normal quality (--bw)
357
358 o Color, econofast mode (--eco --fd)
359
360 o Color, normal quality (--eco)
361
362 o Color, high quality
363
364 o Color, normal quality, black ink disabled (-p --eco)
365
366 o Color, high quality, black ink disabled (-p --uni)
374367
375368 (These are the choices that will be presented by "official" rhs-
376369 printfilters-1.72; if you installed a pnm2ppa RPM package from the
383376 still be a useful alternative to pnm2ppa on older, slower systems
384377 with less available memory.
385378
386 +o The three _P_r_i_n_t_i_n_g _o_p_t_i_o_n_s are not relevant here, and should _n_o_t be
379 o The three Printing options are not relevant here, and should not be
387380 selected. They are for direct printing of text (ascii) to non-
388381 postscript printers, but since the only way of printing text files
389382 with pnm2ppa is by first converting them to postscript(tm), this is
390 _n_o_t possible on the PPA printer.
391
392 +o _I_t _i_s _i_m_p_o_r_t_a_n_t _t_h_a_t _t_h_e _c_h_o_i_c_e "Fast text printing (non-PS
393 printers only)" _i_s _N_O_T _s_e_l_e_c_t_e_d_, _s_o _t_h_a_t _t_h_e _p_r_i_n_t _f_i_l_t_e_r_s _w_i_l_l
394 _c_o_n_v_e_r_t _t_e_x_t _f_i_l_e_s _t_o _p_o_s_t_s_c_r_i_p_t _b_e_f_o_r_e _p_r_i_n_t_i_n_g_.
395
396 +o The _M_a_r_g_i_n_s entries control the margins used when printing text
383 not possible on the PPA printer.
384
385 o It is important that the choice "Fast text printing (non-PS
386 printers only)" is NOT selected, so that the print filters will
387 convert text files to postscript before printing.
388 o The Margins entries control the margins used when printing text
397389 files (these are instructions to the text-to-postscript conversion
398390 process).
399391
400 +o The _E_x_t_r_a _G_S _o_p_t_i_o_n_s box is not only a place for adding options for
401 ghostscript, but also for the PPA drivers. _L_e_a_v_e _t_h_i_s _b_o_x _e_m_p_t_y
402 _u_n_l_e_s_s _y_o_u _k_n_o_w _w_h_a_t _y_o_u _a_r_e _d_o_i_n_g. As explained in the text in
392 o The Extra GS options box is not only a place for adding options for
393 ghostscript, but also for the PPA drivers. Leave this box empty
394 unless you know what you are doing. As explained in the text in
403395 the Driver Description box (you did read it, didn't you ?), the
404396 entry should be in the format:
405397
406398
407399
408400 gs_options PPA ppa_options
409
410401
411402
412403
416407 mand line (hopefully, these two sources of information will be consis-
417408 tent with each other!);
418409
419 When you have made your choices, click on _O_k to save your selections
420 and close the "Configure Filter" screen, and then click on _O_K to
410 When you have made your choices, click on Ok to save your selections
411 and close the "Configure Filter" screen, and then click on OK to
421412 close the "Edit Local Printer Entry" screen.
422413
423414 You are now back in the "Red Hat Print System Manager" screen;
424 highlight the printer you just configured, and, in the _T_e_s_t_s menu,
425 choose _P_r_i_n_t _P_o_s_t_s_c_r_i_p_t _t_e_s_t _p_a_g_e to print a test page using the Red
415 highlight the printer you just configured, and, in the Tests menu,
416 choose Print Postscript test page to print a test page using the Red
426417 Hat print filters. If this printed correctly, your print system is
427418 set up to use the PPA printer, just like any of the other printers
428419 that the Red Hat print filters support.
429420
430421
431422
432
433 CCoonnffiigguurriinngg ppnnmm22ppppaa..ccoonnff aanndd ccaalliibbrraattiinngg tthhee pprriinntteerr..
423 Configuring pnm2ppa.conf and calibrating the printer.
434424
435425 A number of printer parameters are set to reasonable default values
436426 for each of the printer models, but you may wish to "fine tune" or
441431
442432 The user-adjustable parameters are:
443433
444 +o vveerrbboossee 11 and ssiilleenntt 11. These control messages about progress and
434 o verbose 1 and silent 1. These control messages about progress and
445435 errors from pnm2ppa. By default, messages are sent to the system
446436 log /var/log/messages. The verbose 1 keyword send copies to
447437 stderr, the standard error stream to the terminal. The silent 1
448438 keyword silences the stream of messages to the system log.
449439
450 +o TThhee ssyysstteemm lloogg mmeessssaaggeess mmaayy bbee ssiilleenncceedd iinn tthhee ddeeffaauulltt
451 ccoonnffiigguurraattiioonn ffiillee;; sswwiittcchh ooffff ""ssiilleenntt"" mmooddee wwiitthh ""ssiilleenntt 00"" ffoorr
452 ddeebbuuggggiinngg pprriinntteerr pprroobblleemmss ((oorr uussee vveerrbboossee mmooddee))..
453
454 +o The vveerrssiioonn keyword can be used to specify the printer model as
440 o The system log messages may be silenced in the default
441 configuration file; switch off "silent" mode with "silent 0"
442 for debugging printer problems (or use verbose mode).
443
444 o The version keyword can be used to specify the printer model as
455445 710, 712, 720, 722, 820, or 1000. It is not needed if you use the
456446 RedHat printool to configure the printer.
457447
458 +o xxooffffsseett and yyooffffsseett: the x-offset and y-offset (in pixels) of the
448 o xoffset and yoffset: the x-offset and y-offset (in pixels) of the
459449 printed image on the page, which should be chosen so the image is
460450 correctly centered on the paper. (These can also be set with the
461451 -x <xoff> and -y <yoff> options.) See CALIBRATION.html (or
462452 CALIBRATION.txt) for more information.
463453
464454
465 +o ttooppmmaarrggiinn, bboottttoommmmaarrggiinn, lleeffttmmaarrggiinn, rriigghhttmmaarrggiinn: the four margins,
455 o topmargin, bottommargin, leftmargin, rightmargin: the four margins,
466456 which define the distances (in pixels) from the edges of the paper
467457 to the printed region; parts of the image that are outside these
468458 margins will not be printed. (These can also be set with the
471461 -l <left margin> , and
472462 -r <right margin> options.)
473463
474 +o CCoollOOffffssXX and CCoollOOffffssYY: the x-offset and y-offset (in pixels)
464 o ColOffsX and ColOffsY: the x-offset and y-offset (in pixels)
475465 between the color image produced by the color ink printer head,
476466 and that produced by the black ink printer head. These should be
477467 recalibrated
478 eeaacchh ttiimmee aann iinnkk ccaarrttrriiddggee iiss rreeppllaacceedd. See CALIBRATION.html (or
468 each time an ink cartridge is replaced. See CALIBRATION.html (or
479469 CALIBRATION.txt) for more information.
480470
481 +o bbllaacckksshheeaarr and ccoolloorrsshheeaarr: these are x offsets between right-to-
471 o blackshear and colorshear: these are x offsets between right-to-
482472 left and left-to-right sweeps of the print head, one for the black
483473 printing and one for the color printing. These provide sideways
484474 offsets (in pixels) of the right-to-left sweeps, that can be used
485475 to correct "shearing" when printing in modes that use bidirectional
486476 print head sweeps.
487477
488 +o uunniimmooddee 11 will make unidirectional print sweeps (left-to-right)
478 o unimode 1 will make unidirectional print sweeps (left-to-right)
489479 the default, instead of bidirectional sweeps. The --uni and --bi
490480 options can control how a particular print run is printed.
491481 Unidirectional printing is only useful (it is slower) if there are
492482 issues of "shearing" in high quality image printing.
493483
494 +o bbllaacckknneessss : this takes values 0,1,2,3 or 4 drops of black ink per
484 o blackness : this takes values 0,1,2,3 or 4 drops of black ink per
495485 pixel, and controls black ink density in black-and-white and "text-
496486 like" black regions in color printing. At present, this has no
497487 effect on printing with the black ink cartridge disabled, or on
499489 with the -B <n> option, where n is the number of drops.)
500490
501491
502 +o GGaammmmaaRR, GGaammmmaaGG, and GGaammmmaaBB: the are the three "gamma" parameters
492 o GammaR, GammaG, and GammaB: the are the three "gamma" parameters
503493 that define the standard color correction curves for red, green,
504494 and blue. Changing these will affect how colors appear
505495 (decreasing any Gamma enhaces the corresponding color). The Gamma
506496 values are specified as decimal numbers, with Gamma = 1.0
507497 corresponding to no color correction.
508498
509 +o Gamma values can also be specified using integer numbers
510 RReeddGGaammmmaaIIddxx, GGrreeeennGGaammmmaaIIddxx, BBlluueeGGaammmmaaIIddxx; These are determined by a
499 o Gamma values can also be specified using integer numbers
500 RedGammaIdx, GreenGammaIdx, BlueGammaIdx; These are determined by a
511501 procedure discussed in COLOR.html or COLOR.txt, which involves
512 printing a test page. The ppaappeerrssiizzee keyword specifies the paper
502 printing a test page. The papersize keyword specifies the paper
513503 size used for this testpage, because it is produced by pnm2ppa
514504 without the input that usually specifies the page size.
515505
516 +o The keywords bbllaacckk__iinnkk 00, ccoolloorr__iinnkk 00, ccyyaann__iinnkk 00, mmaaggeennttaa__iinnkk 00,
517 and yyeellllooww__iinnkk 00 can be used to switch of the various inks; this
506 o The keywords black_ink 0, color_ink 0, cyan_ink 0, magenta_ink 0,
507 and yellow_ink 0 can be used to switch of the various inks; this
518508 can be useful in troubleshooting and debugging pnm2ppa.
519509
520510 Use test_ppa to print various test pages or calibration patterns to
521511 adjust the offsets.
522512
523513 If you wish to specify these parameters using the command-line options
524 described above, some of them can be entered in the "extra GS options"
525 box using the Print System Manager (printtool), as described above.
526
527
528 UUttiilliittyy pprrooggrraammss ffoorr tthhee pprriinntteerr..
514 described above, in Red Hat 6.2/7.0 some of them can be entered in the
515 "extra GS options" box using the Print System Manager (printtool), as
516 described above. In Red Hat 7.1 and later, all command-line options
517 can be set using the new printconf-gui utility.
518 Utility programs for the printer.
529519
530520 HP's Windows software provides a utility program that sends PPA
531 commands to tell the printer to perform taks like cleaning the
532 printheads, etc. The codes for some of these functions have already
533 been reverse engineered. There are proposals to add support for PPA
534 printers to the PUP (Printer Utility Program) utility, which is also a
535 project at http://www.sourceforge.net. However, as of the time of
536 writing, no PUP support for PPA printers is available (volunteers,
537 anyone?).
538
539
540 TTrroouubblleesshhoooottiinngg
521 commands to tell the printer to perform tasks like cleaning the
522 printheads, etc.
523
524 On Red Hat Linux, You can use test_ppa (which acts as a command-line
525 front-end for calibrate_ppa) to print head-cleaning patterns.
526
527 There is a graphical (gtk-based) tool written by Javier Sedano for
528 creating a pnm2ppa.conf file and acting as a front end to
529 calibrate_ppa. This is called ppaSet, and a beta version of it can be
530 found in the same place as the pnm2ppa-1.10 distribution at
531 http://sourceforge.net/projects/pnm2ppa
532
533 There was also at one time a proposal to add support for PPA printers
534 to the PUP (Printer Utility Program) utility, which is also a project
535 at http://www.sourceforge.net. However, as of the time of writing, no
536 PUP support for PPA printers is available.
537
538
539 Troubleshooting
541540
542541 The first thing to do is to look at the messages from pnm2ppa in the
543 system log to see what is happening, whether pnm2ppa aaccttuuaallllyy rreecceeiivveedd
544 aannyy iinnppuutt, and if it was valid.
545 ((YYoouu mmaayy nneeeedd ttoo eennaabbllee ssyysstteemm lloogg mmeessssaaggeess iinn /etc/pnm2ppa.conf,
542 system log to see what is happening, whether pnm2ppa actually received
543 any input, and if it was valid.
544 (You may need to enable system log messages in /etc/pnm2ppa.conf,
546545 see above.) Maybe ghostscript failed to convert your postscript file
547 into PNM format: this is nnoott a pnm2ppa problem! Here are suggestions
548 for dealing with problems that you may encounter.
549
550 +o PPrriinnttiinngg ffaaiillss iinn tthhee mmiiddddllee ooff aa pprriinntt rruunn, perhaps when a figure
546 into PNM format: in that case the system log reports "Fatal Error!
547 Input image (pnm2ppa) is not a PNM image". (note: when this occured,
548 older versions of pnm2ppa reported "Input image is not a supported PNM
549 format" which may have been confusing). This is because the input
550 received by pnm2ppa was not a valid PNM image, but instead ghostscript
551 failed to produce any PNM output at all, and its only output was
552 probably just an error message. This is not a pnm2ppa problem!
553
554 Here are suggestions for dealing with other problems that you may
555 encounter.
556
557 o Printing fails in the middle of a print run, perhaps when a figure
551558 embedded in the document is printing (in the latest pnm2ppa
552559 versions, printing finishes normally, but an incomplete document is
553560 printed). The system log reports that read_line could not read
554561 the image, and found EOF (end-of-file). This probably means that
555 ghostscript's "ppmraw" or "pgmraw" output device failed for some
556 reason, usually leaving a core dump, without completing the
557 translation of the postscript to a pnm format. (This has been seen
558 to happen in ghostscript 5.10 ; upgrading to ghostscript 5.50
559 solved the problem.) If you cannot upgrade, try printing the
560 document in black-and-white using the ghostscript "pbmraw" output
561 device.
562
563 +o TThhee test_ppa script works, but you can't get printtool to make the
564 printfilters work.
565
566 You installed pnm2ppa-1.0 and the PPA-enhanced rhs-printfilters
567 (earlier than v. 1.61) from the pnm2ppa SourceForge page. You
568 are using printtool v. 3.43 or earlier and are probably a Mandrake
569 user. Solution: (a) use printtool to uninstall the PPA printer;
570 (b) delete (or rename) the printer database /usr/lib/rhs/rhs-
571 printfilters/printerdb, and reinstall the rhs-printfilters RPM
572 using the "rpm --force ... " option; (c) use printtool to add the
573 PPA printer again. (Your previously-installed rhs-printfilters may
574 have resisted replacement of its printerdb).
575
576 +o YYoouu uuppggrraaddeedd yyoouurr RReeddHHaatt ((oorr ccoommppaattiibbllee)) LLiinnuuxx ddiissttrriibbuuttiioonn aanndd
577 yyoouurr pprriinnttffiilltteerrss nnoo lloonnggeerr wwoorrkk. You used to use a PPA-enhanced
578 rhs-printfilters from the pnm2ppa SourceForge site. You upgraded
579 your distribution to one using printtool v 3.44 or later (e.g.
580 RedHat 6.2). Solution: Make sure that rhs-printfilters has been
581 updated to a version 1.61 or greater that came with your upgraded
582 distribution. Use printtool to delete, and then add the PPA
583 printer This will create a new printer configuration compatible
584 with your upgraded distribution.
585
586 +o YYoouu pprriinntteedd aann iimmaaggee ffiillee uussiinngg aa ""hhiigghh qquuaalliittyy"" pprriinntteerr sseettttiinngg,,
587 bbuutt iitt hhaass vviissiibbllee hhoorriizzoonnttaall lliinneess oonn iitt and printing under
562 ghostscript's "ppmraw" or "pgmraw" output device started correctly,
563 but failed for some reason before finishing the image conversion
564 from postscript to PNM format, usually leaving a core dump. (This
565 has been seen to happen in ghostscript 5.10 ; upgrading to
566 ghostscript 5.50 solved the problem.) If you cannot upgrade, try
567 printing the document in black-and-white using the ghostscript
568 "pbmraw" output device.
569
570 o You printed an image file using a "high quality" printer setting,
571 but it has visible horizontal lines on it and printing under
588572 Windows(tm) 9x doesn't show this effect (except in "economode").
589573 These are probably "swath boundaries", showing the junction between
590574 different sweeps of the print head. Solution: using unidirectional
591575 printing (PPA option --uni, or unimode 1 in /etc/pnm2ppa.conf)
592 helps a little, but this problem requires an extensive rewrite of
593 part of pnm2ppa (cutswath.c) for a satisfactory solution.
594 (Volunteers welcome - see the TODO file in the pnm2ppa docs
595 (/usr/doc/pnm2ppa*/TODO)!)
596
597 +o "FFllaasshhiinngg lliigghhtt ssyynnddrroommee ". Your printer usually works, but you
576 helps a little. this problem is fixed in the pnm2ppa-1.10 release
577
578 o "Flashing light syndrome ". Your printer usually works, but you
598579 have found that some particular documents cause the printer to
599580 fail, and the lights on its panel start flashing rapidly in
600581 sequence. Solution, turn the printer off and back on again.
604585 (Don't sent it to the Mailing List unless requested). Bug reports
605586 can be filed at the SourceForge pnm2ppa site.
606587
607 +o YYoouu wwiisshh ttoo pprriinntt oonn eennvveellooppeess oorr ootthheerr nnoonn--ssttaannddaarrdd mmeeddiiaa nnoott
608 ssuuppppoorrtteedd bbyy tthhee pprriinntt ffiilltteerrss? Solution: if you can get
588 o You wish to print on envelopes or other non-standard media not
589 supported by the print filters? Solution: if you can get
609590 Ghostscript (gs) to produce the correct image, and the paper size
610591 is in the range allowed by your printer, you should be able to do
611592 this with a script that bypasses the print filters, as described
612593 earlier in this document.
613594
614 +o CCoolloorrss llooookk wwrroonngg,, oorr ddoo nnoott mmaattcchh wwhhaatt tthhee WWiinnddoowwss((ttmm)) 99xx ddrriivveerr
615 pprroodduucceess. Solution: check that your color ink cartridge is not
595 o Colors look wrong, or do not match what the Windows(tm) 9x driver
596 produces. Solution: check that your color ink cartridge is not
616597 running out of some ink color; if not, (a) adjust the "gamma"
617598 entries in /etc/pnm2ppa,conf, or (b) install a customized color
618599 calibration file /etc/pnm2ppa.gamma. See the file COLOR.html (or
620601
621602
622603
623 CCoonnttaaccttiinngg tthhee ppnnmm22ppppaa pprroojjeecctt..
604 Contacting the pnm2ppa project.
624605
625606 Send comments or corrections (about this document or the RPMS) to:
626607 ppa-rpms@users.sourceforge.net
627608
628 There are three mailing lists, _p_p_a_._a_n_n_o_u_n_c_e (announcements), _p_p_a_._u_s_e_r_s
629 (users helping users) and _p_p_a_._d_e_v_e_l (developers). You can subscribe
630 to them, or browse their archives, at
631 http://pnm2ppa.sourceforge.net/maillist.htm.
632
633 To contact the developers, subscribe to _p_p_a_._d_e_v_e_l and post a message.
609 There are three mailing lists, pnm2ppa-announce@lists.sourceforge.net
610 (announcements), pnm2ppa-users@lists.sourceforge.net (users helping
611 users) and pnm2ppa-devel@lists.sourceforge.net (developers). You can
612 subscribe to them, or browse their archives, at
613 http://sourceforge.net/projects/pnm2ppa. (The older pnm2ppa mailing
614 lists died with the ListBot service)
615
616 To contact the developers, subscribe to ppa.devel and post a message.
634617
635618 There are Public Forums for posting questions and comments at
636619 http://sourceforge.net/projects/pnm2ppa (but whether you get any help
637 from these, depends on whether anyone is reading them).
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
620 from these, depends on whether anyone is reading them (unlikely!)).
621
622
623
0 On Solaris systems, you will probably have to install the GNU "libiberty"
1 library (-liberty) which provides getopt_long for Solaris; get it at
2 http://sunfreeware.com
3 (look for the package "libiberty.so" in the list of freeware)
4 and install it into /usr/local/lib.
5
6 The tarball of the package is called "shared-libiberty.tar.gz".
7 If you use the precompiled library libiberty-i386.so that it supplies for
8 x86 systems, rename it to libiberty.so when you install it. Otherwise,
9 build the library from source.
10
11 Uncomment the Makefile line adding an entry for -liberty to LDFLAGS.
12
13 You may also need to compile with the -D__NO_SYSLOG__ option to suppress
14 system log messages. See the Makefile.
15
16 If "make install" fails, manually copy the pnm2ppa and calibrate_ppa binaries,
17 the manpage pnp2ppa.1, and the configuration file pnm2ppa.conf
18 to their appropriate locations.
19
20 The "install" command on Solaris does not have the -b (backup) option.
21 uncomment the Makefile line entry for this.
0 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
1 <HTML>
2 <HEAD>
3 <META NAME="GENERATOR" CONTENT="SGML-Tools 1.0.9">
4 <TITLE>Networking HP PPA DeskJet Printers using SAMBA.: Networking HP DeskJet PPA printers with SAMBA </TITLE>
5 <LINK HREF="PPA_networking-2.html" REL=next>
6
7 <LINK HREF="PPA_networking.html#toc1" REL=contents>
8 </HEAD>
9 <BODY>
10 <A HREF="PPA_networking-2.html">Next</A>
11 Previous
12 <A HREF="PPA_networking.html#toc1">Contents</A>
13 <HR>
14 <H2><A NAME="s1">1. Networking HP DeskJet PPA printers with SAMBA </A></H2>
15
16 <P>
17 <H2><A NAME="ss1.1">1.1 Overview of PPA printers.</A>
18 </H2>
19
20 <P>The HP DeskJet 710/712C, 720/722C, 820Cse/820Cxi and 1000Cse/1000Cxi
21 printers are
22 &quot;Winprinters&quot; which are designed only for use with
23 MS Windows operating systems. HP supplies Windows-only software
24 that processes the input data into the proprietary and unpublished
25 PPA (&quot;Printer Performance Architecture&quot;) protocol.
26 <P>HP states that these printers are <B>not supported as networked
27 printers</B>, but they in fact function correctly as shared (SMB)
28 printers under MS Windows.
29 <P>In this document, the <B>Host</B> is the computer to which
30 the PPA printer is physically connected, and the <B>Clients</B> are
31 other computers on the network that wish to print documents
32 on the PPA printer.
33 <P>In the Windows printing system, separate copies of the HP PPA printer drivers
34 are installed on each Client, and are run on the Client to produce PPA output
35 that is sent over the network to be spooled
36 on the Host to which the printer is attached.
37 <P>HP's drivers are only supplied for Windows systems. The
38 independently-produced
39 <A HREF="http://sourceforge.net/projects/pnm2ppa">pnm2ppa</A>
40 driver runs on Linux, some other Unix systems, and BeOS.
41 <P>This document describes various tested strategies for
42 using <CODE>pnm2ppa</CODE> and the
43 <A HREF="http://www.samba.org">samba</A>
44 suite of SMB tools to allow the PPA printer to be attached to
45 a non-Windows host on a (TCP-based) SMB network, or to allow
46 non-Windows Clients to receive printing services from a Host
47 on the network.
48 <P>
49 <H2><A NAME="ss1.2">1.2 Choice of protocol for sending over the network.</A>
50 </H2>
51
52 <P>There are <B>two</B> possible ways to send printer data from a Client to
53 the printer Host over the network.
54 <UL>
55 <LI> as <B>PPA data</B>, created by a driver on the Client.
56 This is what
57 happens when using conventional printer sharing on Windows.</LI>
58 <LI> as <B>PostScript data</B>, created on the Client, which
59 is then translated into PPA instructions by
60 drivers running on the printer Host.</LI>
61 </UL>
62
63 Since PPA data is rather large, the first method involves sending
64 larger amounts of data over the network, which may be why HP do
65 not officially support PPA DeskJets as networked printers. It also
66 requires that PPA drivers are installed on the Client.
67 <P>The Host to which the printer is attached can thus provide <B>two</B>
68 classes
69 of printing services:
70 <UL>
71 <LI><B>PPA printing services:</B> the Host accepts PPA-format
72 printing jobs created on the Clients either with HP's native PPA drivers
73 (Windows Clients) or <CODE>pnm2ppa</CODE> (Unix/Linux/BeOS Clients);</LI>
74 <LI><B>PostScript printing services:</B> the Host accepts PostScript-format
75 printing jobs created on any postscript-capable Client, and converts
76 them to PPA format using either HP's native PPA drivers
77 (Windows Host) or <CODE>pnm2ppa</CODE> (Unix/Linux/BeOS Host);</LI>
78 </UL>
79
80 It is useful to set up the Host to offer <B>both types</B> of service,
81 sharing a common spooling system.
82 <P>
83 <HR>
84 <A HREF="PPA_networking-2.html">Next</A>
85 Previous
86 <A HREF="PPA_networking.html#toc1">Contents</A>
87 </BODY>
88 </HTML>
0 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
1 <HTML>
2 <HEAD>
3 <META NAME="GENERATOR" CONTENT="SGML-Tools 1.0.9">
4 <TITLE>Networking HP PPA DeskJet Printers using SAMBA.: Configuring the Printer Host.</TITLE>
5 <LINK HREF="PPA_networking-3.html" REL=next>
6 <LINK HREF="PPA_networking-1.html" REL=previous>
7 <LINK HREF="PPA_networking.html#toc2" REL=contents>
8 </HEAD>
9 <BODY>
10 <A HREF="PPA_networking-3.html">Next</A>
11 <A HREF="PPA_networking-1.html">Previous</A>
12 <A HREF="PPA_networking.html#toc2">Contents</A>
13 <HR>
14 <H2><A NAME="s2">2. Configuring the Printer Host.</A></H2>
15
16 <P>
17 <H2><A NAME="ss2.1">2.1 Configuring a Linux/Unix Host to share a PPA printer using Samba.</A>
18 </H2>
19
20 <P>It is assumed that <CODE>pnm2ppa</CODE> is installed and working
21 to provide local printing services on the Host, and that
22 <CODE>lpr</CODE> will invoke a full set of print filters, as
23 (e.g.) in Red Hat 6.2. The PPA printer is installed with
24 the printer name <CODE>lp</CODE>, and
25 <CODE>samba</CODE> is assumed to be installed. General Samba configuration
26 issues involving security levels, network password, etc, are outside the
27 scope of this document (see the SMB-HOWTO). You must log in as
28 <CODE>root</CODE> to configure Samba.
29 <P>Here is a sample entry setting up two public printer shares
30 in the Host's <CODE>/etc/smb.conf</CODE> file.
31 The printer HP722C-PPA is for printing by a Client that sends
32 PPA output from <CODE>pnm2ppa</CODE> or the HP drivers across
33 the network, and HP722-PS is for Clients that produce PostScript
34 output:
35 <BLOCKQUOTE><CODE>
36 <PRE>
37 [HP722C-PPA]
38 comment = HP 722C printer on Linux (PPA input)
39 path = /var/tmp
40 printer name = lp
41 writable = yes
42 public = yes
43 printable = yes
44 print command = lpr -l -r -h -P %p %s
45 [HP722C-PS]
46 comment = HP 722C printer on Linux (Postscript input)
47 path = /var/tmp
48 printer name = lp
49 writable = yes
50 public = yes
51 printable = yes
52 print command = lpr -r -h -P %p %s
53 </PRE>
54 </CODE></BLOCKQUOTE>
55
56 The only differences besides the names are that the print command
57 for HP722-PPA uses the &quot;<CODE> -l </CODE>&quot;
58 &quot;pass-through&quot; option so print filters are not applied.
59 The <CODE>path</CODE> entry uses <CODE>/var/tmp</CODE> because this is (presumably)
60 a world-readable and -writable area for temporary files.
61 <P>After editing <CODE>/etc/smb.conf</CODE> to include these entries,
62 save it, and test its syntax with Samba's <CODE>testparm</CODE> utility.
63 Then restart samba
64 (run &quot;<CODE>/etc/rc.d/init.d/smb restart</CODE>&quot; on Red Hat).
65 <P>
66 <P>
67 <P>
68 <H2><A NAME="ss2.2">2.2 Configuring a Windows Host to share a PPA printer with non-Windows Clients.</A>
69 </H2>
70
71 <P>The Host is assumed to be a Window 98 system, and the PPA
72 printer is assumed to be a HP722C installed with the native HP
73 PPA drivers supplied on HP's installation CD. Some details may vary
74 on other Windows versions.
75 <P>First set up a shared printer that can accept PPA input
76 from both networked Windows Clients, and from
77 networked non-Windows Clients
78 that use <CODE>pnm2ppa</CODE>.
79 <P>
80 <UL>
81 <LI><B>IMPORTANT!</B>:
82 A PPA printer attached to a Windows Host shared with a
83 Client running pnm2ppa has the following limitation:
84 <UL>
85 <LI> <B>Bi-Directional communication between the Windows Host and the printer
86 must be disabled.</B></LI>
87 </UL>
88
89 If it is not done,
90 <B>a General Protection Fault</B> will usually occur on
91 the Windows Host when pnm2ppa sends
92 output to the
93 shared printer. (A &quot;Hpfbkg06&quot; error occurs,
94 and the printer becomes nonfunctional until
95 the Windows system is rebooted.)
96 Disabling bi-directional communication appears to be a minor inconvenience:
97 according to HP, the print quality is unaffected,
98 but the
99 &quot;advanced features of the Status Monitor&quot;
100 will no longer send reminders to align the print cartridges
101 after a new cartridge is installed, or
102 send error messages
103 associated with the ink cartridges
104 or the banner lever.</LI>
105 </UL>
106 <P>You may be able to avoid disabling bi-directional communication
107 by using an emulated Postscript
108 printer to serve non-Windows Clients <B>without</B> using <CODE>pnm2ppa</CODE>
109 (see below).
110 <P>To turn off bi-directional communication between the Windows Host
111 and the printer, open the <B>Settings/Printers</B> folder,
112 then right-click on the printer icon, and open the <B>Properties</B>
113 dialog. Select the <B>Details</B> tab, and click on
114 <B>Spool Settings</B>, then choose the setting
115 &quot;<B>Disable bi-directional support for this printer</B>&quot;.
116 If you have any difficulties, try rebooting Windows after the change,
117 or see HP's support document
118 <A HREF="http://www.hp.com/cposupport/printers/support_doc/bpd06455.html">http://www.hp.com/cposupport/printers/support_doc/bpd06455.html</A> about disabling bi-directional communication.
119 <P>To set up the Host to share the printer, right-click on its
120 icon in the <B>Settings/Printers</B> folder, and select <B>Sharing</B>,
121 then assign it a Share Name like HP722C-PPA , and enter a Comment
122 Line like &quot;HP 722C printer on Windows 98 (PPA input)&quot;.
123 <P>You may now also wish to set up an emulated Postscript printer that
124 accepts Postscript input from the Client,
125 and prints it using HP's PPA drivers
126 <B>running on the Host, instead of on the Client.</B>
127 See the section
128 <A HREF="PPA_networking-4.html">Emulating a PostScript printer on a Windows Host</A><P>If you have installed and successfully tested the emulated printer,
129 set it up for sharing on the network.
130 Right-click on its
131 icon in the <B>Settings/Printers</B> folder, and select <B>Sharing</B>,
132 then assign it a Share Name like HP722C-PS, and enter a Comment
133 Line like &quot;HP 722C printer on Windows 98 (PostScript input)&quot;.
134 <P>The emulated printer will appear like a Postscript printer to
135 the Clients. If it provides acceptable printing services to
136 the non-Windows clients, you will not need to connect <CODE>pnm2ppa</CODE>
137 printers to HP722C-PPA, and will be able to re-enable bi-directional
138 communication between the HP drivers and the printer.
139 (However, the extra processing involved in the emulation may be
140 unacceptably slow, or turn out to use too much of the host's CPU)
141 <P>
142 <P>
143 <HR>
144 <A HREF="PPA_networking-3.html">Next</A>
145 <A HREF="PPA_networking-1.html">Previous</A>
146 <A HREF="PPA_networking.html#toc2">Contents</A>
147 </BODY>
148 </HTML>
0 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
1 <HTML>
2 <HEAD>
3 <META NAME="GENERATOR" CONTENT="SGML-Tools 1.0.9">
4 <TITLE>Networking HP PPA DeskJet Printers using SAMBA.: Configuring the Printing Clients.</TITLE>
5 <LINK HREF="PPA_networking-4.html" REL=next>
6 <LINK HREF="PPA_networking-2.html" REL=previous>
7 <LINK HREF="PPA_networking.html#toc3" REL=contents>
8 </HEAD>
9 <BODY>
10 <A HREF="PPA_networking-4.html">Next</A>
11 <A HREF="PPA_networking-2.html">Previous</A>
12 <A HREF="PPA_networking.html#toc3">Contents</A>
13 <HR>
14 <H2><A NAME="s3">3. Configuring the Printing Clients.</A></H2>
15
16 <P>
17 <H2><A NAME="ss3.1">3.1 Setting up Printing from a Windows Client. </A>
18 </H2>
19
20 <P>
21 <P>Open the <B>Settings/Printers</B> folder, and start the
22 <B>Add Printer</B> Wizard. Choose to add a Network Printer,
23 and browse the network to find the Printer Shares you configured on
24 the host (e.g., HP722C-PPA and HP722C-PS). If they are not visible,
25 either the Host or the network is not properly configured. Correct
26 the problem before proceding.
27 <P>Normally, you will probably want to use
28 the native Windows HP PPA drivers, so select the printer Share that accepts
29 PPA input (e.g., HP722C-PPA). If the Host
30 is a Windows Host, it will provide the drivers over the network,
31 otherwise you will have to
32 find the printer in the list of available HP Printer drivers,
33 or click on <B>Have Disk</B> and install them from HP's installation CD.
34 You then get a chance to change the name with which the printer will be
35 known on the Client. Finally, you should choose to print a test page.
36 <P>You might instead (or also) want to set up printing
37 services using the Printer Share that accepts Postscript
38 (e.g., HP722C-PS).
39 In that case, if the Host is not a Windows Host, choose a
40 &quot;generic&quot; PostScript printer like the
41 Apple LaserWriter II NT or the Digital turboPrintServer 20/Net.
42 <P>If the test page prints sucessfully, you are finished!
43 <P>
44 <P>
45 <H2><A NAME="ss3.2">3.2 Setting up Printing from a Linux/Unix Samba Client </A>
46 </H2>
47
48 <P>
49 <P>First examine the network by opening a terminal window and
50 using the command
51 <BLOCKQUOTE><CODE>
52 <PRE>
53 smbclient -L hostname
54 </PRE>
55 </CODE></BLOCKQUOTE>
56
57 (where &quot;hostname&quot; should be replaced by the
58 network name of the Host to which the printer is attached).
59 This will list
60 the SMB services provided by that Host.
61 (Alternatively, your
62 system may have some graphical front-end to <CODE>smbclient</CODE>
63 that allows you to inspect the network.)
64 The list should include
65 the Printer Share(s) you configured on the Host
66 (e.g., HP722C-PPA and HP722C-PS). If these are
67 absent, you must first identify and correct the problem.
68 <P>You must now configure the printer. The details of how to do this
69 will vary between Linux/Unix distributions, but there will probably
70 be support for network printing using Samba.
71 <P>If the Printer Share
72 you wish to use is intended to accept PPA input
73 (e.g., HP722C-PPA), configure the Client to use the <CODE>pnm2ppa</CODE>
74 driver.
75 <P>If it is intended to accept PostScript input
76 (e.g., HP722C-PS), configure the Client to print to a PostScript printer.
77 <P>You may wish to configure both types of printers, and experiment
78 to see which provides the best printing services on your network.
79 <P>See the SMB-HOWTO documentation for more information.
80 <P>
81 <P>
82 <HR>
83 <A HREF="PPA_networking-4.html">Next</A>
84 <A HREF="PPA_networking-2.html">Previous</A>
85 <A HREF="PPA_networking.html#toc3">Contents</A>
86 </BODY>
87 </HTML>
0 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
1 <HTML>
2 <HEAD>
3 <META NAME="GENERATOR" CONTENT="SGML-Tools 1.0.9">
4 <TITLE>Networking HP PPA DeskJet Printers using SAMBA.: Emulating a PostScript printer on a Windows Host.</TITLE>
5 <LINK HREF="PPA_networking-3.html" REL=previous>
6 <LINK HREF="PPA_networking.html#toc4" REL=contents>
7 </HEAD>
8 <BODY>
9 Next
10 <A HREF="PPA_networking-3.html">Previous</A>
11 <A HREF="PPA_networking.html#toc4">Contents</A>
12 <HR>
13 <H2><A NAME="s4">4. Emulating a PostScript printer on a Windows Host.</A></H2>
14
15 <P>
16 <P>If you do not have commercial PostScript emulation software for Windows that
17 will work with your HP PPA DeskJet
18 (the author is unaware of any such software that supports PPA printers),
19 you can use <B>Ghostscript</B> together with HP's native Windows drivers.
20 <P>
21 <H2><A NAME="ss4.1">4.1 Installing Ghostscript as the emulation software.</A>
22 </H2>
23
24 <P>From the Ghostscript home page
25 <A HREF="http://www.cs.wisc.edu/~ghost/">http://www.cs.wisc.edu/~ghost/</A>
26 download and install (in this order) the Windows packages of
27 <UL>
28 <LI> <B>Ghostscript</B> (PostScript Emulation Software).</LI>
29 <LI> <B>GSview</B> (Ghostscript previewer, provides <CODE>gsprint</CODE>).</LI>
30 <LI> <B>RedMon</B> (printer port redirection utility).</LI>
31 </UL>
32
33 (Install these using their <CODE>setup.exe</CODE>
34 installation tools, and do not manually
35 set up any configuration files for <CODE>gsprint</CODE>
36 or <CODE>RedMon</CODE>.)
37 You must now follow the detailed instructions below, and
38 use the Windows &quot;Add Printer Wizard&quot; to add a postscript
39 printer, and then
40 configure it to use the <CODE>gsprint</CODE> utility that comes with
41 GSview, and redirect the output to your HP PPA DeskJet using the <CODE>RedMon</CODE> utility.
42 <P>
43 <P>
44 <H2><A NAME="ss4.2">4.2 Adding the fictitious Postscript printer.</A>
45 </H2>
46
47 <P>In the following, I assume your printer is a HP DeskJet 722C,
48 and is installed with its native Windows Drivers as a printer
49 called &quot;HP DeskJet 720C Series&quot;. Change printer
50 name entries
51 below as appropriate for your printer model.
52 <P>The following instructions are tested on Windows 98, and may differ
53 on other Windows variants.
54 <P>Open the <B>Settings/Printers</B> folder.
55 <P>First check that the HP PPA Deskjet is correctly installed,
56 using HP's native Windows drivers. Right-click on its icon,
57 and select its <B>Properties</B> dialog. The <B>General
58 Properties</B> screen will open. This shows the <B>exact name</B>
59 that the printer was given when it was installed. Make a note of
60 it, and use the <B>Print Test Page</B> button
61 to confirm that the
62 printer is working. (The &quot;Printer name:&quot; line on the
63 test page will also show the <B>exact name</B> of the HP PPA Deskjet
64 that you will need to use when configuring the emulated postscript printer
65 below). When you are done,
66 click on <B>OK</B> to close the dialog.
67 <P>Now start the <B>Add Printer</B> &quot;Wizard&quot;.
68 Make the choices:
69 <UL>
70 <LI> install a <B>local printer</B></LI>
71 <LI> select a PostScript printer from the
72 list of printers;
73 (e.g., one of the <B>Apple LaserWriter</B> models:
74 the Laserwriter II NT is known to work; <B>Digital
75 PrintServer</B> models such as the turboPrintServer 20/Net
76 have also been recommended). This will provide a
77 suitable postscript driver.</LI>
78 <LI> From the list of Available Ports, choose
79 &quot;<B>FILE: Creates a file on disk</B>&quot;
80 (you will change this after
81 the printer is installed)</LI>
82 <LI> set as default printer?: <B>NO</B></LI>
83 <LI> Print test page?: <B>NO</B></LI>
84 </UL>
85 <P>
86 <H2><A NAME="ss4.3">4.3 Redirecting the output to the PPA printer.</A>
87 </H2>
88
89 <P>After the printer has been installed,
90 right-click on its icon, and rename it to something like,
91 e.g.,
92 &quot;Ghostscript+HP722C&quot;.
93 Then right click again and open its <B>Properties</B> dialog.
94 <P>On the <B>General</B> tab screen,
95 enter something informative
96 in the <B>Comment</B> box, such as
97 &quot; Emulated Postscript printer; output redirected
98 to a HP722C DeskJet printer&quot; (optional).
99 <P>Next select the <B>Details</B> tab.
100 The box &quot;<B>Print using the following driver:</B>&quot;
101 should show the
102 Postscript driver you selected (e.g., Apple LaserWriter II NT).
103 <P>
104 <UL>
105 <LI> Click on <B>Add Port</B>.
106 Select <B>other</B>, then <B> Redirected Port</B>, which should be
107 available if <CODE>RedMon</CODE> was correctly installed, and click on
108 <B>OK</B> to accept these
109 settings and close the Add Port dialog.
110 On the <B>Details</B> tab screen,
111 The box &quot;<B>Print to the following port:</B>&quot;
112 should now show a
113 redirected port such as
114 &quot;<CODE>RPT1 [Redirected Port]</CODE>&quot;.
115 </LI>
116 <LI> Click on
117 <B>Port Settings</B>.
118 <UL>
119 <LI>In the box
120 &quot;<B>Redirect port to the program:</B>&quot;, enter the path to the
121 <CODE>gsprint</CODE> program. (If you accepted the defaults when installing it,
122 this may be <CODE>C:\Ghostgum\gsview\gsprint.exe</CODE>; you may
123 search for it by clicking on <B>Browse</B>).
124 </LI>
125 <LI>In the box &quot;<B>arguments for this program are:</B>&quot;
126 enter the arguments to be passed to the
127 <CODE>gsprint</CODE> program (there is a document <CODE>gsprint.htm</CODE>
128 with more details of these in the folder containing <CODE>gsprint.exe</CODE>).
129 Suggested arguments are:
130 <BLOCKQUOTE><CODE>
131 <PRE>
132 -printer "HP DeskJet 720C Series" -color -
133 </PRE>
134 </CODE></BLOCKQUOTE>
135
136 Replace &quot;HP DeskJet 720C Series&quot; by the (quoted)
137 <B>exact name</B> of the HP PPA DeskJet printer that
138 you made a note of earlier. <B>(If you do not copy this name exactly,
139 including any capitalization or spaces, things may not work!)</B>
140 The <CODE>-color</CODE> argument is needed to
141 enable color printing;
142 (Whether you actually get color printing will depend on the local settings
143 of the &quot;HP DeskJet 720C Series&quot; printer
144 that really prints
145 the document.)
146 The final
147 &quot;<CODE> - </CODE>&quot; is <B>required</B>: without it,
148 the output of <CODE>gsprint</CODE> will not get redirected to
149 the printer.
150
151 </LI>
152 <LI>The box &quot;<B>Output</B>&quot; should show
153 &quot;<B>Program handles output</B>&quot;.
154 </LI>
155 <LI>In the box &quot;<B>Run</B>&quot;, select
156 &quot;<B>hidden</B>&quot;.
157 </LI>
158 <LI>The box &quot;<B>Shutdown delay</B>&quot; will say
159 &quot;300 seconds&quot;. Print jobs for which processing by
160 <CODE>gsprint</CODE> takes longer than this will be terminated,
161 to avoid blocking the printer spool queue. Increase this limit
162 if necessary.</LI>
163 </UL>
164
165
166 Now click on <B>OK</B> to close the Port Settings dialog.
167
168 </LI>
169 <LI> Click on <B>Spool Settings</B>, and select
170 &quot;<B>Disable bi-directional support for this printer</B>&quot;,
171 and click <B>OK</B>.</LI>
172 </UL>
173 <P>Finally, again select the <B>General</B> tab, and test the installation by
174 clicking on &quot;<B>Print a test page</B>&quot;. If it works, you are
175 finished setting up Postscript emulation. Click <B>OK</B> to
176 exit the Printer Properties dialog.
177 <P>(If you have problems, first check that you made the correct
178 entries in the Printer Properties dialogs, <B>especially check that you
179 did not make any typing errors in the
180 exact name for the PPA DeskJet printer in the</B>
181 <CODE>gsprint</CODE><B> arguments box</B>, which must correspond exactly
182 to the &quot;Printer name&quot; given to the HP PPA printer). If the problems
183 persist, you might get guidance from the
184 gsprint and RedMon documentation; look
185 in the folders where these were installed.)
186 <P>You now have a working emulated
187 &quot;Postscript printer&quot; that can now be shared over
188 a network. (The &quot;sharing&quot; options will now be available
189 if you right-click on the emulated printer's icon.)
190 <P>
191 <H2><A NAME="ss4.4">4.4 Limitations.</A>
192 </H2>
193
194 <P>This emulated postscript
195 printer is most useful for providing printing services
196 to non-Windows
197 Clients on a <CODE>samba</CODE> network,
198 but can be also be used by Windows
199 Clients with the following limitations:
200 <UL>
201 <LI>Windows Clients will be able to
202 select Print Settings only for the
203 visible (&quot;front end&quot;) &quot;Postscript printer&quot;,
204 but not for
205 the hidden (&quot;back end&quot;) HP PPA DeskJet printer
206 that actually
207 does the printing.</LI>
208 <LI>Changes in the local Print Settings of the PPA driver for
209 the DeskJet printer on the
210 Host system (but not on Client systems, if it
211 too is shared) will affect network printing by the
212 &quot;Postscript printer&quot;. </LI>
213 <LI>Since the
214 visible &quot;Postscript printer&quot; falsely
215 advertises its identity, some of its Print Settings
216 options seen by users on the Clients may not be valid.</LI>
217 <LI>The extra processing on the printer Host
218 may make printing rather slow compared to native Windows printing.</LI>
219 </UL>
220 <HR>
221 Next
222 <A HREF="PPA_networking-3.html">Previous</A>
223 <A HREF="PPA_networking.html#toc4">Contents</A>
224 </BODY>
225 </HTML>
0 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
1 <HTML>
2 <HEAD>
3 <META NAME="GENERATOR" CONTENT="SGML-Tools 1.0.9">
4 <TITLE>Networking HP PPA DeskJet Printers using SAMBA.</TITLE>
5 <LINK HREF="PPA_networking-1.html" REL=next>
6
7
8 </HEAD>
9 <BODY>
10 <A HREF="PPA_networking-1.html">Next</A>
11 Previous
12 Contents
13 <HR>
14 <H1>Networking HP PPA DeskJet Printers using SAMBA.</H1>
15
16 <H2>The pnm2ppa project team
17 <A HREF="mailto:ppa-rpms@sourceforge.net">ppa-rpms@users.sourceforge.net</A></H2>v0.12 Feb 10, 2002
18 <P><HR>
19 <EM>This document discusses Networking HP 710C, 720C 820C or 1000C Series
20 (PPA Protocol) HP DeskJet printers with non-Windows Hosts or Clients,
21 using SAMBA. Topics include choosing between transmitting PPA or PostScript
22 across the network, Windows and Linux/Unix Hosts, Windows and Linux/Unix
23 Clients, and emulating a PostScript printer on Windows.
24 (Updated for pnm2ppa-1.04 and later.)</EM>
25 <HR>
26 <P>
27 <H2><A NAME="toc1">1.</A> <A HREF="PPA_networking-1.html">Networking HP DeskJet PPA printers with SAMBA </A></H2>
28
29 <UL>
30 <LI><A HREF="PPA_networking-1.html#ss1.1">1.1 Overview of PPA printers.</A>
31 <LI><A HREF="PPA_networking-1.html#ss1.2">1.2 Choice of protocol for sending over the network.</A>
32 </UL>
33 <P>
34 <H2><A NAME="toc2">2.</A> <A HREF="PPA_networking-2.html">Configuring the Printer Host.</A></H2>
35
36 <UL>
37 <LI><A HREF="PPA_networking-2.html#ss2.1">2.1 Configuring a Linux/Unix Host to share a PPA printer using Samba.</A>
38 <LI><A HREF="PPA_networking-2.html#ss2.2">2.2 Configuring a Windows Host to share a PPA printer with non-Windows Clients.</A>
39 </UL>
40 <P>
41 <H2><A NAME="toc3">3.</A> <A HREF="PPA_networking-3.html">Configuring the Printing Clients.</A></H2>
42
43 <UL>
44 <LI><A HREF="PPA_networking-3.html#ss3.1">3.1 Setting up Printing from a Windows Client. </A>
45 <LI><A HREF="PPA_networking-3.html#ss3.2">3.2 Setting up Printing from a Linux/Unix Samba Client </A>
46 </UL>
47 <P>
48 <H2><A NAME="toc4">4.</A> <A HREF="PPA_networking-4.html">Emulating a PostScript printer on a Windows Host.</A></H2>
49
50 <UL>
51 <LI><A HREF="PPA_networking-4.html#ss4.1">4.1 Installing Ghostscript as the emulation software.</A>
52 <LI><A HREF="PPA_networking-4.html#ss4.2">4.2 Adding the fictitious Postscript printer.</A>
53 <LI><A HREF="PPA_networking-4.html#ss4.3">4.3 Redirecting the output to the PPA printer.</A>
54 <LI><A HREF="PPA_networking-4.html#ss4.4">4.4 Limitations.</A>
55 </UL>
56 <HR>
57 <A HREF="PPA_networking-1.html">Next</A>
58 Previous
59 Contents
60 </BODY>
61 </HTML>
0 Networking HP PPA DeskJet Printers using SAMBA.
1 The pnm2ppa project team ppa-rpms@users.sourceforge.net
2 v0.12 Feb 10, 2002
3
4 This document discusses Networking HP 710C, 720C 820C or 1000C Series
5 (PPA Protocol) HP DeskJet printers with non-Windows Hosts or Clients,
6 using SAMBA. Topics include choosing between transmitting PPA or
7 PostScript across the network, Windows and Linux/Unix Hosts, Windows
8 and Linux/Unix Clients, and emulating a PostScript printer on Windows.
9 (Updated for pnm2ppa-1.04 and later.)
10 ______________________________________________________________________
11
12 Table of Contents
13
14
15 1. Networking HP DeskJet PPA printers with SAMBA
16 1.1 Overview of PPA printers.
17 1.2 Choice of protocol for sending over the network.
18
19 2. Configuring the Printer Host.
20 2.1 Configuring a Linux/Unix Host to share a PPA printer using Samba.
21 2.2 Configuring a Windows Host to share a PPA printer with non-Windows Clients.
22
23 3. Configuring the Printing Clients.
24 3.1 Setting up Printing from a Windows Client.
25 3.2 Setting up Printing from a Linux/Unix Samba Client
26
27 4. Emulating a PostScript printer on a Windows Host.
28 4.1 Installing Ghostscript as the emulation software.
29 4.2 Adding the fictitious Postscript printer.
30 4.3 Redirecting the output to the PPA printer.
31 4.4 Limitations.
32
33
34 ______________________________________________________________________
35
36 1. Networking HP DeskJet PPA printers with SAMBA
37
38
39 1.1. Overview of PPA printers.
40
41 The HP DeskJet 710/712C, 720/722C, 820Cse/820Cxi and 1000Cse/1000Cxi
42 printers are "Winprinters" which are designed only for use with MS
43 Windows operating systems. HP supplies Windows-only software that
44 processes the input data into the proprietary and unpublished PPA
45 ("Printer Performance Architecture") protocol.
46
47 HP states that these printers are not supported as networked printers,
48 but they in fact function correctly as shared (SMB) printers under MS
49 Windows.
50
51 In this document, the Host is the computer to which the PPA printer
52 is physically connected, and the Clients are other computers on the
53 network that wish to print documents on the PPA printer.
54
55 In the Windows printing system, separate copies of the HP PPA printer
56 drivers are installed on each Client, and are run on the Client to
57 produce PPA output that is sent over the network to be spooled on the
58 Host to which the printer is attached.
59
60 HP's drivers are only supplied for Windows systems. The
61 independently-produced pnm2ppa driver runs on Linux, some other Unix
62 systems, and BeOS.
63
64 This document describes various tested strategies for using pnm2ppa
65 and the samba suite of SMB tools to allow the PPA printer to be
66 attached to a non-Windows host on a (TCP-based) SMB network, or to
67 allow non-Windows Clients to receive printing services from a Host on
68 the network.
69
70
71 1.2. Choice of protocol for sending over the network.
72
73 There are two possible ways to send printer data from a Client to the
74 printer Host over the network.
75
76 o as PPA data, created by a driver on the Client. This is what
77 happens when using conventional printer sharing on Windows.
78
79 o as PostScript data, created on the Client, which is then translated
80 into PPA instructions by drivers running on the printer Host.
81
82 Since PPA data is rather large, the first method involves sending
83 larger amounts of data over the network, which may be why HP do not
84 officially support PPA DeskJets as networked printers. It also
85 requires that PPA drivers are installed on the Client.
86
87 The Host to which the printer is attached can thus provide two classes
88 of printing services:
89
90 o PPA printing services: the Host accepts PPA-format printing jobs
91 created on the Clients either with HP's native PPA drivers (Windows
92 Clients) or pnm2ppa (Unix/Linux/BeOS Clients);
93
94 o PostScript printing services: the Host accepts PostScript-format
95 printing jobs created on any postscript-capable Client, and
96 converts them to PPA format using either HP's native PPA drivers
97 (Windows Host) or pnm2ppa (Unix/Linux/BeOS Host);
98
99 It is useful to set up the Host to offer both types of service,
100 sharing a common spooling system.
101
102
103 2. Configuring the Printer Host.
104
105
106 2.1. Configuring a Linux/Unix Host to share a PPA printer using
107 Samba.
108
109 It is assumed that pnm2ppa is installed and working to provide local
110 printing services on the Host, and that lpr will invoke a full set of
111 print filters, as (e.g.) in Red Hat 6.2. The PPA printer is installed
112 with the printer name lp, and samba is assumed to be installed.
113 General Samba configuration issues involving security levels, network
114 password, etc, are outside the scope of this document (see the SMB-
115 HOWTO). You must log in as root to configure Samba.
116
117 Here is a sample entry setting up two public printer shares in the
118 Host's /etc/smb.conf file. The printer HP722C-PPA is for printing by
119 a Client that sends PPA output from pnm2ppa or the HP drivers across
120 the network, and HP722-PS is for Clients that produce PostScript
121 output:
122
123
124
125 [HP722C-PPA]
126 comment = HP 722C printer on Linux (PPA input)
127 path = /var/tmp
128 printer name = lp
129 writable = yes
130 public = yes
131 printable = yes
132 print command = lpr -l -r -h -P %p %s
133 [HP722C-PS]
134 comment = HP 722C printer on Linux (Postscript input)
135 path = /var/tmp
136 printer name = lp
137 writable = yes
138 public = yes
139 printable = yes
140 print command = lpr -r -h -P %p %s
141
142
143
144 The only differences besides the names are that the print command for
145 HP722-PPA uses the " -l " "pass-through" option so print filters are
146 not applied. The path entry uses /var/tmp because this is (presum-
147 ably) a world-readable and -writable area for temporary files.
148
149 After editing /etc/smb.conf to include these entries, save it, and
150 test its syntax with Samba's testparm utility. Then restart samba
151 (run "/etc/rc.d/init.d/smb restart" on Red Hat).
152
153
154
155 2.2. Configuring a Windows Host to share a PPA printer with non-Win-
156 dows Clients.
157
158 The Host is assumed to be a Window 98 system, and the PPA printer is
159 assumed to be a HP722C installed with the native HP PPA drivers
160 supplied on HP's installation CD. Some details may vary on other
161 Windows versions.
162
163 First set up a shared printer that can accept PPA input from both
164 networked Windows Clients, and from networked non-Windows Clients that
165 use pnm2ppa.
166
167
168 o IMPORTANT!: A PPA printer attached to a Windows Host shared with a
169 Client running pnm2ppa has the following limitation:
170
171 o Bi-Directional communication between the Windows Host and the
172 printer must be disabled.
173
174 If it is not done, a General Protection Fault will usually occur on
175 the Windows Host when pnm2ppa sends output to the shared printer.
176 (A "Hpfbkg06" error occurs, and the printer becomes nonfunctional
177 until the Windows system is rebooted.) Disabling bi-directional
178 communication appears to be a minor inconvenience: according to HP,
179 the print quality is unaffected, but the "advanced features of the
180 Status Monitor" will no longer send reminders to align the print
181 cartridges after a new cartridge is installed, or send error mes-
182 sages associated with the ink cartridges or the banner lever.
183
184 You may be able to avoid disabling bi-directional communication by
185 using an emulated Postscript printer to serve non-Windows Clients
186 without using pnm2ppa (see below).
187
188
189 To turn off bi-directional communication between the Windows Host and
190 the printer, open the Settings/Printers folder, then right-click on
191 the printer icon, and open the Properties dialog. Select the Details
192 tab, and click on Spool Settings, then choose the setting "Disable bi-
193 directional support for this printer". If you have any difficulties,
194 try rebooting Windows after the change, or see HP's support document
195 http://www.hp.com/cposupport/printers/support_doc/bpd06455.html about
196 disabling bi-directional communication.
197
198 To set up the Host to share the printer, right-click on its icon in
199 the Settings/Printers folder, and select Sharing, then assign it a
200 Share Name like HP722C-PPA , and enter a Comment Line like "HP 722C
201 printer on Windows 98 (PPA input)".
202
203 You may now also wish to set up an emulated Postscript printer that
204 accepts Postscript input from the Client, and prints it using HP's PPA
205 drivers running on the Host, instead of on the Client. See the
206 section Emulating a PostScript printer on a Windows Host
207
208 If you have installed and successfully tested the emulated printer,
209 set it up for sharing on the network. Right-click on its icon in the
210 Settings/Printers folder, and select Sharing, then assign it a Share
211 Name like HP722C-PS, and enter a Comment Line like "HP 722C printer
212 on Windows 98 (PostScript input)".
213
214 The emulated printer will appear like a Postscript printer to the
215 Clients. If it provides acceptable printing services to the non-
216 Windows clients, you will not need to connect pnm2ppa printers to
217 HP722C-PPA, and will be able to re-enable bi-directional communication
218 between the HP drivers and the printer. (However, the extra
219 processing involved in the emulation may be unacceptably slow, or turn
220 out to use too much of the host's CPU)
221
222
223
224 3. Configuring the Printing Clients.
225
226
227 3.1. Setting up Printing from a Windows Client.
228
229
230 Open the Settings/Printers folder, and start the Add Printer Wizard.
231 Choose to add a Network Printer, and browse the network to find the
232 Printer Shares you configured on the host (e.g., HP722C-PPA and
233 HP722C-PS). If they are not visible, either the Host or the network
234 is not properly configured. Correct the problem before proceding.
235
236 Normally, you will probably want to use the native Windows HP PPA
237 drivers, so select the printer Share that accepts PPA input (e.g.,
238 HP722C-PPA). If the Host is a Windows Host, it will provide the
239 drivers over the network, otherwise you will have to find the printer
240 in the list of available HP Printer drivers, or click on Have Disk
241 and install them from HP's installation CD. You then get a chance to
242 change the name with which the printer will be known on the Client.
243 Finally, you should choose to print a test page.
244
245 You might instead (or also) want to set up printing services using the
246 Printer Share that accepts Postscript (e.g., HP722C-PS). In that
247 case, if the Host is not a Windows Host, choose a "generic" PostScript
248 printer like the Apple LaserWriter II NT or the Digital
249 turboPrintServer 20/Net.
250
251 If the test page prints sucessfully, you are finished!
252
253
254
255 3.2. Setting up Printing from a Linux/Unix Samba Client
256
257
258 First examine the network by opening a terminal window and using the
259 command
260
261
262 smbclient -L hostname
263
264
265
266 (where "hostname" should be replaced by the network name of the Host
267 to which the printer is attached). This will list the SMB services
268 provided by that Host. (Alternatively, your system may have some
269 graphical front-end to smbclient that allows you to inspect the net-
270 work.) The list should include the Printer Share(s) you configured on
271 the Host (e.g., HP722C-PPA and HP722C-PS). If these are absent, you
272 must first identify and correct the problem.
273
274 You must now configure the printer. The details of how to do this
275 will vary between Linux/Unix distributions, but there will probably be
276 support for network printing using Samba.
277
278 If the Printer Share you wish to use is intended to accept PPA input
279 (e.g., HP722C-PPA), configure the Client to use the pnm2ppa driver.
280
281 If it is intended to accept PostScript input (e.g., HP722C-PS),
282 configure the Client to print to a PostScript printer.
283
284 You may wish to configure both types of printers, and experiment to
285 see which provides the best printing services on your network.
286
287 See the SMB-HOWTO documentation for more information.
288
289
290
291 4. Emulating a PostScript printer on a Windows Host.
292
293
294 If you do not have commercial PostScript emulation software for
295 Windows that will work with your HP PPA DeskJet (the author is unaware
296 of any such software that supports PPA printers), you can use
297 Ghostscript together with HP's native Windows drivers.
298
299
300 4.1. Installing Ghostscript as the emulation software.
301
302 From the Ghostscript home page http://www.cs.wisc.edu/~ghost/ download
303 and install (in this order) the Windows packages of
304
305 o Ghostscript (PostScript Emulation Software).
306
307 o GSview (Ghostscript previewer, provides gsprint).
308
309 o RedMon (printer port redirection utility).
310
311 (Install these using their setup.exe installation tools, and do not
312 manually set up any configuration files for gsprint or RedMon.)
313 You must now follow the detailed instructions below, and use the
314 Windows "Add Printer Wizard" to add a postscript printer, and then
315 configure it to use the gsprint utility that comes with GSview, and
316 redirect the output to your HP PPA DeskJet using the RedMon
317 utility.
318
319
320 4.2. Adding the fictitious Postscript printer.
321
322 In the following, I assume your printer is a HP DeskJet 722C, and is
323 installed with its native Windows Drivers as a printer called "HP
324 DeskJet 720C Series". Change printer name entries below as
325 appropriate for your printer model.
326
327 The following instructions are tested on Windows 98, and may differ on
328 other Windows variants.
329
330 Open the Settings/Printers folder.
331
332 First check that the HP PPA Deskjet is correctly installed, using HP's
333 native Windows drivers. Right-click on its icon, and select its
334 Properties dialog. The General Properties screen will open. This
335 shows the exact name that the printer was given when it was installed.
336 Make a note of it, and use the Print Test Page button to confirm that
337 the printer is working. (The "Printer name:" line on the test page
338 will also show the exact name of the HP PPA Deskjet that you will need
339 to use when configuring the emulated postscript printer below). When
340 you are done, click on OK to close the dialog.
341
342 Now start the Add Printer "Wizard". Make the choices:
343
344 o install a local printer
345
346 o select a PostScript printer from the list of printers; (e.g., one
347 of the Apple LaserWriter models: the Laserwriter II NT is known to
348 work; Digital PrintServer models such as the turboPrintServer
349 20/Net have also been recommended). This will provide a suitable
350 postscript driver.
351
352 o From the list of Available Ports, choose "FILE: Creates a file on
353 disk" (you will change this after the printer is installed)
354
355 o set as default printer?: NO
356
357 o Print test page?: NO
358
359
360 4.3. Redirecting the output to the PPA printer.
361
362 After the printer has been installed, right-click on its icon, and
363 rename it to something like, e.g., "Ghostscript+HP722C". Then right
364 click again and open its Properties dialog.
365
366 On the General tab screen, enter something informative in the Comment
367 box, such as " Emulated Postscript printer; output redirected to a
368 HP722C DeskJet printer" (optional).
369
370 Next select the Details tab. The box "Print using the following
371 driver:" should show the Postscript driver you selected (e.g., Apple
372 LaserWriter II NT).
373
374
375 o Click on Add Port. Select other, then Redirected Port, which
376 should be available if RedMon was correctly installed, and click
377 on OK to accept these settings and close the Add Port dialog. On
378 the Details tab screen, The box "Print to the following port:"
379 should now show a redirected port such as "RPT1 [Redirected
380 Port]".
381
382 o Click on Port Settings.
383
384 o In the box "Redirect port to the program:", enter the path to
385 the gsprint program. (If you accepted the defaults when
386 installing it, this may be C:\Ghostgum\gsview\gsprint.exe; you
387 may search for it by clicking on Browse).
388
389 o In the box "arguments for this program are:" enter the arguments
390 to be passed to the gsprint program (there is a document
391 gsprint.htm with more details of these in the folder containing
392 gsprint.exe). Suggested arguments are:
393
394
395 -printer "HP DeskJet 720C Series" -color -
396
397
398
399 Replace "HP DeskJet 720C Series" by the (quoted) exact name of the
400 HP PPA DeskJet printer that you made a note of earlier. (If you do
401 not copy this name exactly, including any capitalization or spaces,
402 things may not work!) The -color argument is needed to enable
403 color printing; (Whether you actually get color printing will
404 depend on the local settings of the "HP DeskJet 720C Series"
405 printer that really prints the document.) The final " - " is
406 required: without it, the output of gsprint will not get redi-
407 rected to the printer.
408
409
410 o The box "Output" should show "Program handles output".
411
412 o In the box "Run", select "hidden".
413
414 o The box "Shutdown delay" will say "300 seconds". Print jobs for
415 which processing by gsprint takes longer than this will be
416 terminated, to avoid blocking the printer spool queue.
417 Increase this limit if necessary.
418
419
420 Now click on OK to close the Port Settings dialog.
421
422
423 o Click on Spool Settings, and select "Disable bi-directional support
424 for this printer", and click OK.
425
426 Finally, again select the General tab, and test the installation by
427 clicking on "Print a test page". If it works, you are finished
428 setting up Postscript emulation. Click OK to exit the Printer
429 Properties dialog.
430
431 (If you have problems, first check that you made the correct entries
432 in the Printer Properties dialogs, especially check that you did not
433 make any typing errors in the exact name for the PPA DeskJet printer
434 in the gsprint arguments box, which must correspond exactly to the
435 "Printer name" given to the HP PPA printer). If the problems persist,
436 you might get guidance from the gsprint and RedMon documentation; look
437 in the folders where these were installed.)
438
439 You now have a working emulated "Postscript printer" that can now be
440 shared over a network. (The "sharing" options will now be available
441 if you right-click on the emulated printer's icon.)
442
443
444 4.4. Limitations.
445
446 This emulated postscript printer is most useful for providing printing
447 services to non-Windows Clients on a samba network, but can be also be
448 used by Windows Clients with the following limitations:
449
450
451 o Windows Clients will be able to select Print Settings only for the
452 visible ("front end") "Postscript printer", but not for the hidden
453 ("back end") HP PPA DeskJet printer that actually does the
454 printing.
455
456 o Changes in the local Print Settings of the PPA driver for the
457 DeskJet printer on the Host system (but not on Client systems, if
458 it too is shared) will affect network printing by the "Postscript
459 printer".
460
461 o Since the visible "Postscript printer" falsely advertises its
462 identity, some of its Print Settings options seen by users on the
463 Clients may not be valid.
464
465 o The extra processing on the printer Host may make printing rather
466 slow compared to native Windows printing.
467
468
469
3737 ------------
3838
3939 If you need help using this software, you can send a message to the
40 ppa.users mailing list, or post your concerns on one of the SourceForge
41 forums. Subscribe to the mailing lists at
42 http://pnm2ppa.sourceforge.net/maillist.htm
43 and visit the SourceForge page at
40 pnm2ppa-users@lists.sourceforge.net mailing list, or post your concerns on
41 one of the SourceForge forums. Subscribe to the mailing lists at
4442 http://sourceforge.net/projects/pnm2ppa
43 (Note the old pnm2ppa mailing lists which used the ListBot service
44 died with that service!)
4545
4646
4747
5050
5151
5252
53
0 Release notes for pnm2ppa-1.11 October 2002
1
2 - pnm2ppa-1.10 had problems with HP820C printers. Hopefully, these
3 are fixed.
4 - Also fixed: a memory leak affected all printer models
5 in certain circumstances: in high quality mode, if the last
6 data on a page was in color, the final three print head passes
7 were not printed, and the data was left in unfreed memory.
8 (discovered using the "valgrind" memory-leak detector).
9 - compression of color data sent to the printer is now enabled.
10 (only compression of black data was previously enabled).
11 If it is suspected this is causing problems, it can be disabled by
12 a new configuration file keyword "compression 0".
13 - Logging of normal informational messages to the system log is
14 now turned off by default. (They still go to stderr in "verbose" mode).
15 Logging of information messages in the System Log can be re-enabled with
16 a new configuration-file entry "log_info 1": this is only accepted
17 from the default configuration file (/etc/pnm2ppa.conf).
18 --------------------------------------------
19 Release notes for pnm2ppa-1.10 June 23 2002
20
21 - major rework of swath-cutting internals so black ink
22 is never overprinted by color ink, and multipass color
23 printing is bidirectional. Only tested on HP722C.
24 Should have much better image quality now, we will have to see
25 if the redesign has broken printing on HP820C, 1000C...
26 Is anyone still using these PPA printers?
27 - new: a --dpi300 command line option for interpreting the
28 input as 300dpi instead of 600dpi. This may be useful for
29 printing 300dpi pnm output directly from scanners.
30 -----------------------------------------------------
031 Release notes for pnm2ppa-1.04 November 12 2000
132
233 - reduced memory footprint of calibrate_ppa from 36MB to 1.8MB
5687 Such changes will require significant effort (by someone highly motivated)
5788 to be achieved. pnm2ppa is probably as good as it can get by tweaking its
5889 code with little bug fixes.
90 [FIXED IN v1.10]
5991
6092 Improvements in color correction techniques could still be achieved,
6193 though (see docs/en/COLOR.txt).
6294
6395 Calibration and printer utility procedures (head cleaning codes, etc)
6496 could also be added. (perhaps using the PUP utility?)
97 [NOW USE calibrate_ppa FOR SOME OF THESE FUNCTIONS]
6598
6699 Use of data compression of sweep data for color sweeps could also be
67100 added without a major rewite, to perhaps speed up printing.
68
101 [FIXED IN v1.11]
69102
70103
71104 The pnm2ppa team.
00 TODO
1 UPDATE (June 10, 2002)
2 * Striping in images like ghostscript' example image "tiger.ps'
3 has been eliminated by just making sure that black ink is never overprinted
4 by color ink. A major reworking to cutswath.c and some improvements to
5 image.c were needed. This is probably the final work done on this driver..
16
7 --------------------------------
28 Code issues (comments by duncan):
39 * implement data compression for color as well as
410 black and white printing.
5 * bidirectional printing is not fully consistent (It is not clear
6 ahead of time whether the next sweep will be color or black, and thus
7 when the sweep changes from black to color or vice-versa, the sweep
8 direction may not reverse.)
911 * check out the new information about the buffer on the printer.
1012 (mentioned on ppa.devel by andrew in early 2000)
1113 * cleaning head codes needed. (or put them into PUP);
1214 document the codes in the ppa docs here.
1315 * should multiple color sweeps in a swath (gMaxpass=4)
1416 alternate between right-to-left and left-to-right ?
15 * Printing of e.g. tiger.ps (an example included with ghostscript)
16 shows lines between swaths. The Windows driver does not. This is because
17 the four passes of the color head (gMaxPass=4) are all at the same
18 vertical position. This is not the way to e.g. paint a wall using a
19 paint roller - instead the successive passes should be vertically
20 staggered so their swath boundaries are not all at the same vertical
21 position. The Windows driver does this: the vertical position of pass 2
22 is 1/4 of a swath height below pass 1, etc. Unfortunately, the design
23 decisions in cutswath.c make this not a simple change. Initial changes
24 would be to somehow decouple the four sweeps, so they could have independent
25 left and right values, directions, vertical positions, etc.
2617
2718 * The Windows driver also has a "normal" mode with gMaxPass=2, and well
2819 as "econofast" (gMaxPass=1) and high quality (gMaxPass=4). It
3526 * A FS_black_dither routine is needed in black-only printing, for high-quality
3627 black-only images.
3728
38 * Internationalization ("i18n") should be done with GNU gettext and .po files,
39 not the current hack.
4029
4130 * add autodetection of device via IEEE 1284 and other methods
4231 * redo debugging support (done ajv)
0 .TH pnm2ppa "28 Oct 2000"
0 .TH pnm2ppa "23 Jun 2002"
11 .SH NAME
22 pnm2ppa - convert portable anymap (PNM) images to HP's PPA printer format.
33 .SH SYNOPSIS
1414 (PNM format output can be produced from PostScript(tm) input by the
1515 GhostScript output devices "pbmraw", "pgmraw" or "ppmraw", or by "pnmraw",
1616 which will choose one of these formats as appropriate for the document.)
17 \fBpnm2ppa\fP assumes the input resolution is 600dpi (or 300dpi if
18 the command-line option \fB--dpi300\fP is used): input at higher/lower
19 resolutions will result in a correspondingly larger/smaller printed image,
20 provided it is within the printer's allowed size range.
1721 .PP
1822
1923 .SH OPTIONS
4044 .\"{{{ -d
4145 .IP "\fB\-d\fP"
4246 Displays the current configuration.
47 .\"}}}
48
49 .\"{{{ --dpi300
50 .IP "\fB\--dpi300\fP"
51 Treat input resolution as 300dpi instead of 600dpi.
4352 .\"}}}
4453
4554 .\"{{{ --eco
190199 .PP
191200 (c) 1999 Andrew van der Stock
192201 .PP
193 (c) 1998-2000 Various authors for many, many fixes
202 (c) 1998-2002 Various authors for many, many fixes
194203 .SH HISTORY
195204 This program was originally pbm2ppa, written by Tim Norman. It originally
196205 supported black and white output on the 820 series.
201210 http://sourceforge.net/projects/pnm2ppa.
202211 .SH BUGS
203212 Faint horizontal lines marking boundaries between print sweeps may be visible.
204 For best results when printing images, use the options \fB -p --uni \fP.
205
213 You may get better results when printing images, with the options:
214 \fB -p --uni \fP (this may no longer apply since recent code improvements).
215
66 <author>The pnm2ppa project team
77 <htmlurl url="mailto:ppa-rpms@sourceforge.net"
88 name="ppa-rpms@users.sourceforge.net">
9 <date>v0.1 Nov 11, 2000
9 <date>v0.2 June 11, 2002
1010 <abstract>
1111 Information about using pnm2ppa
1212 with Mandrake.
2626 for installation and setup. That document is written
2727 for Red Hat; note the Mandrake-specific differences
2828 listed below,
29
30 <bf> To update <tt>pnm2ppa</tt>
31 in any recent Mandrake release (7.2 or later) from v1.04 to v1.10,
32 the simplest procedure may be
33 just to compile pnm2ppa from tarball source and replace the Mandake binaries
34 <tt>/usr/bin/pnm2ppa</tt> and <tt>/usr/bin/calibrate_ppa</tt> with
35 the new versions. They should function as drop-in replacements,
36 with the same user interface, but improved image quality.
37 (You may also wish to use the newer <tt>pnm2ppa.conf</tt> configuration
38 file template).</bf>
39
40
41
42
2943
3044 <itemize>
3145 <item> Mandrake 7.0 and earlier has incompatible and non-functional
66 <author>The pnm2ppa project team
77 <htmlurl url="mailto:ppa-rpms@sourceforge.net"
88 name="ppa-rpms@users.sourceforge.net">
9 <date>v0.27, Nov 11, 2000
9 <date>v0.30, July 9, 2002
1010 <abstract>
1111 Information and installation instructions
1212 to accompany pnm2ppa packages
1414 <htmlurl
1515 url="http://sourceforge.net/projects/pnm2ppa"
1616 name="http://sourceforge.net/projects/pnm2ppa">
17 (Updated for pnm2ppa-1.04 and later.)
17 (Updated for pnm2ppa-1.10 and Red Hat 6.2 or later.)
1818 See the &quot;Troubleshooting&quot; section at the end of
1919 this document for
2020 fixes to some reported problems
2727 <bf> Overview of HP's PPA DeskJet Printers.</bf>
2828
2929 Most of Hewlett-Packard's DeskJet(tm) printers use the PCL3 command language,
30 and are currently supported by Ghostscript drivers. However, a few models,
30 and are currently supported by Ghostscript drivers. However, a few legacy
31 models,
3132 namely
3233 <itemize>
3334 <item> <em>DeskJet 710C Series</em>: HP DeskJet 710C, 712C
35 <em>(discontinued)</em>
3436 <item> <em>DeskJet 720C Series</em>: HP DeskJet 720C, 722C
37 <em>(discontinued)</em>
3538 <item> <em>DeskJet 820C Series</em>: HP DeskJet 820Cxi, 820Cse
3639 <em>(discontinued)</em>
3740 <item> <em>DeskJet 1000C Series</em>: HP DeskJet 1000Cxi, 1000Cse
4346 PPA (<em>Printer Performance Architecture</em>) protocol,
4447 instead of PCL. The two models in each series are physically
4548 identical;
46 they just come with different bundled Windows software.
47 The 820C and 1000C series are discontinued at this time (January 2000).
49 they just came with different bundled Windows software.
50 All PPA printers are now discontinued from HP's product lines,
51 but may still be found as second-hand legacy items.
4852
4953 PPA printers rely on software running on the
5054 host CPU to carry out the low-level processing
5155 of printer output that would be done by hardware in
5256 a standard PCL printer. The relation of PPA printers to PCL printers
5357 is analogous to the relation between &quot;Winmodems&quot; and true modems.
54
55 Unfortunately, HP only supplies Windows software drivers for PPA printers,
58 Presumably, the idea at the time was that this would allow cheaper hardware
59 to be used, but the decline in hardware prices probably meant that
60 the savings were not significant, and PPA printing seems to have been
61 abandoned.
62
63 Unfortunately, HP only supplied Windows software drivers for PPA printers,
5664 and have indicated that it is unlikely that
5765 they will ever make the proprietary PPA specs public.
5866 This is apparently because of concerns that
6573 and it seems that HP do not wish to take any responsibility for such damage by
6674 encouraging unofficial PPA programming.)
6775
68 In fact,
69 the decline in hardware component prices has meant that the anticipated
70 cost-savings through using host-based PPA instead of printer-based PCL
71 are less than expected, and two of the PPA printer series
72 (820C, 1000C) have been phased out, and replaced by similar PCL printers
73 in HP's product line. The 710C and 720C series are still being sold
74 at this time of writing. <bf> All other currently-offered
75 DeskJet models appear to be standard PCL3
76 printers.</bf>
77
78
79 Many Linux users may have inadvertently purchased PPA DeskJet models,
80 mistaking them for PCL3 DeskJets, for which independently-produced
81 Linux drivers have long
82 been available. Fortunately, a reverse engineering effort,
76 In the past, Linux users often inadvertently purchased PPA DeskJet models,
77 mistaking them for PCL3 DeskJets, which have traditionally
78 been well-supported
79 by Linux drivers.
80 Fortunately, a reverse engineering effort,
8381 started in 1998 by Tim Norman,
84 <htmlurl
85 url="http://www.normsoft.com/ppa"
86 name="http://www.normsoft.com/ppa">
87 and
82 and continued by the <em>pnm2ppa</em> project at
8883 <htmlurl
8984 url="http://pnm2ppa.sourceforge.net"
9085 name="http://pnm2ppa.sourceforge.net">,
91 and continued by the <em>pnm2ppa</em> project at
86 and
9287 <htmlurl
9388 url="http://sourceforge.net/projects/pnm2ppa"
9489 name="http://sourceforge.net/projects/pnm2ppa">
9590 has managed to produce drivers that provide basic printing
9691 functionality for these PPA printers under Linux and other
97 Unices.
98
99
92 Unices. While HP have recently begun to release their own Linux
93 drivers for PCL3 DeskJets, they have not included drivers for their legacy
94 PPA printers in this effort.
95
96 The <tt>pnm2ppa</tt> driver has been stable since v1.04, released
97 October 2000, with no known reproducible bugs, except that image printing
98 quality was not so good. This version has been distributed with
99 Red Hat, and other Linux distributions. v1.10, released July 2002,
100 contains a lot of changes that improve image quality, in particular
101 by improved bidirectional printing, and
102 always printing black on top of color.
103
104 A better improvement would be for someone to make a PPA backend to
105 <htmlurl
106 url="http://gimp-print.sourceforge.net"
107 name="gimp-print">, using
108 <tt>pnm2ppa</tt> as a guide for how to send data to PPA printers.
109 But, since PPA printers are now &quot;legacy&quot; hardware, and
110 <tt>pnm2ppa</tt> appears to
111 work fine for most printing tasks, it is unlikely that any new developers will
112 be interested in doing this, and there is currently no further development
113 anticipated. The project is currently in &quot;low-maintenance mode&quot;.
100114
101115 <p>
102116 <bf> The pnm2ppa driver for color printing with PPA printers.</bf>
105119 <em><tt>pnm2ppa</tt></em> driver which is the successor to the older
106120 black-and-white-only driver
107121 <htmlurl url="http://pnm2ppa.sourceforge.net/files/pbm2ppa-0.8.6.tar.gz"
108 name="pbm2ppa-0.8.6"> developed by Tim Norman.
109
122 name="pbm2ppa-0.8.6"> developed by Tim Norman.
110123
111124 <tt>pnm2ppa</tt>
112 can translate <em>portable anymap</em> (<em>pnm</em>)
125 translates <em>portable anymap</em> (<em>pnm</em>)
113126 format images into a stream of PPA instructions which can be sent to the
114127 printer. In the driver name,
115128 &quot;<em>pnm</em>&quot; stands for the superset
135148 The last two output devices are switches that try to analyze the
136149 image, and select an appropriate format; however, they are not
137150 recommended for routine use, as they may inconsistently choose the format.
138 The <tt>ghostscript-5.10</tt>
139 package supplied with Red Hat 6.x distributions provides all these
140 devices; older versions may not. To see the list of available
151 The <tt>ghostscript</tt>
152 packages supplied with all recent Red Hat distributions provides all these
153 devices. To see the list of available
141154 ghostscript output devices, type the command line
142155 <tscreen><verb>
143156 gs --help
172185 and <tt>-v 720</tt> specifies the PPA printer as belonging
173186 to the DeskJet 720C series.
174187
188 <itemize>
189 <item> <tt>pnm2ppa</tt> expects that the input resolution is 600dpi
190 (or 300dpi if it is called with the <tt>pnm2ppa --dpi300 ...</tt>option).
191 This corresponds to the <tt>gs -r600 ...</tt> or
192 <tt>gs -r300 ... </tt> ghostscript options.
193 If other higher/lower input resolutions are used, the size of
194 the printed image will be larger/smaller, provided it is
195 within the printer's allowed size range.
196 </itemize>
175197
176198 Obviously, it would be impractical to type such a command each time
177 one wished to print something, so in addition to the <tt>pnm2ppa</tt>
178 driver itself, an enhanced version of Red Hat's <tt>rhs-printfilters</tt>
179 RPM package is provided; after this is installed, the PPA printer
180 can be managed like other standard printers with the Red Hat
181 <tt>printtool</tt> utility. The postscript file can then be printed with
199 one wished to print something, and since RedHat 6.2, printfilter
200 support for <tt>pnm2ppa</tt> is built into Red Hat's printer
201 configuration scheme, so after configuration,
182202 the simple command
183203 <tscreen><verb>
184204 lpr file.ps
185205 </verb></tscreen>
186
206 should successfully print a postscript file.
207 However, in case you wish to check if something
208 is misconfigured in the print filters, you can use a script like the
209 above one to bypass them and check that the printer is working.
187210 <itemize>
188211 <item>
189212 <em>
190 However, if you wish to print to paper sizes supported by ghostscript,
191 but not supported by the Red Hat <tt>printtool</tt> utility, you can
213 Also, if you wish to print to paper sizes supported by ghostscript,
214 but not supported by the Red Hat Printer configuration utilities, you can
192215 use scripts like the one above.
193216 The HP 710C, 720C, and 820C series support paper sizes from
194217 3&quot;x3&quot; to 8.5&quot;x14&quot;, while the 1000C
198221
199222 <p>
200223 <bf> Available RPM packages.</bf>
201
202224 A RPM package for <tt>pnm2ppa</tt> is part of the Red Hat Linux
203225 distribution starting with Red Hat 6.2.
204226 You will also find a RPM package for the latest release of
210232
211233 The latest version at the time
212234 of writing is
213 <tt>pnm2ppa-1.04-1.i386.rpm</tt>, and is built on
214 Red Hat 6.2. If you are running a different release
235 <tt>pnm2ppa-1.10-1rh7x.i386.rpm</tt>, and is built on
236 Red Hat 7.3, or
237 <tt>pnm2ppa-1.10-1rh62.i386.rpm</tt>, built on
238 Red Hat 6.2.
239 If you are running a different release
215240 of Red Hat (or a different Linux distribution)
216241 you may need to download and rebuild the source RPM
217 <tt>pnm2ppa-1.04-1.src.rpm</tt> instead:
218 <tscreen><verb>
219 rpm --rebuild pnm2ppa-1.04-1.src.rpm
242 <tt>pnm2ppa-1.10-1.src.rpm</tt> instead:
243 <tscreen><verb>
244 rpm --rebuild pnm2ppa-1.10-1.src.rpm
220245 </verb></tscreen>
221246 (You must be <tt>root</tt> to do this, and have the necessary
222247 compilers installed; on Red Hat, the rebuilt binary RPM will be created in
223248 the directory <tt>/usr/src/redhat/RPMS/i386/</tt>.)
224249
225250 Red Hat 6.2 and later also includes support for configuring your
226 printer to use <tt>pnm2ppa</tt> using <tt>printtool</tt>
227 and <tt>rhs-printfilters</tt>.
228 If you are using Red Hat 6.1 and earlier,you will need to
229 update the <tt>rhs-printfilters</tt> that came with the distribution
230 to the
231 <tt>rhs-printfilters-1.57-4ppa4.i386.rpm</tt> also available at
232 <htmlurl
233 url="http://sourceforge.net/projects/pnm2ppa"
234 name="http://sourceforge.net/projects/pnm2ppa">.
235 (This is designed to work only with <tt>printtool-3.43</tt> and earlier.)
236
237
238 Note: If you are using Red Hat 6.2, you may wish to update the
239 print filter support that it comes with. The <tt>pnm2ppa-1.04-1</tt>
251 printer to use <tt>pnm2ppa</tt>.
252 (Information necessary for configuring
253 <tt>pnm2ppa</tt> on older Red Hat releases has been removed from
254 this document; for this, see the documentation that came with
255 <tt>pnm2ppa-1.04</tt>, or update your RedHat distribution.)
256 Note: If you are still using Red Hat 6.2, you may wish to update the
257 print filter support for <tt>pnm2ppa</tt> that comes with it.
258 The <tt>pnm2ppa-1.10-1rh62*</tt>
240259 RPM package supplies the necessary files that you can use.
241260 After installing this RPM, see
242261 <tt>/usr/lib/rhs/rhs-printfilters/README.ppa</tt> for details.
249268
250269 Now begin the installation. First install the <tt>pnm2ppa</tt> RPM:
251270 <tscreen><verb>
252 rpm -Uvh pnm2ppa-1.04-1.i386.rpm
271 rpm -Uvh pnm2ppa-1.10-1*.i386.rpm
253272 </verb></tscreen>
254273 The <tt>pnm2ppa</tt> executable gets installed in <tt>/usr/bin/</tt>.
255274
256 If you are using a 2.2.x kernel,
257 (e.g. Red Hat 6.x)
258 it will be able to autodetect
275 The Linux kernel will be able to autodetect
259276 IEEE-1284 devices like PPA printers, provided they are attached
260277 to the parallel port with a bidirectional IEEE-1284 cable. (If your
261278 printer works under Windows, you have the correct cable.)
262 (Note that older (2.0.x) kernels do not have this autoprobe facility.)
263279 A script <tt>detect_ppa</tt> is provided by the <tt>pnm2ppa</tt>
264280 RPM: just type
265281 <tscreen><verb>
266282 detect_ppa
267283 </verb></tscreen>
268284 to confirm that your Printer is found.
269
270 It is possible (especially on Red Hat 6.1) that you will have to add
271 a line
272 <tscreen><verb>
273 alias parport_lowlevel parport_pc
274 </verb></tscreen>
275 to the file <tt>/etc/conf.modules</tt> for the printer to be found (this is
276 a parallel port recognition issue, not specific to PPA printers.
277 and a known &quot;gotcha&quot; on Red Hat 6.1).
278285 A typical message from the printer, which will
279286 be displayed if autodetection is successful, is:
280287 <tscreen><verb>
294301 printer model (710, 712, 720, 722, 820, 1000), your paper size
295302 (letter, legal, a4) and the printer port the printer is attached to.
296303 If it is attached to the primary parallel port, this is
297 <em><tt>/dev/lp1</tt></em> under older 2.0.x kernels, and (usually)
298 <em><tt>/dev/lp0</tt></em> under newer 2.2.x kernels, as in Red Hat 6.x.
304 (usually) <em><tt>/dev/lp0</tt></em>.
299305 Type
300306 <tscreen><verb>
301307 test_ppa
308314 <itemize>
309315 <item> <em><em>Tip:</em>
310316 The </em><tt>test_ppa</tt><em> script
311 does not use the print filters that
312 will be installed by the </em><tt>rhs-printfilters</tt><em> RPM, so it is
317 does not use the Red Hat print filters, so it is
313318 useful when troubleshooting, for testing if any printing problems are
314319 associated with the basic printer installation, or with the
315320 configuration of the print filters.</em>
316321 </itemize>
317322
318 <p>
319 <bf> Installing the PPA-enhanced <tt>rhs-printfilters</tt> RPM package (if needed).</bf>
320
321 <itemize>
322 <em>
323 This step is NOT needed on Red Hat 6.2 or later.</em>
324 </itemize>
325
326 The <tt>rhs-printfilters</tt> rpm distributed with
327 Red Hat 6.1 does not support <tt>pnm2ppa</tt>,
328 If you use an older distribution, you will first have to replace their
329 <tt>rhs-printfilters</tt> RPM with the PPA-enhanced version from the
330 pnm2ppa project.
331
332 Once you have confirmed you have a working printer, install the
333 RPM <tt>rhs-printfilters-1.57-4ppa4.i386.rpm</tt>
334 <tscreen><verb>
335 rpm -Uvh rhs-printfilters-1.57-4ppa4.i386.rpm
336 </verb></tscreen>
337
338 <bf> Configuring the print filters with <tt>printtool</tt>.</bf>
339
340 Now start the &quot;<em>Red Hat Linux Print System Manager</em>&quot;
323
324 <bf> Configuring the print filters.</bf>
325
326 Note: Red Hat 7.3 now features either CUPS or LPRng printer management.
327 The configuration tools should be able to configure <tt>pnm2ppa</tt>,
328 using the information about it taken from the Linux Printer Database.
329 Apart from the addition of a new <tt>--dpi300</tt> option
330 to accept 300dpi input (useful for printing PNM output from 300dpi scanners),
331 there have been no changes in the pnm2ppa command line since the pnm2ppa-1.0
332 release, so the configuration scripts are stable. (They
333 can only use the default 600dpi input mode.)
334
335 Since Red Hat 7.1, there is a graphical
336 printer configuration utility <tt>printconf-gui</tt>. In Red Hat 6.2 and
337 7.0, the older configuration utility called <tt>printtool</tt> is used.
338 In either case,
339 start the &quot;<em>Red Hat Linux Print System Manager</em>&quot;
341340 (as root) to
342341 configure the printer, either
343 by clicking on the printer icon in Red Hat's &quot;control-panel&quot;, or just
344 typing
342 by clicking on the printer icon in Red Hat's &quot;control-panel&quot;,
343 or just typing
345344 <tscreen><verb>
346345 printtool
347346 </verb></tscreen>
348 In the Print System Manager window, click on <em>Add</em>, then
347 which also starts <tt>printconf-gui</tt> in the newer Red Hat releases.
348
349 <p>
350 <bf> Configuring the print filters with the Red Hat 6.2/7.0 printtool</bf>
351
352 (Skip this section unless you are still using Red Hat 6.2 or 7.0)
353
354 The following description is for the older <tt>printtool</tt> that
355 is used by Red Hat 6.2/7.0. The printer configuration utility
356 <tt>printconf-gui</tt> for Red Hat 7.1 and later
357 is a little different, as it is based on the <em>foomatic</em> printer
358 configuration database which contains entries for <tt>pnm2ppa</tt>
359 (but not the older <tt>pbm2ppa</tt>). You should be able to easily figure out
360 what to do: it can configure all <tt>pnm2ppa</tt> command-line options in the
361 <em>Driver Options</em> screen.
362
363 In the Red Hat 6.2/7.0 Print System Manager window, click on <em>Add</em>, then
349364 in the &quot;Add a Printer Entry&quot;, select <em>Local Printer</em>, and
350365 click <em>Ok</em>. Hopefully, the port on which the printer is attached
351366 will be listed as &quot;Detected&quot; (<em>if not,
352367 fix the problem before continuing</em>, perhaps by
353368 adding the line &quot;<tt>alias parport_lowlevel parport_pc</tt>&quot;
354 to <tt>/etc/conf.modules</tt>), as mentioned above.
369 to <tt>/etc/conf.modules</tt>).
355370 You will now have to &quot;<em>edit
356371 the local printer entry</em>&quot; for the PPA printer. Click on
357372 <em>Select</em> to chose the &quot;Input filter&quot;.
362377 <item><bf>HP DeskJet 1000 series (PPA)</bf> (for 1000Cse, 1000Cxi models)
363378 <item><bf>HP DeskJet 710/720 series (PPA)</bf> (for 710C, 712C, 720C, 722C models)
364379 <item><bf>HP DeskJet 820 series (PPA)</bf> (for 820Cse, 820Cxi models)
365 <itemize>
366 <item> If these entries do not show up, it may be because the older
367 <tt>rhs-printfilters</tt> package that you updated did not allow
368 the printer database <tt>/usr/lib/rhs/rhs-printfilters/printerdb</tt>
369 to be replaced. Try deleting or renaming the <tt>printerdb</tt>
370 file, and then reinstall
371 the PPA-enhanced <tt>rhs-printfilters</tt> RPM using
372 &quot;<tt>rpm --force -Uvh rhs-printfilters*</tt>&quot;
373 </itemize>
374 </itemize>
375
376
380 </itemize>
377381 Select the appropriate
378382 entry for your printer model. You will then be presented with
379383 various options:
597601
598602 If you wish to specify these
599603 parameters using the command-line options
600 described above, some of them can be
604 described above, in Red Hat 6.2/7.0 some of them can be
601605 entered in the &quot;extra GS options&quot; box using the Print System Manager
602606 (<tt>printtool</tt>), as described above.
603
607 In Red Hat 7.1 and later, all command-line options can be set using the new
608 <tt>printconf-gui</tt> utility.
604609
605610 <p>
606611 <bf> Utility programs for the printer.</bf>
607612
608613 HP's Windows software provides a utility program
609614 that sends PPA commands to tell the printer to perform
610 taks like cleaning the printheads, etc. The codes for some
611 of these functions have already been reverse engineered.
612 There are proposals to add support for PPA printers to the
615 tasks like cleaning the printheads, etc.
616
617 On Red Hat Linux, You can use <tt>test_ppa</tt>
618 (which acts as a command-line front-end for
619 <tt>calibrate_ppa</tt>) to print head-cleaning patterns.
620
621 There is a graphical (gtk-based) tool
622 written by Javier Sedano
623 for creating
624 a <tt>pnm2ppa.conf</tt> file and acting as a front end to
625 <tt>calibrate_ppa</tt>.
626 This is called <tt>ppaSet</tt>, and a beta version of it can be found
627 in the same place as the <tt>pnm2ppa-1.10</tt> distribution
628 at <htmlurl
629 url="http://sourceforge.net/projects/pnm2ppa"
630 name="http://sourceforge.net/projects/pnm2ppa">
631
632 There was also at one time a proposal to add support for PPA printers to the
613633 PUP (Printer Utility Program) utility, which is
614634 also a project at
615635 <htmlurl
616636 url="http://www.sourceforge.net/project/?group_id=1118"
617637 name="http://www.sourceforge.net">.
618638 However, as of the time of writing, no PUP support
619 for PPA printers is available (volunteers, anyone?).
639 for PPA printers is available.
620640
621641 <p>
622642 <bf>Troubleshooting</bf>
627647 <bf> (You may need to enable system log messages in
628648 <tt>/etc/pnm2ppa.conf</tt>, see above.)</bf>
629649 Maybe ghostscript failed to convert your postscript file into
630 PNM format: this is <bf>not</bf> a <tt>pnm2ppa</tt> problem!
631 Here are suggestions for dealing with problems that you may encounter.
650 PNM format: in that case the system log reports
651 <bf>&quot;Fatal Error! Input image (pnm2ppa) is not a PNM image&quot;</bf>.
652 (note: when this occured, older versions of <tt>pnm2ppa</tt> reported
653 <bf>&quot;Input image is not a supported PNM format&quot;</bf> which
654 may have been confusing).
655 This is because the input received by <tt>pnm2ppa</tt> was not a valid
656 PNM image, but instead ghostscript failed to produce any
657 PNM output at all, and its only output was probably just an error message.
658 This is <em>not</em> a <tt>pnm2ppa</tt> problem!
659
660 Here are suggestions for dealing with other problems that you may encounter.
632661 <itemize>
633662 <item><bf> Printing fails in the middle of a print run</bf>, perhaps
634663 when a figure embedded in the document is printing (in the latest
637666 reports that <tt>read_line</tt> could not read the image, and found EOF
638667 (end-of-file). This probably
639668 means that <tt>ghostscript</tt>'s &quot;ppmraw&quot; or
640 &quot;pgmraw&quot; output device failed for some reason,
641 usually leaving a core dump, without completing the
642 translation of the postscript to a pnm format.
669 &quot;pgmraw&quot; output device started correctly, but
670 failed for some reason before finishing the image conversion
671 from postscript to PNM format, usually leaving a core dump.
643672 (This has been seen to happen in ghostscript 5.10 ;
644673 upgrading to ghostscript 5.50 solved the problem.) If you cannot
645674 upgrade, try printing the document
646675 in black-and-white using the ghostscript &quot;pbmraw&quot; output device.
647 <item>
648 <bf>The <tt>test_ppa</tt> script works,
649 but you can't get <tt>printtool</tt> to make the printfilters work.</bf>
650
651 You installed <tt>pnm2ppa-1.0</tt> and the PPA-enhanced
652 <tt>rhs-printfilters</tt> (earlier than v. 1.61) from the pnm2ppa
653 SourceForge page. You are using <tt> printtool</tt> v. 3.43 or earlier
654 and are probably a Mandrake user.
655 Solution: (a) use <tt>printtool </tt> to uninstall the PPA printer;
656 (b) delete (or rename) the printer database
657 <tt>/usr/lib/rhs/rhs-printfilters/printerdb</tt>, and reinstall
658 the <tt>rhs-printfilters</tt> RPM using the
659 &quot;<tt>rpm --force ... </tt>&quot;
660 option; (c) use <tt>printtool</tt> to add the
661 PPA printer again.
662 (Your previously-installed <tt>rhs-printfilters</tt> may have
663 resisted replacement of its <tt>printerdb</tt>).
664 <item>
665 <bf>You upgraded your RedHat (or compatible) Linux distribution
666 and your printfilters no longer work</bf>.
667 You used to use a PPA-enhanced <tt>rhs-printfilters</tt> from the
668 pnm2ppa SourceForge site. You
669 upgraded your distribution to one using <tt>printtool</tt> v 3.44 or later
670 (e.g. RedHat 6.2).
671 Solution: Make sure that
672 <tt>rhs-printfilters</tt> has been updated to a version
673 1.61 or greater that came with your
674 upgraded distribution.
675 Use <tt>printtool</tt> to delete, and then add the
676 PPA printer
677 This will create a new printer configuration compatible
678 with your upgraded distribution.
679676 <item>
680677 <bf>You printed an image file using a &quot;high quality&quot;
681678 printer setting, but it has visible horizontal lines
684681 These are probably &quot;swath boundaries&quot;,
685682 showing the junction between different sweeps of the print head.
686683 Solution: using unidirectional printing (PPA option <tt>--uni</tt>,
687 or <tt>unimode 1</tt> in <tt>/etc/pnm2ppa.conf</tt>) helps a little, but
688 this problem requires an extensive
689 rewrite of part of pnm2ppa (<tt>cutswath.c</tt>)
690 for a satisfactory solution. (Volunteers welcome - see the TODO file in the
691 pnm2ppa docs (<tt>/usr/doc/pnm2ppa*/TODO</tt>)!)
684 or <tt>unimode 1</tt> in <tt>/etc/pnm2ppa.conf</tt>) helps a little.
685 <bf>this problem is fixed in the pnm2ppa-1.10 release</bf>
692686 <item>
693687 &quot;<bf>Flashing light syndrome</bf> &quot;.
694688 Your printer usually works, but you have found that some particular
733727 name="ppa-rpms@users.sourceforge.net">
734728
735729 There are three mailing lists,
736 <em>ppa.announce</em> (announcements),
737 <em>ppa.users</em> (users helping users)
738 and <em>ppa.devel</em> (developers).
730 <em>pnm2ppa-announce@lists.sourceforge.net</em> (announcements),
731 <em>pnm2ppa-users@lists.sourceforge.net</em> (users helping users)
732 and <em>pnm2ppa-devel@lists.sourceforge.net</em> (developers).
739733 You can subscribe to them, or browse their
740734 archives, at
741735 <htmlurl
742 url="http://pnm2ppa.sourceforge.net"
743 name="http://pnm2ppa.sourceforge.net/maillist.htm">.
736 url="http://sourceforge.net/projects/pnm2ppa"
737 name="http://sourceforge.net/projects/pnm2ppa">.
738 (The older pnm2ppa mailing lists died with the ListBot service)
744739
745740 To contact the developers, subscribe to <em>ppa.devel</em> and post a message.
746741
750745 url="http://sourceforge.net/projects/pnm2ppa"
751746 name="http://sourceforge.net/projects/pnm2ppa">
752747 (but whether you get any help from these, depends on
753 whether anyone is reading them).
748 whether anyone is reading them (unlikely!)).
754749
755750 </article>
756751
0 <!doctype linuxdoc system>
1 <article>
2
3 <!-- Title information -->
4
5 <title>Networking HP PPA DeskJet Printers using SAMBA.
6 <author>The pnm2ppa project team
7 <htmlurl url="mailto:ppa-rpms@sourceforge.net"
8 name="ppa-rpms@users.sourceforge.net">
9 <date>v0.12 Feb 10, 2002
10 <abstract>
11 This document discusses Networking HP 710C, 720C 820C or 1000C Series
12 (PPA Protocol) HP DeskJet printers with non-Windows Hosts or Clients,
13 using SAMBA. Topics include choosing between transmitting PPA or PostScript
14 across the network, Windows and Linux/Unix Hosts, Windows and Linux/Unix
15 Clients, and emulating a PostScript printer on Windows.
16 (Updated for pnm2ppa-1.04 and later.)
17 </abstract>
18
19 <!-- Begin the document -->
20 <toc>
21
22
23 <sect> Networking HP DeskJet PPA printers with SAMBA
24 <p>
25 <sect1> Overview of PPA printers.
26 <p>
27 The HP DeskJet 710/712C, 720/722C, 820Cse/820Cxi and 1000Cse/1000Cxi
28 printers are
29 &quot;Winprinters&quot; which are designed only for use with
30 MS Windows operating systems. HP supplies Windows-only software
31 that processes the input data into the proprietary and unpublished
32 PPA (&quot;Printer Performance Architecture&quot;) protocol.
33
34 HP states that these printers are <bf>not supported as networked
35 printers</bf>, but they in fact function correctly as shared (SMB)
36 printers under MS Windows.
37
38 In this document, the <bf>Host</bf> is the computer to which
39 the PPA printer is physically connected, and the <bf>Clients</bf> are
40 other computers on the network that wish to print documents
41 on the PPA printer.
42
43 In the Windows printing system, separate copies of the HP PPA printer drivers
44 are installed on each Client, and are run on the Client to produce PPA output
45 that is sent over the network to be spooled
46 on the Host to which the printer is attached.
47
48 HP's drivers are only supplied for Windows systems. The
49 independently-produced
50 <htmlurl url="http://sourceforge.net/projects/pnm2ppa" name="pnm2ppa">
51 driver runs on Linux, some other Unix systems, and BeOS.
52
53 This document describes various tested strategies for
54 using <tt>pnm2ppa</tt> and the
55 <htmlurl url="http://www.samba.org" name="samba">
56 suite of SMB tools to allow the PPA printer to be attached to
57 a non-Windows host on a (TCP-based) SMB network, or to allow
58 non-Windows Clients to receive printing services from a Host
59 on the network.
60
61 <sect1> Choice of protocol for sending over the network.
62 <p>
63 There are <bf>two</bf> possible ways to send printer data from a Client to
64 the printer Host over the network.
65 <itemize>
66 <item> as <bf>PPA data</bf>, created by a driver on the Client.
67 This is what
68 happens when using conventional printer sharing on Windows.
69 <item> as <bf>PostScript data</bf>, created on the Client, which
70 is then translated into PPA instructions by
71 drivers running on the printer Host.
72 </itemize>
73 Since PPA data is rather large, the first method involves sending
74 larger amounts of data over the network, which may be why HP do
75 not officially support PPA DeskJets as networked printers. It also
76 requires that PPA drivers are installed on the Client.
77
78 The Host to which the printer is attached can thus provide <bf>two</bf>
79 classes
80 of printing services:
81 <itemize>
82 <item>
83 <bf>PPA printing services:</bf> the Host accepts PPA-format
84 printing jobs created on the Clients either with HP's native PPA drivers
85 (Windows Clients) or <tt>pnm2ppa</tt> (Unix/Linux/BeOS Clients);
86 <item>
87 <bf>PostScript printing services:</bf> the Host accepts PostScript-format
88 printing jobs created on any postscript-capable Client, and converts
89 them to PPA format using either HP's native PPA drivers
90 (Windows Host) or <tt>pnm2ppa</tt> (Unix/Linux/BeOS Host);
91 </itemize>
92 It is useful to set up the Host to offer <bf>both types</bf> of service,
93 sharing a common spooling system.
94
95 <sect> Configuring the Printer Host.
96 <p>
97 <sect1> Configuring a Linux/Unix Host to share a PPA printer
98 using Samba.
99 <p>
100 It is assumed that <tt>pnm2ppa</tt> is installed and working
101 to provide local printing services on the Host, and that
102 <tt>lpr</tt> will invoke a full set of print filters, as
103 (e.g.) in Red Hat 6.2. The PPA printer is installed with
104 the printer name <tt>lp</tt>, and
105 <tt>samba</tt> is assumed to be installed. General Samba configuration
106 issues involving security levels, network password, etc, are outside the
107 scope of this document (see the SMB-HOWTO). You must log in as
108 <tt>root</tt> to configure Samba.
109
110 Here is a sample entry setting up two public printer shares
111 in the Host's <tt>/etc/smb.conf</tt> file.
112 The printer HP722C-PPA is for printing by a Client that sends
113 PPA output from <tt>pnm2ppa</tt> or the HP drivers across
114 the network, and HP722-PS is for Clients that produce PostScript
115 output:
116 <tscreen><verb>
117 [HP722C-PPA]
118 comment = HP 722C printer on Linux (PPA input)
119 path = /var/tmp
120 printer name = lp
121 writable = yes
122 public = yes
123 printable = yes
124 print command = lpr -l -r -h -P %p %s
125 [HP722C-PS]
126 comment = HP 722C printer on Linux (Postscript input)
127 path = /var/tmp
128 printer name = lp
129 writable = yes
130 public = yes
131 printable = yes
132 print command = lpr -r -h -P %p %s
133 </verb></tscreen>
134 The only differences besides the names are that the print command
135 for HP722-PPA uses the &quot;<tt> -l </tt>&quot;
136 &quot;pass-through&quot; option so print filters are not applied.
137 The <tt>path</tt> entry uses <tt>/var/tmp</tt> because this is (presumably)
138 a world-readable and -writable area for temporary files.
139
140 After editing <tt>/etc/smb.conf</tt> to include these entries,
141 save it, and test its syntax with Samba's <tt>testparm</tt> utility.
142 Then restart samba
143 (run &quot;<tt>/etc/rc.d/init.d/smb restart</tt>&quot; on Red Hat).
144
145
146
147 <sect1> Configuring a Windows Host to share a PPA printer
148 with non-Windows Clients.
149 <p>
150 The Host is assumed to be a Window 98 system, and the PPA
151 printer is assumed to be a HP722C installed with the native HP
152 PPA drivers supplied on HP's installation CD. Some details may vary
153 on other Windows versions.
154
155 First set up a shared printer that can accept PPA input
156 from both networked Windows Clients, and from
157 networked non-Windows Clients
158 that use <tt>pnm2ppa</tt>.
159
160 <itemize>
161 <item><bf>IMPORTANT!</bf>:
162 A PPA printer attached to a Windows Host shared with a
163 Client running pnm2ppa has the following limitation:
164 <itemize>
165 <item> <bf>Bi-Directional communication between the Windows Host and the printer
166 must be disabled.</bf>
167 </itemize>
168 If it is not done,
169 <bf>a General Protection Fault</bf> will usually occur on
170 the Windows Host when pnm2ppa sends
171 output to the
172 shared printer. (A &quot;Hpfbkg06&quot; error occurs,
173 and the printer becomes nonfunctional until
174 the Windows system is rebooted.)
175 Disabling bi-directional communication appears to be a minor inconvenience:
176 according to HP, the print quality is unaffected,
177 but the
178 &quot;advanced features of the Status Monitor&quot;
179 will no longer send reminders to align the print cartridges
180 after a new cartridge is installed, or
181 send error messages
182 associated with the ink cartridges
183 or the banner lever.
184 </itemize>
185
186 You may be able to avoid disabling bi-directional communication
187 by using an emulated Postscript
188 printer to serve non-Windows Clients <bf>without</bf> using <tt>pnm2ppa</tt>
189 (see below).
190
191 To turn off bi-directional communication between the Windows Host
192 and the printer, open the <bf>Settings/Printers</bf> folder,
193 then right-click on the printer icon, and open the <bf>Properties</bf>
194 dialog. Select the <bf>Details</bf> tab, and click on
195 <bf>Spool Settings</bf>, then choose the setting
196 &quot;<bf>Disable bi-directional support for this printer</bf>&quot;.
197 If you have any difficulties, try rebooting Windows after the change,
198 or see HP's support document
199 <htmlurl url="http://www.hp.com/cposupport/printers/support_doc/bpd06455.html"
200 name="http://www.hp.com/cposupport/printers/support_doc/bpd06455.html"> about disabling bi-directional communication.
201
202 To set up the Host to share the printer, right-click on its
203 icon in the <bf>Settings/Printers</bf> folder, and select <bf>Sharing</bf>,
204 then assign it a Share Name like HP722C-PPA , and enter a Comment
205 Line like &quot;HP 722C printer on Windows 98 (PPA input)&quot;.
206
207 You may now also wish to set up an emulated Postscript printer that
208 accepts Postscript input from the Client,
209 and prints it using HP's PPA drivers
210 <bf>running on the Host, instead of on the Client.</bf>
211 See the section
212 <htmlurl url="PPA_networking-4.html"
213 name="Emulating a PostScript printer on a Windows Host">
214
215 If you have installed and successfully tested the emulated printer,
216 set it up for sharing on the network.
217 Right-click on its
218 icon in the <bf>Settings/Printers</bf> folder, and select <bf>Sharing</bf>,
219 then assign it a Share Name like HP722C-PS, and enter a Comment
220 Line like &quot;HP 722C printer on Windows 98 (PostScript input)&quot;.
221
222 The emulated printer will appear like a Postscript printer to
223 the Clients. If it provides acceptable printing services to
224 the non-Windows clients, you will not need to connect <tt>pnm2ppa</tt>
225 printers to HP722C-PPA, and will be able to re-enable bi-directional
226 communication between the HP drivers and the printer.
227 (However, the extra processing involved in the emulation may be
228 unacceptably slow, or turn out to use too much of the host's CPU)
229
230
231 <sect> Configuring the Printing Clients.
232 <p>
233 <sect1> Setting up Printing from a Windows Client.
234 <p>
235
236 Open the <bf>Settings/Printers</bf> folder, and start the
237 <bf>Add Printer</bf> Wizard. Choose to add a Network Printer,
238 and browse the network to find the Printer Shares you configured on
239 the host (e.g., HP722C-PPA and HP722C-PS). If they are not visible,
240 either the Host or the network is not properly configured. Correct
241 the problem before proceding.
242
243 Normally, you will probably want to use
244 the native Windows HP PPA drivers, so select the printer Share that accepts
245 PPA input (e.g., HP722C-PPA). If the Host
246 is a Windows Host, it will provide the drivers over the network,
247 otherwise you will have to
248 find the printer in the list of available HP Printer drivers,
249 or click on <bf>Have Disk</bf> and install them from HP's installation CD.
250 You then get a chance to change the name with which the printer will be
251 known on the Client. Finally, you should choose to print a test page.
252
253 You might instead (or also) want to set up printing
254 services using the Printer Share that accepts Postscript
255 (e.g., HP722C-PS).
256 In that case, if the Host is not a Windows Host, choose a
257 &quot;generic&quot; PostScript printer like the
258 Apple LaserWriter II NT or the Digital turboPrintServer 20/Net.
259
260 If the test page prints sucessfully, you are finished!
261
262
263 <sect1> Setting up Printing from a Linux/Unix Samba Client
264 <p>
265
266 First examine the network by opening a terminal window and
267 using the command <tscreen><verb>
268 smbclient -L hostname
269 </verb></tscreen>
270 (where &quot;hostname&quot; should be replaced by the
271 network name of the Host to which the printer is attached).
272 This will list
273 the SMB services provided by that Host.
274 (Alternatively, your
275 system may have some graphical front-end to <tt>smbclient</tt>
276 that allows you to inspect the network.)
277 The list should include
278 the Printer Share(s) you configured on the Host
279 (e.g., HP722C-PPA and HP722C-PS). If these are
280 absent, you must first identify and correct the problem.
281
282 You must now configure the printer. The details of how to do this
283 will vary between Linux/Unix distributions, but there will probably
284 be support for network printing using Samba.
285
286 If the Printer Share
287 you wish to use is intended to accept PPA input
288 (e.g., HP722C-PPA), configure the Client to use the <tt>pnm2ppa</tt>
289 driver.
290
291 If it is intended to accept PostScript input
292 (e.g., HP722C-PS), configure the Client to print to a PostScript printer.
293
294 You may wish to configure both types of printers, and experiment
295 to see which provides the best printing services on your network.
296
297 See the SMB-HOWTO documentation for more information.
298
299
300 <sect> Emulating a PostScript printer on a Windows Host.
301 <p>
302
303 If you do not have commercial PostScript emulation software for Windows that
304 will work with your HP PPA DeskJet
305 (the author is unaware of any such software that supports PPA printers),
306 you can use <bf>Ghostscript</bf> together with HP's native Windows drivers.
307
308 <sect1> Installing Ghostscript as the emulation software.
309 <p>
310 From the Ghostscript home page
311 <htmlurl
312 url="http://www.cs.wisc.edu/~ghost/" name="http://www.cs.wisc.edu/~ghost/">
313 download and install (in this order) the Windows packages of
314 <itemize>
315 <item> <bf>Ghostscript</bf> (PostScript Emulation Software).
316 <item> <bf>GSview</bf> (Ghostscript previewer, provides <tt>gsprint</tt>).
317 <item> <bf>RedMon</bf> (printer port redirection utility).
318 </itemize>
319 (Install these using their <tt>setup.exe</tt>
320 installation tools, and do not manually
321 set up any configuration files for <tt>gsprint</tt>
322 or <tt>RedMon</tt>.)
323 You must now follow the detailed instructions below, and
324 use the Windows &quot;Add Printer Wizard&quot; to add a postscript
325 printer, and then
326 configure it to use the <tt>gsprint</tt> utility that comes with
327 GSview, and redirect the output to your HP PPA DeskJet using the <tt>RedMon</tt> utility.
328
329
330 <sect1> Adding the fictitious Postscript printer.
331 <p>
332 In the following, I assume your printer is a HP DeskJet 722C,
333 and is installed with its native Windows Drivers as a printer
334 called &quot;HP DeskJet 720C Series&quot;. Change printer
335 name entries
336 below as appropriate for your printer model.
337
338 The following instructions are tested on Windows 98, and may differ
339 on other Windows variants.
340
341 Open the <bf>Settings/Printers</bf> folder.
342
343 First check that the HP PPA Deskjet is correctly installed,
344 using HP's native Windows drivers. Right-click on its icon,
345 and select its <bf>Properties</bf> dialog. The <bf>General
346 Properties</bf> screen will open. This shows the <bf>exact name</bf>
347 that the printer was given when it was installed. Make a note of
348 it, and use the <bf>Print Test Page</bf> button
349 to confirm that the
350 printer is working. (The &quot;Printer name:&quot; line on the
351 test page will also show the <bf>exact name</bf> of the HP PPA Deskjet
352 that you will need to use when configuring the emulated postscript printer
353 below). When you are done,
354 click on <bf>OK</bf> to close the dialog.
355
356 Now start the <bf>Add Printer</bf> &quot;Wizard&quot;.
357 Make the choices:
358 <itemize>
359 <item> install a <bf>local printer</bf>
360 <item> select a PostScript printer from the
361 list of printers;
362 (e.g., one of the <bf>Apple LaserWriter</bf> models:
363 the Laserwriter II NT is known to work; <bf>Digital
364 PrintServer</bf> models such as the turboPrintServer 20/Net
365 have also been recommended). This will provide a
366 suitable postscript driver.
367 <item> From the list of Available Ports, choose
368 &quot;<bf>FILE: Creates a file on disk</bf>&quot;
369 (you will change this after
370 the printer is installed)
371 <item> set as default printer?: <bf>NO</bf>
372 <item> Print test page?: <bf>NO</bf>
373 </itemize>
374
375 <sect1>Redirecting the output to the PPA printer.
376 <p>
377 After the printer has been installed,
378 right-click on its icon, and rename it to something like,
379 e.g.,
380 &quot;Ghostscript+HP722C&quot;.
381 Then right click again and open its <bf>Properties</bf> dialog.
382
383 On the <bf>General</bf> tab screen,
384 enter something informative
385 in the <bf>Comment</bf> box, such as
386 &quot; Emulated Postscript printer; output redirected
387 to a HP722C DeskJet printer&quot; (optional).
388
389 Next select the <bf>Details</bf> tab.
390 The box &quot;<bf>Print using the following driver:</bf>&quot;
391 should show the
392 Postscript driver you selected (e.g., Apple LaserWriter II NT).
393
394 <itemize>
395 <item> Click on <bf>Add Port</bf>.
396 Select <bf>other</bf>, then <bf> Redirected Port</bf>, which should be
397 available if <tt>RedMon</tt> was correctly installed, and click on
398 <bf>OK</bf> to accept these
399 settings and close the Add Port dialog.
400 On the <bf>Details</bf> tab screen,
401 The box &quot;<bf>Print to the following port:</bf>&quot;
402 should now show a
403 redirected port such as
404 &quot;<tt>RPT1 [Redirected Port]</tt>&quot;.
405
406 <item> Click on
407 <bf>Port Settings</bf>.
408 <itemize>
409 <item>In the box
410 &quot;<bf>Redirect port to the program:</bf>&quot;, enter the path to the
411 <tt>gsprint</tt> program. (If you accepted the defaults when installing it,
412 this may be <tt>C:\Ghostgum\gsview\gsprint.exe</tt>; you may
413 search for it by clicking on <bf>Browse</bf>).
414
415 <item>In the box &quot;<bf>arguments for this program are:</bf>&quot;
416 enter the arguments to be passed to the
417 <tt>gsprint</tt> program (there is a document <tt>gsprint.htm</tt>
418 with more details of these in the folder containing <tt>gsprint.exe</tt>).
419 Suggested arguments are:
420 <tscreen><verb>
421 -printer "HP DeskJet 720C Series" -color -
422 </verb></tscreen>
423 Replace &quot;HP DeskJet 720C Series&quot; by the (quoted)
424 <bf>exact name</bf> of the HP PPA DeskJet printer that
425 you made a note of earlier. <bf>(If you do not copy this name exactly,
426 including any capitalization or spaces, things may not work!)</bf>
427 The <tt>-color</tt> argument is needed to
428 enable color printing;
429 (Whether you actually get color printing will depend on the local settings
430 of the &quot;HP DeskJet 720C Series&quot; printer
431 that really prints
432 the document.)
433 The final
434 &quot;<tt> - </tt>&quot; is <bf>required</bf>: without it,
435 the output of <tt>gsprint</tt> will not get redirected to
436 the printer.
437
438
439 <item>The box &quot;<bf>Output</bf>&quot; should show
440 &quot;<bf>Program handles output</bf>&quot;.
441
442 <item>In the box &quot;<bf>Run</bf>&quot;, select
443 &quot;<bf>hidden</bf>&quot;.
444
445 <item>The box &quot;<bf>Shutdown delay</bf>&quot; will say
446 &quot;300 seconds&quot;. Print jobs for which processing by
447 <tt>gsprint</tt> takes longer than this will be terminated,
448 to avoid blocking the printer spool queue. Increase this limit
449 if necessary.
450 </itemize>
451
452 Now click on <bf>OK</bf> to close the Port Settings dialog.
453
454
455 <item> Click on <bf>Spool Settings</bf>, and select
456 &quot;<bf>Disable bi-directional support for this printer</bf>&quot;,
457 and click <bf>OK</bf>.
458 </itemize>
459
460 Finally, again select the <bf>General</bf> tab, and test the installation by
461 clicking on &quot;<bf>Print a test page</bf>&quot;. If it works, you are
462 finished setting up Postscript emulation. Click <bf>OK</bf> to
463 exit the Printer Properties dialog.
464
465 (If you have problems, first check that you made the correct
466 entries in the Printer Properties dialogs, <bf>especially check that you
467 did not make any typing errors in the
468 exact name for the PPA DeskJet printer in the</bf>
469 <tt>gsprint</tt><bf> arguments box</bf>, which must correspond exactly
470 to the &quot;Printer name&quot; given to the HP PPA printer). If the problems
471 persist, you might get guidance from the
472 gsprint and RedMon documentation; look
473 in the folders where these were installed.)
474
475 You now have a working emulated
476 &quot;Postscript printer&quot; that can now be shared over
477 a network. (The &quot;sharing&quot; options will now be available
478 if you right-click on the emulated printer's icon.)
479
480 <sect1> Limitations.
481 <p>
482 This emulated postscript
483 printer is most useful for providing printing services
484 to non-Windows
485 Clients on a <tt>samba</tt> network,
486 but can be also be used by Windows
487 Clients with the following limitations:
488 <itemize>
489 <item>Windows Clients will be able to
490 select Print Settings only for the
491 visible (&quot;front end&quot;) &quot;Postscript printer&quot;,
492 but not for
493 the hidden (&quot;back end&quot) HP PPA DeskJet printer
494 that actually
495 does the printing.
496 <item>Changes in the local Print Settings of the PPA driver for
497 the DeskJet printer on the
498 Host system (but not on Client systems, if it
499 too is shared) will affect network printing by the
500 &quot;Postscript printer&quot;.
501 <item>Since the
502 visible &quot;Postscript printer&quot; falsely
503 advertises its identity, some of its Print Settings
504 options seen by users on the Clients may not be valid.
505 <item>The extra processing on the printer Host
506 may make printing rather slow compared to native Windows printing.
507 </itemize>
508 </article>
509
510
511
512
513
514
515
516
7373 for (i = 150; i < image->width / 4; i++)
7474 {
7575 q = (unsigned char) (255.0 * (i - 150) / (image->width / 4 - 150));
76 // R
76 /* R */
7777 line[3 * i] = q;
7878 line[3 * i + 1] = 0;
7979 line[3 * i + 2] = 0;
8080
81 // G
81 /* G */
8282 line[3 * (i + image->width / 4)] = 0;
8383 line[3 * (i + image->width / 4) + 1] = q;
8484 line[3 * (i + image->width / 4) + 2] = 0;
8585
86 // B
86 /* B */
8787 line[3 * (i + 2 * image->width / 4)] = 0;
8888 line[3 * (i + 2 * image->width / 4) + 1] = 0;
8989 line[3 * (i + 2 * image->width / 4) + 2] = q;
1818 * Global Variables
1919 */
2020
21 #define VERSION "1.04 (November 05, 2000)"
21 #define VERSION "1.12 (November 19, 2002)"
2222
2323 /*
2424 * Global types
8484
8585 BOOLEAN gSilent, gVerbose ; /* switch off syslog, messages to stderr */
8686
87 int gByteCount; /* 1 for pbm/pgm input, 3 for ppm */
88
89 BOOLEAN gCalibrate; /* true when printing calibration pages */
90 BOOLEAN g300; /* assume 300dpi input when true */
91 BOOLEAN gCompress; /* enable compressed (color) sweep data */
92 BOOLEAN gLogInfo; /* enable informational syslog messages */
8793 #else
8894 #ifndef __CALIBRATE_C__
8995 extern int gMaxPass;
107113 extern BOOLEAN gPixmapMode;
108114 extern BOOLEAN gBlack, gCyan, gMagenta, gYellow;
109115 extern BOOLEAN gSilent, gVerbose;
116 extern int gByteCount;
117 extern BOOLEAN gCalibrate;
118 extern BOOLEAN g300;
119 extern BOOLEAN gCompress;
120 extern BOOLEAN gLogInfo;
110121 #endif
111122 #endif
112123
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
+670
-324
image.c less more
3131 #include "dither.h"
3232 #include "lang.h"
3333
34
34 #include <assert.h>
3535
3636
3737
5050 image->unread = 0;
5151 image->colors = 0;
5252
53 gCalibrate = false;
54 gByteCount = 3;
55
5356 if (gGammaMode)
5457 {
5558 /* produce color calibration page, uses the default papersize */
5659 image->version = P6_PPMRAW;
5760 image->width = gWidth;
5861 image->height = gHeight;
62 g300 = false;
5963 }
6064 else
6165 {
6468 return 0;
6569 line[strlen (line) - 1] = 0;
6670
67
6871 /* we have to handle the six pnm formats .
6972 */
70
7173 if (!strcmp (line, "P1"))
7274 {
75 DPRINTF("input format is P1: pbm (ascii)\n");
7376 image->version = P1_PBM;
7477 if (!gPixmapMode)
75 gColorMode = false ;
78 {
79 gColorMode = false ;
80 gByteCount = 1;
81 }
82 else
83 gFastMode = true;
84
7685 strcpy(gFormat,"BitMap");
7786 }
7887 if (!strcmp (line, "P2"))
7988 {
89 DPRINTF("input format is P2: pgm (ascii)\n");
8090 image->version = P2_PGM;
8191 if (!gPixmapMode)
82 gColorMode = false ;
92 {
93 gColorMode = false ;
94 gByteCount = 1;
95 }
96 else
97 gFastMode = true;
98
8399 strcpy(gFormat,"GreyMap");
84100 }
85101 if (!strcmp (line, "P3"))
86102 {
103 DPRINTF("input format is P3: ppm (ascii)\n");
87104 image->version = P3_PPM;
88105 strcpy(gFormat,"PixMap");
89106 }
90107 if (!strcmp (line, "P4"))
91108 {
109 DPRINTF("input format is P4: pbm (binary)\n");
92110 image->version = P4_PBMRAW;
93111 if (!gPixmapMode)
94 gColorMode = false ;
112 {
113 gColorMode = false ;
114 gByteCount = 1;
115 }
116 else
117 gFastMode = true;
118
95119 strcpy(gFormat,"BitMap");
96120 }
97121 if (!strcmp (line, "P5"))
98122 {
123 DPRINTF("input format is P5: pgm (binary)\n");
99124 image->version = P5_PGMRAW;
100125 if (!gPixmapMode)
101 gColorMode = false ;
126 {
127 gColorMode = false ;
128 gByteCount = 1;
129 }
130 else
131 gFastMode = true;
102132 strcpy(gFormat,"GreyMap");
103133 }
104134 if (!strcmp (line, "P6"))
105135 {
136 DPRINTF("input format is P6: ppm (binary)\n");
106137 image->version = P6_PPMRAW;
107138 strcpy(gFormat,"PixMap");
108139 }
109140 if (image->version == none)
110141 {
142 DPRINTF("input format is not recognized as PNM\n");
111143 snprintf(syslog_message,message_size,"initImage(): %s",
112144 gMessages[E_IM_BADFORMAT] );
113145 wrap_syslog (LOG_CRIT,"%s",syslog_message);
114146 return 0;
115147 }
148
116149
150
117151 /* initialize switch that is used to terminate further printing
118152 * if EOF is detected while reading the input image
119153 */
120154
121155 gTerminate = false ;
122156
123 do
157 do {
124158 if (fgets (line, 1024, fptr) == NULL)
125159 return 0;
126 while (line[0] == '#');
160 line[strlen (line) - 1] = 0;
161 if (!strcmp (line, "# pnm2ppa calibration image")){
162 gCalibrate = true;
163 g300 = false;
164 DPRINTF("initImage(): Calibration Page input detected!\n");
165 }
166 } while (line[0] == '#');
127167 if (2 != sscanf (line, "%d %d", &image->width, &image->height))
128168 return 0;
129169
134174 * will only be uses for calibration or gamma correction output
135175 * which is not generated by pnm imput
136176 */
177
178
179 /* if we treat the input as 300dpi, double image dimensions */
180 if(g300) {
181 DPRINTF("300dpi input mode\n");
182 image->width *= 2;
183 image->height *= 2;
184 }
137185
138186 gWidth = image->width ;
139187 gHeight = image->height ;
184232
185233 image->colors = colors ;
186234
187 DPRINTF( "initImage: width=%d, height=%d, colors = %d\n",
188 image->width, image->height, image->colors);
235 DPRINTF( "initImage: width=%d, height=%d, colors = %d,"
236 " ByteCount = %d\n",
237 image->width, image->height, image->colors, gByteCount);
189238
190239 }
191240 /* initialize buffer */
212261 {
213262 int linesize;
214263 unsigned char *newbuf;
215 // size_t newsize;
264 /* size_t newsize; */
216265 int newsize ;
217266 int k;
218267
242291 return 0;
243292 }
244293
245 // calculate the number of bits and add one to double the needed memory
246 // size.
294 /* calculate the number of bits and add one to double the needed memory
295 size.*/
247296 newsize = pow(2, (int)((log(image->buflines * linesize + bytes)/log(2))+1));
248297
249298 DPRINTF("resizing memory from %d bytes to %d bytes\n",
269318 }
270319
271320
272
273 void
274 convert_black_data (image_t *image, unsigned char *line, unsigned char *black)
321 BOOLEAN
322 convert_black_data (image_t *image, unsigned char *line, unsigned char *black,
323 BOOLEAN line_is_nonblank)
275324 {
276325 /* Lets document this - please correct anything incorrect here!
277326 (duncan, Feb 12 2000, updated July 2000)
307356
308357 - whitespace is coded by (255,255,255).
309358
359 - triplication of bytes is switched off when gByteCount == 1
360
310361 Color data is only printed on even lines.
311362
312363 Black data is printed on even and odd lines,
316367 the next even line.
317368 */
318369
370 /*
371 FEB 2002 (duncan)
372 try to clean this up for pictures vs. text.
373 identify regions of black surrounded by white space as text ONLY
374 if they are less that "textwidth" dots wide. Otherwise, they are
375 treated as part of an image, and will try to use both ink types,
376 if any color was found on the line.
377 */
319378
320379 int i, j, k;
321380 unsigned char mask = 0x80;
322381 unsigned char *pos = black;
323382 int blackness ;
324
325 unsigned char curr_stuff= 0 ; // 0 = white, 1 = not white (current pixel)
383 BOOLEAN use_color = false;
384 BOOLEAN has_black = false;
385
386 /* max_text_width is arbitary: make it configurable?
387 textwidth = maximum width of a black region that is printed
388 only with black ink when color is present on the line,
389 on the assumption it is text, not image.
390 */
391 const int max_text_width = 8; /* color dots at 300dpi */
392
393
394
395 unsigned char curr_stuff= 0 ;/* 0 = white, 1 = not white (current pixel)*/
326396 unsigned char remove_black = 1, have_color = 0;
327 unsigned char first_black=0 , second_black=0 ; //controls black ink density
397 unsigned char first_black=0 , second_black=0 ; /*controls black ink density*/
328398
329399 blackness = gBlackness ;
330400 j = image->bufferCurLine ;
356426 }
357427 else
358428 {
359 // first_black = 0 ; /* even lines */
360 // second_black = 1 ;
429 #if 0
430 first_black = 0 ; /* even lines */
431 second_black = 1 ;
432 #endif
361433 /* treat odd and even lines the same, to avoid artifacts?*/
362434 first_black = 1 ; /* even lines */
363435 second_black = 0 ;
388460 /* In Pixmap mode black ink cartridge is disabled (this should
389461 be renamed to (say) NoBlack mode ) */
390462
391 if (gPixmapMode)
463 if (gPixmapMode || !line_is_nonblank)
392464 memset (pos, 0x00, (image->width + 7) / 8);
393465 else
394466 {
395 if (gColorMode)
467 if (gColorMode && gByteCount ==3 )
468 /* beginning of code that assumes gByteCount == 3 */
396469 {
397470 /* This is the most delicate situation, we (may) have both color
398471 * and black on the same line;
402475 * neither too sparse...)
403476 */
404477
478 /* check for presence of color in the line */
479
480 for (i = 0; i < image->width * 3; i += 6)
481 {
482 if (line[i] != line[i+1] || line[i+1] != line[i+2])
483 {
484 use_color = true;
485 break;
486 }
487 }
488
405489 curr_stuff=0;
406490
407491 for (i = 0; i < image->width * 3; i += 6)
411495
412496 if (curr_stuff==0)
413497 {
498 int black_width = 0;
414499 /* this is a test to see if the current non-whitespace
415500 * pixel is part of a region of black delineated by
416501 * whitespace (have_color=0)
417502 * or is in a region containing some
418503 * colored pixels (in this case have_color=1)
419504 */
420 if (! (line[i]>gMaxPass && //if line is not white
505 if (! (line[i]>gMaxPass && /*if line is not white*/
421506 line[i+1]> gMaxPass &&
422507 line[i+2]>gMaxPass) )
423508 {
509
424510 have_color=0;
425511 k=i;
426512 while ( (!(have_color)) &&
435521 have_color=1;
436522
437523 k+=6;
524 black_width++;
525 /* treat wide black regions as having color */
526 if (use_color && black_width > max_text_width)
527 have_color=1;
438528 }
439529 if (have_color)
440530 remove_black=0;
443533 curr_stuff=1;
444534 }
445535 }
536
446537
447538 if ( !(line[i] || line[i + 1] || line[i + 2]))
448539 {
452543 * these behaviors may need some further
453544 * adjustments.
454545 */
455 if (remove_black)
546 if (gCalibrate || remove_black)
456547 {
457548 /* in this case the black region is
458549 * identified as delineated by whitespace
532623 mask = 0x80;
533624 }
534625 }
535 }
536 else
626 } /* end of code that assumes gByteCount == 3 */
627
628 else /* !gColorMode, gByteCount could be 1 or 3 */
537629 {
538630 /* this next part is for printing in black and white only.
539631 * if !gColorMode, the line contains only black or white, so
542634
543635 *pos = 0;
544636
545 for (i = 0 ; i < image->width * 3; i += 6)
637 for (i = 0 ; i < image->width *gByteCount ; i += 2*gByteCount )
546638 {
547639 if (mask == 0x80)
548640 *pos = 0;
549641
550 if ((!line[i] && !line[i + 1] && !line[i + 2]))
642 if (!line[i]) /* black even pixel */
551643 {
552644 if (first_black && gBlack)
553645 *pos |= mask; /* one drop of black ink */
560652 if (second_black && gBlack)
561653 *pos |= mask; /* one drop of black ink */
562654 }
563 else
564 {
565 /* pixel is not black */
655 else /* blank even pixel */
656 {
566657 mask >>= 1;
567658 if (mask == 0)
568659 {
570661 mask = 0x80;
571662 }
572663 }
573 mask >>= 1;
664
665 mask >>= 1; /* odd pixels are left black */
574666 if (mask == 0)
575667 {
576668 pos++;
577669 mask = 0x80;
578670 }
579671 }
580 memset (line, 0xff, image->width * 3);
672 memset (line, 0xff, image->width );
581673 }
582674
583675 }
676
677 if (!(gPixmapMode || !line_is_nonblank)) {
678 unsigned char *p;
679 for (p = black; p <= pos; p++) {
680 if( *p ) {
681 has_black = true;
682 break;
683 }
684 }
685 }
686
687 return has_black;
584688 }
585689
586690
587 void
691 BOOLEAN
588692 convert_color_data (image_t *image, unsigned char *line,
589 unsigned char *color[], int c_off)
693 unsigned char *color[], int c_off,
694 BOOLEAN line_is_nonblank)
590695 {
591696 int i, k, j;
592697 unsigned char mask;
593698 unsigned char *pos;
699 BOOLEAN has_color = false;
594700
595701 j = 1;
596702 for (k = 0; k < gMaxPass; k++)
601707
602708 memset (pos, 0x00, (image->width / 2 + 7) / 8 * 3);
603709
604 for (i = 0; i < image->width * 3; i += 6)
605 {
606
607 if ((line[i] < gMaxPass - (k) + 1) && gCyan)
710 if (line_is_nonblank)
711 for (i = 0; i < image->width * 3; i += 6)
712 {
713
714 if ((line[i] < gMaxPass - k + 1) && gCyan)
608715 pos[0] |= mask;
609 if ((line[i + 1] < gMaxPass - (k) + 1) && gMagenta)
716 if ((line[i + 1] < gMaxPass - k + 1) && gMagenta)
610717 pos[1] |= mask;
611 if ((line[i + 2] < gMaxPass - (k) + 1) && gYellow)
612 pos[2] |= mask;
613
614 mask >>= 1;
615 if (mask == 0)
616 {
617 pos += 3;
618 mask = 0x80;
718 if ((line[i + 2] < gMaxPass - k + 1) && gYellow)
719 pos[2] |= mask;
720
721 mask >>= 1;
722 if (mask == 0)
723 {
724 pos += 3;
725 mask = 0x80;
726 }
619727 }
728
729
730
731 if (line_is_nonblank && k == 0) {
732 unsigned char *p;
733 for (p = &color[gMaxPass -1][c_off]; p <= pos; p++) {
734 if( *p) {
735 has_color = true;
736 break;
737 }
738 }
739
620740 }
621741 }
742 return has_color;
622743 }
623744
624 /* Drugo */
625
626745 /* read a line of data from the file and convert to the necessary format */
627 void
746 BOOLEAN
628747 read_line (image_t * image, unsigned char *black[], int b_off,
629748 unsigned char *color[], int c_off)
630749 {
631 static unsigned char *line, *oldline; /* take care to free these! */
750 static unsigned char *oldline = NULL; /* take care to free this! */
751 unsigned char *prevline = NULL; /* take care to free this! */
752 unsigned char *line = NULL; /* take care to free this! */
632753 int i, j, k ;
633754 int fread_eof = 0;
634 static int have_oldline = 0;
635
636 line = malloc (image->width * 3);
755 BOOLEAN line_is_nonblank = true;
756 static BOOLEAN prevline_is_nonblank = true;
757 int image_width = image->width;
758 const BOOLEAN repeat_line = (g300 && image->bufferCurLine %2);
759
760 /*
761 for 300dpi input (g300 is true) ,
762 the data is duplicated horizontally and vertically
763 to convert it to 600dpi format.
764 odd lines are copies of the preceeding even line,
765 which was stored as "oldline" :
766 */
767 if(g300) {
768 image_width /= 2;
769 if (repeat_line) {
770 /* in 300dpi input mode,
771 the data from the previous even line should be used again
772 for this odd line*/
773 assert(oldline);
774 line = oldline;
775 oldline = NULL;
776 }
777 }
637778
638 if (!line)
639 {
640 /* make this nicer... propagate upwards */
641 snprintf(syslog_message,message_size, "read_line(): %s",
642 gMessages[E_BADMALLOC]);
643 wrap_syslog (LOG_CRIT,"%s",syslog_message);
644 if (have_oldline)
645 free (oldline);
646 exit (1);
647 }
648
649
779 if(!line)
780 if (!(line = malloc (image->width * gByteCount)))
781 {
782 /* make this nicer... propagate upwards */
783 snprintf(syslog_message,message_size, "read_line(): %s",
784 gMessages[E_BADMALLOC]);
785 wrap_syslog (LOG_CRIT,"%s",syslog_message);
786 if (oldline)
787 free (oldline);
788 exit (1);
789 }
790
791
650792 /* All the six pnm input formats
651 * (pbm, pbmraw, pgm, pgmraw, pbm, pbmraw )
793 * (pbm, pbmraw, pgm, pgmraw, ppm, ppmraw )
652794 * can be read from the input, and converted to
653795 * ppmraw format for further processing.
654796 */
655797
656798
657 if (!gGammaMode && !gTerminate)
799 if (!gGammaMode && !gTerminate && !repeat_line)
658800 {
659801 switch (image->version)
660802 {
661803 /* for completeness, the non-raw pnm formats are supported */
662804 case P1_PBM:
663 for ( i = 0 ; i < image->width * 3 ; )
664 switch( getc( image->fptr ) )
665 {
666 case EOF:
667 snprintf(syslog_message,message_size, "read_line(): %s PBM\n",
668 gMessages[E_IM_EOFREADLINE]);
669 wrap_syslog (LOG_CRIT,"%s",syslog_message);
670
671 /* input data is truncated; set gTerminate mode
672 * and replace lost part of image with whitespace
673 * until print run ends.
674 */
675 gTerminate = true ;
676 break;
677 case '1':
678 line[i] = line[i + 1]= line[i + 2] = 0;
679 i += 3 ;
680 break;
681 case '0':
682 line[i] = line[i + 1]= line[i + 2] = 255;
683 i += 3 ;
684 break;
685 default :
686 break;
687 }
688 break;
689 case P2_PGM:
690 {
691 /* This is included for completeness,
692 * but this implementation s PAINFULLY slow !
693 * is there a better way?
694 * (YES, USE THE PGMRAW FORMAT ONLY !)
695 */
696 unsigned int value ;
697 for ( i = 0 ; i < image->width * 3 ; i += 3 )
698 {
699 switch (fscanf(image->fptr, "%u ", &value ) )
700 {
701 case '1':
702 break ;
703 case EOF:
704 snprintf(syslog_message,message_size,"read_line(): %s PGM\n",
705 gMessages[E_IM_EOFREADLINE]);
706 wrap_syslog (LOG_CRIT,"%s",syslog_message);
707
708 /* input data is truncated; set gTerminate mode
709 * and replace lost part of image with whitespace
710 * until print run ends.
711 */
712 gTerminate = true ;
713 break;
714 default:
715 snprintf(syslog_message,message_size,"read_line(): %s",
716 gMessages[E_IM_BADREADLINE]);
717 wrap_syslog (LOG_CRIT,"%s",syslog_message);
718 free (line);
719 if (have_oldline)
720 free (oldline);
721 exit (1);
722 break;
723 }
724 if(value <= 255)
725 line[i] = line[i + 1] = line[i + 2] = value ;
726 else
727 {
728 snprintf(syslog_message,message_size,"read_line(): %s",
729 gMessages[E_IM_BADIMAGE]);
730 wrap_syslog (LOG_CRIT,"%s",syslog_message);
731 free (line);
732 if (have_oldline)
733 free (oldline);
734 exit (1);
735 }
736 }
737 }
738 break;
739 case P3_PPM:
740 {
805 {
806 /* read pbm format; convert to ppm format if gByteCount = 3 */
741807 /* This is included for completeness,
742808 * but this implementation is PAINFULLY slow !
743809 * is there a better way?
744810 * (YES, USE THE PPMRAW FORMAT ONLY !)
745811 */
812 int index = 0;
813 int incr = gByteCount;
814 if(g300)
815 incr *= 2;
816 for ( i = 0 ; i < image_width ; )
817 {
818 switch( getc( image->fptr ) )
819 {
820 case EOF:
821 snprintf(syslog_message,message_size, "read_line(pbm,ascii): %s PBM\n",
822 gMessages[E_IM_EOFREADLINE]);
823 wrap_syslog (LOG_CRIT,"%s",syslog_message);
824
825 /* input data is truncated; set gTerminate mode
826 * and replace lost part of image with whitespace
827 * until print run ends.
828 */
829 gTerminate = true ;
830 break;
831 case '1':
832 line[index] = 0;
833 index += incr;
834 i ++;
835 break;
836 case '0':
837 line[index] = 255;
838 index += incr;
839 i ++;
840 break;
841 default :
842 break;
843 }
844 }
845 if(g300) {
846 for ( j = 0 ; j < index ; j += incr )
847 line[j+gByteCount] = line[j];
848 }
849 if (gByteCount == 3) {
850 for (j = 0; j < index ; j += 3 )
851 line[j + 2]= line[j + 1] = line[j];
852 }
853 }
854 break;
855 case P2_PGM:
856 {
857 /* read pgm format; convert to ppm format if gByteCount = 3 */
858 /* This is included for completeness,
859 * but this implementation is PAINFULLY slow !
860 * is there a better way?
861 * (YES, USE THE PGMRAW FORMAT ONLY !)
862 */
863 int index = 0;
746864 unsigned int value ;
747 for ( i = 0 ; i < image->width * 3 ; i ++ )
748 {
749 switch (fscanf(image->fptr, "%u ", &value ) )
750 {
751 case '1':
865 int incr = gByteCount;
866 if(g300)
867 incr *= 2;
868 for ( i = 0 ; i < image_width ; i ++ )
869 {
870 switch(fscanf(image->fptr, "%u ", &value ))
871 {
872 case 1:
752873 break ;
753874 case EOF:
754 snprintf(syslog_message,message_size,"read_line(): %s PPM\n",
875 snprintf(syslog_message,message_size,"read_line(pgm,ascii): %s PGM\n",
755876 gMessages[E_IM_EOFREADLINE]);
756877 wrap_syslog (LOG_CRIT,"%s",syslog_message);
757
878
758879 /* input data is truncated; set gTerminate mode
759880 * and replace lost part of image with whitespace
760881 * until print run ends.
762883 gTerminate = true ;
763884 break;
764885 default:
765 snprintf(syslog_message,message_size,"read_line(): %s",
886 snprintf(syslog_message,message_size,"read_line(pgm,ascii): %s",
766887 gMessages[E_IM_BADREADLINE]);
767888 wrap_syslog (LOG_CRIT,"%s",syslog_message);
768889 free (line);
769 if (have_oldline)
890 line = NULL;
891 if (oldline) {
892 free (oldline);
893 oldline = NULL;
894 }
895 exit (1);
896 break;
897 }
898 if(value <= 255)
899 {
900 line[index] = value;
901 index += incr;
902 }
903 else
904 {
905 snprintf(syslog_message,message_size,"read_line(pgm,ascii): %s",
906 gMessages[E_IM_BADIMAGE]);
907 wrap_syslog (LOG_CRIT,"%s",syslog_message);
908 free (line);
909 if (oldline)
910 free (oldline);
911 exit (1);
912 }
913 }
914 if(g300) {
915 for ( j = 0 ; j < index ; j += incr )
916 line[j+gByteCount] = line[j];
917 }
918 if (gByteCount == 3) {
919 for (j = 0; j < index ; j += 3 )
920 line[j + 2]= line[j + 1] = line[j];
921 }
922 }
923 break;
924 case P3_PPM:
925 {
926 /* read pbm format */
927 /* This is included for completeness,
928 * but this implementation is PAINFULLY slow !
929 * is there a better way?
930 * (YES, USE THE PPMRAW FORMAT ONLY !)
931 */
932 unsigned int value ;
933 int index = 0;
934 assert(gByteCount == 3);
935 for ( i = 0 ; i < image_width * 3 ; i ++ )
936 {
937 switch (fscanf(image->fptr, "%u ", &value ) )
938 {
939 case 1:
940 break ;
941 case EOF:
942 snprintf(syslog_message,message_size,"read_line(ppm,ascii): %s PPM\n",
943 gMessages[E_IM_EOFREADLINE]);
944 wrap_syslog (LOG_CRIT,"%s",syslog_message);
945
946 /* input data is truncated; set gTerminate mode
947 * and replace lost part of image with whitespace
948 * until print run ends.
949 */
950 gTerminate = true ;
951 break;
952 default:
953 snprintf(syslog_message,message_size,"read_line(ppm,ascii): %s",
954 gMessages[E_IM_BADREADLINE]);
955 wrap_syslog (LOG_CRIT,"%s",syslog_message);
956 free (line);
957 if (oldline)
770958 free (oldline);
771959 exit (1);
772960 break;
773961 }
774 if(value <= 255)
775 line[i] = value ;
962 if(value <= 255){
963 if (g300) {
964 line[index+3] = line[index] = value;
965 index++;
966 if(!(index %3))
967 index+=3;
968 } else {
969 line[index] = value ;
970 index ++;
971 }
972 }
776973 else
777974 {
778 snprintf(syslog_message,message_size,"read_line() %s",
975 snprintf(syslog_message,message_size,"read_line(ppm,ascii) %s",
779976 gMessages[E_IM_BADIMAGE]);
780977 wrap_syslog (LOG_CRIT,"%s",syslog_message);
781978 free (line);
782 if (have_oldline)
979 if (oldline)
783980 free (oldline);
784981 exit (1);
785982 }
787984 }
788985 break;
789986 case P4_PBMRAW:
790 /* read pbmraw format and convert to ppmraw format */
791 {
792 int pbm_width, count, index ;
793 char* pbmraw_data;
794 unsigned char mask[8] =
987 /* read pbmraw format; convert to ppm format if gByteCount = 3 */
988 {
989 int pbm_width, count, index=0;
990 int incr = gByteCount;
991 char* pbmraw_data;
992 unsigned char mask[8] =
795993 { 0x80, 0x40, 0x20, 0x10, 0x08, 0x04, 0x02, 0x01 };
796 pbm_width = ( image->width + 7 ) / 8;
797
798 if (! (pbmraw_data = malloc(pbm_width)) )
799 {
800 snprintf(syslog_message,message_size,"read_line(): %s",
801 gMessages[E_BADMALLOC]);
802 wrap_syslog (LOG_CRIT,"%s",syslog_message);
803 if (have_oldline)
804 free (oldline);
805 free (line);
806 exit (1);
807 }
808
809 count = fread(pbmraw_data, 1 , pbm_width, image->fptr);
810 if (pbm_width == count)
811 {
812 /* success */
813 /* pbm raw format: 0=white, 1=black;
814 * bits are stored eight per byte, high bit
815 * first, low bit last.
816 */
817 index = 0;
818 for ( i = 0 ; i < image->width ; i ++ )
819 {
820 k = i % 8 ;
821 j = i / 8 ;
822 if ( pbmraw_data[j] & mask[k] )
823 line[index] = line[index + 1] = line[index + 2] = 0 ;
824 else
825 line[index] = line[index + 1] = line[index + 2] = 255; ;
826 index += 3;
827 }
828 free(pbmraw_data);
829 }
830 else
831 {
832 /* error reading line */
833 free(pbmraw_data);
834 fread_eof=feof(image->fptr);
835 clearerr(image->fptr);
836 if (fread_eof)
837 {
838 snprintf(syslog_message,message_size,"read_line(): %s PBMRAW\n",
994 pbm_width = ( image_width + 7 ) / 8;
995
996 if(g300)
997 incr *= 2;
998 if (! (pbmraw_data = malloc(pbm_width)) )
999 {
1000 snprintf(syslog_message,message_size,"read_line(pbmraw): %s",
1001 gMessages[E_BADMALLOC]);
1002 wrap_syslog (LOG_CRIT,"%s",syslog_message);
1003 if (oldline)
1004 free (oldline);
1005 free (line);
1006 exit (1);
1007 }
1008
1009 count = fread(pbmraw_data, 1 , pbm_width, image->fptr);
1010 if (pbm_width == count)
1011 {
1012 /* success */
1013 /* pbm raw format: 0=white, 1=black;
1014 * bits are stored eight per byte, high bit
1015 * first, low bit last.
1016 */
1017 index = 0;
1018 for ( i = 0 ; i < image_width ; i ++ )
1019 {
1020 k = i % 8 ;
1021 j = i / 8 ;
1022 if ( pbmraw_data[j] & mask[k] )
1023 line[index] = 0;
1024 else
1025 line[index] = 255;
1026 index += incr;
1027 }
1028 free(pbmraw_data);
1029 }
1030 else
1031 {
1032 /* error reading line */
1033 free(pbmraw_data);
1034 fread_eof=feof(image->fptr);
1035 clearerr(image->fptr);
1036 if (fread_eof)
1037 {
1038 snprintf(syslog_message,message_size,"read_line(pbmraw): %s PBMRAW\n",
8391039 gMessages[E_IM_EOFREADLINE]);
8401040 wrap_syslog (LOG_CRIT,"%s",syslog_message);
841
842 /* input data is truncated; set gTerminate mode
843 * and replace lost part of image with whitespace
844 * until print run ends.
845 */
846 gTerminate = true ;
847 }
848 else
849 {
850 snprintf(syslog_message,message_size,"read_line(): %s",
1041
1042 /* input data is truncated; set gTerminate mode
1043 * and replace lost part of image with whitespace
1044 * until print run ends.
1045 */
1046 gTerminate = true ;
1047 }
1048 else
1049 {
1050 snprintf(syslog_message,message_size,"read_line(pgmraw): %s",
8511051 gMessages[E_IM_BADREADLINE]);
8521052 wrap_syslog (LOG_CRIT,"%s",syslog_message);
853 free (line);
854 if (have_oldline)
855 free (oldline);
856 exit (1);
857 }
858 }
859 }
860
1053 free (line);
1054 if (oldline)
1055 free (oldline);
1056 exit (1);
1057 }
1058 }
1059 if(g300) {
1060 for ( j = 0 ; j < index ; j += incr )
1061 line[j + gByteCount] = line[j];
1062 }
1063 if (gByteCount == 3) {
1064 for (j = 0; j < index ; j += 3 )
1065 line[j + 2]= line[j + 1] = line[j];
1066 }
1067 }
8611068 break;
8621069 case P5_PGMRAW:
8631070
864 /* read pgmraw format and convert to ppmraw format */
865 {
866 int index ;
1071 /* read pgmraw format; convert to ppm format if gByteCount = 3 */
1072 {
1073 int index=0 ;
8671074 char* pgm_data;
868
869 pgm_data = malloc(image->width);
1075 int incr = gByteCount;
1076 if(g300)
1077 incr *= 2;
1078 pgm_data = malloc(image_width);
8701079 if (!pgm_data)
8711080 {
872 snprintf(syslog_message,message_size,"read_line(): %s",
1081 snprintf(syslog_message,message_size,"read_line(pgmraw): %s",
8731082 gMessages[E_BADMALLOC]);
8741083 wrap_syslog (LOG_CRIT,"%s",syslog_message);
8751084 free (line);
876 if (have_oldline)
1085 if (oldline)
8771086 free (oldline);
8781087 exit (1);
8791088 }
880 if ( 1 == fread (pgm_data, image->width , 1, image->fptr) )
1089 if ( 1 == fread (pgm_data, image_width , 1, image->fptr) )
8811090 {
8821091 /* success */
8831092 index = 0 ;
884 for ( i = 0 ; i < image->width ; i ++ )
885 {
886 line[index] = line[index + 1] = line[index + 2]
887 = pgm_data[i] ;
888 index += 3;
1093 for ( i = 0 ; i < image_width ; i ++ )
1094 {
1095 line[index] = pgm_data[i] ;
1096 index += incr;
8891097 }
8901098 free(pgm_data);
8911099 }
8971105 clearerr(image->fptr);
8981106 if (fread_eof)
8991107 {
900 snprintf(syslog_message,message_size,"read_line:() %s PGMRAW\n",
1108 snprintf(syslog_message,message_size,"read_line:(pgmraw) %s PGMRAW\n",
9011109 gMessages[E_IM_EOFREADLINE]);
9021110 wrap_syslog (LOG_CRIT,"%s",syslog_message);
9031111
9091117 }
9101118 else
9111119 {
912 snprintf(syslog_message,message_size,"read_line(): %s",
1120 snprintf(syslog_message,message_size,"read_line(pgmraw): %s",
9131121 gMessages[E_IM_BADREADLINE]);
9141122 wrap_syslog (LOG_CRIT,"%s",syslog_message);
9151123 free (line);
916 if (have_oldline)
1124 if (oldline)
9171125 free (oldline);
9181126 exit (1);
9191127 }
9201128 }
1129
1130 if(g300) {
1131 for (j = 0 ; j < index ; j += incr )
1132 line[j + gByteCount] = line[j];
1133 }
1134 if (gByteCount == 3){
1135 for (j = 0; j < index ; j += 3 )
1136 line[j + 2]= line[j + 1] = line[j];
1137 }
9211138 }
9221139 break;
9231140 case P6_PPMRAW:
924 if (1 != fread (line, image->width * 3, 1, image->fptr) )
925 {
926 fread_eof=feof(image->fptr);
927 clearerr(image->fptr);
928 if (fread_eof)
929 {
930 snprintf(syslog_message,message_size,"read_line(): %s PPMRAW\n",
931 gMessages[E_IM_EOFREADLINE]);
932 wrap_syslog (LOG_CRIT,"%s",syslog_message);
933
934 /* input data is truncated; set gTerminate mode
935 * and replace lost part of image with whitespace
936 * until print run ends.
937 */
938 gTerminate = true ;
1141 /* read ppmraw format */
1142 {
1143 assert(gByteCount == 3);
1144 if (1 != fread (line, image_width * 3, 1, image->fptr) )
1145 {
1146 fread_eof=feof(image->fptr);
1147 clearerr(image->fptr);
1148 if (fread_eof)
1149 {
1150 snprintf(syslog_message,message_size,"read_line(ppmraw):%s \n",
1151 gMessages[E_IM_EOFREADLINE]);
1152 wrap_syslog (LOG_CRIT,"%s",syslog_message);
1153
1154 /* input data is truncated; set gTerminate mode
1155 * and replace lost part of image with whitespace
1156 * until print run ends.
1157 */
1158 gTerminate = true ;
1159 }
1160 else
1161 {
1162 snprintf(syslog_message,message_size,"read_line(ppmraw): %s",
1163 gMessages[E_IM_BADREADLINE]);
1164 wrap_syslog (LOG_CRIT,"%s",syslog_message);
1165 free (line);
1166 if (oldline)
1167 free (oldline);
1168 exit (1);
1169 }
1170 }
1171 /* if input data was at 300dpi, expand it to 600dpi format */
1172 if(g300) {
1173 int j,k;
1174 for ( i = image_width - 1 ; i > 0 ; i--) {
1175 j = 3 * i ;
1176 k = 2 * j;
1177 line[ k + 3 ] = line[ k ] = line[ j ];
1178 line[ k + 4 ] = line[ k + 1 ] = line[ j + 1 ];
1179 line[ k + 5 ] = line[ k + 2 ] = line[ j + 2 ];
9391180 }
940 else
941 {
942 snprintf(syslog_message,message_size,"read_line(): %s",
943 gMessages[E_IM_BADREADLINE]);
944 wrap_syslog (LOG_CRIT,"%s",syslog_message);
945 free (line);
946 if (have_oldline)
947 free (oldline);
948 exit (1);
949 }
950 }
1181 line[3] = line[0];
1182 line[4] = line[1];
1183 line[5] = line[2];
1184 }
1185 }
9511186 break;
9521187 case none:
9531188 default:
954 snprintf(syslog_message,message_size,"read_line(): %s",
1189 snprintf(syslog_message,message_size,"read_line(?): %s",
9551190 gMessages[E_IM_BADFORMAT]);
9561191 wrap_syslog (LOG_CRIT,"%s",syslog_message);
9571192 free (line);
958 if (have_oldline)
1193 if (oldline)
9591194 free (oldline);
9601195 exit (1);
9611196 break;
962 }
1197 }
9631198 }
9641199 else if (gGammaMode)
9651200 ProduceGamma (image, line ) ; /* generate color calibration page */
1201
1202 if ( gTerminate ||
1203 image->bufferCurLine < image->top ||
1204 image->bufferCurLine >= image->height - image->bottom ) {
1205 /*
1206 * gTerminate becomes true if EOF was obtained when a line was read .
1207 * The input image is incomplete .
1208 * Print only previously-read complete lines.
1209 * unread lines are replaced with blanks for the rest of the print run
1210 *
1211 * also blank out lines above the top margin,
1212 * or below the bottom margin.
1213 */
1214 line_is_nonblank = false;
1215 memset(line, 0xff, image->width * gByteCount);
1216 }
1217
1218 if(line_is_nonblank) {
1219 if (repeat_line)
1220 line_is_nonblank = prevline_is_nonblank ;
1221 else {
1222 /* crop image to left and right margins */
1223 int imin = 0, imax = image->width * gByteCount;
1224 if(image->left > 0) {
1225 imin = image->left * gByteCount;
1226 memset(line,0xff, imin);
1227 }
1228 if(image->right > 0) {
1229 imax = (image->width - image->right) * gByteCount;
1230 memset(line + imax, 0xff, image->right * gByteCount);
1231 }
1232 /* check if cropped line is really nonblank */
1233 line_is_nonblank = false;
1234 for ( i = imin ; i < imax ; i++ ) {
1235 if (line[i] != 255) {
1236 line_is_nonblank = true;
1237 break;
1238 }
1239 }
1240 }
1241 }
1242
9661243
967 if ( gTerminate )
968 {
969 /* this becomes true if EOF was obtained when a line was read .
970 * The input image is incomplete .
971 * Print only previously-read complete lines.
972 * unread lines are replaced with blanks for the rest of the print run
973 */
974 int index ;
975 index = 0 ;
976 for ( i = 0 ; i < image->width ; i ++ )
977 {
978 line[index] = line[index + 1] = line[index + 2] = 255; ;
979 index += 3;
980 }
1244 /* mark line as read */
1245 image->LineType[image->bufferCurLine] =
1246 image->LineType[image->bufferCurLine] | READLINE;
1247
1248
1249 if (!gTerminate && g300 && !repeat_line){
1250 /* in 300dpi mode, store the data when bufferCurLine is even,
1251 to use it again for the next odd line at 600dpi */
1252
1253 if (!(prevline = malloc (image->width * gByteCount))) {
1254 /* make this nicer... propagate upwards */
1255 snprintf(syslog_message,message_size, "read_line(): %s",
1256 gMessages[E_BADMALLOC]);
1257 wrap_syslog (LOG_CRIT,"%s",syslog_message);
1258 free(line);
1259 if (oldline)
1260 free (oldline);
1261 exit (1);
9811262 }
9821263
983
1264 prevline_is_nonblank = line_is_nonblank;
1265 if (prevline_is_nonblank)
1266 memcpy(prevline, line, image->width * gByteCount);
1267 else
1268 memset(prevline, 0xff, image->width * gByteCount);
1269 }
9841270
985 /* process ALL lines to avoid artifacts
1271
1272 /* just to be safe ... */
1273 if(gTerminate && oldline) {
1274 free(oldline);
1275 oldline = NULL;
1276 }
1277
1278 /* process ALL non-blank lines to avoid artifacts
9861279 (odd lines are only processed for black in *_Dither() functions )
9871280 hopefully, this minimal processing is quite fast */
9881281
989 if (gColorMode)
990 {
991 if (gFastMode)
992 HT_Color_Dither (image, line);
993 else
994 FS_Color_Dither (image, line);
995 }
996 else
997 HT_Black_Dither (image, line);
9981282
999 /* if the current line is odd, we only need to return black data */
1283 if(line_is_nonblank) {
1284 image->LineType[image->bufferCurLine] =
1285 image->LineType[image->bufferCurLine] | NONBLANK;
1286 if (gColorMode)
1287 {
1288 if (gFastMode)
1289 HT_Color_Dither (image, line);
1290 else
1291 FS_Color_Dither (image, line);
1292 }
1293 else
1294 HT_Black_Dither (image, line);
1295 }
1296
1297
1298
1299 /* if the current line is odd, we only need to return black data */
10001300 if (image->bufferCurLine % 2 == 1)
10011301 {
10021302 if ( (!gEcoMode || gColorMode) && !gPixmapMode )
10031303 {
1004 convert_black_data (image, line, &black[0][b_off]);
1304 if (convert_black_data
1305 (image, line, &black[0][b_off],line_is_nonblank))
1306 image->LineType[image->bufferCurLine] =
1307 image->LineType[image->bufferCurLine] | BLACKLINE;
10051308 }
10061309 else
10071310 {
10121315 if ( image->bufferCurLine + 1 < image->height )
10131316 {
10141317 memset(&black[0] [b_off], 0x00, (image->width +7 ) / 8 );
1015 oldline = malloc (image->width * 3);
1016 memcpy(oldline, line, image->width * 3 );
1017 have_oldline = 1;
1318 oldline = malloc (image->width * gByteCount);
1319 memcpy(oldline, line, image->width * gByteCount);
10181320 }
10191321 }
1020
1021
10221322 }
10231323 else
10241324 {
10251325 /* return both black and color data on even lines */
10261326 /* note that convert_color_data must be called AFTER convert_black_data */
1027 if ( have_oldline )
1327 if ( oldline )
10281328 {
10291329 /* add any black from previous unprinted odd line
10301330 to next even line */
1031 for ( i = 0; i < image->width * 3; i += 3 )
1331 if (gByteCount == 3)
10321332 {
1033 if ( !oldline[i] && !oldline[i + 1] && !oldline[i + 2] )
1333 for ( i = 0; i < image->width * 3; i += 3 )
10341334 {
1035 line[i] = line[i + 1] = line[i + 2] = 0 ;
1335 if ( !oldline[i] && !oldline[i + 1] && !oldline[i + 2] )
1336 line[i + 2] = line[i + 1] = line[i] = 0 ;
10361337 }
10371338 }
1339 else /* gByteCount = 1 */
1340 {
1341 for ( i = 0; i < image->width ; i ++ )
1342 {
1343 if ( !oldline[i] )
1344 line[i] = 0 ;
1345 }
1346 }
1347
10381348 free(oldline);
1039 have_oldline = 0;
1349 oldline = NULL;
10401350 }
10411351
1042
1043
1044 convert_black_data (image, line, &black[0][b_off]);
1352 if (convert_black_data
1353 (image, line, &black[0][b_off],line_is_nonblank))
1354 image->LineType[image->bufferCurLine] =
1355 image->LineType[image->bufferCurLine] | BLACKLINE;
1356
10451357 if (gColorMode)
1046 convert_color_data (image, line, color, c_off);
1358 if (convert_color_data
1359 (image, line, color, c_off,line_is_nonblank))
1360 image->LineType[image->bufferCurLine] =
1361 image->LineType[image->bufferCurLine] | COLORLINE;
10471362 }
10481363
10491364
10501365 free (line);
1051
1366
1367 if(prevline) {
1368 assert(!oldline);
1369 oldline = prevline;
1370 }
1371
1372
10521373 image->bufferCurLine++;
1053
1374
1375 return line_is_nonblank;
10541376 }
10551377
10561378 /* Drugo */
10621384 buffer_black_line (image_t *image, unsigned char *data[], int offset)
10631385 {
10641386 int lines, linesize = (image->width + 7) / 8;
1387 BOOLEAN nonblank = false;
1388 int curline = image->bufferCurLine;
1389
10651390
10661391 /* if the current line is odd, we need to read 2 black lines */
10671392 if (image->bufferCurLine % 2 == 1)
10681393 lines = 2;
10691394 else
1070 lines = 1; //mocho 1
1395 lines = 1;
10711396
10721397 remallocBuffer (image, linesize * lines);
10731398
10741399 /* read_line into buffer and 'data' */
10751400 read_line (image, image->buffer,
10761401 image->bufpos + image->buflines * linesize, data, offset);
1402 if (image->LineType[curline] & BLACKLINE)
1403 nonblank = true;
1404
10771405 image->buflines++;
10781406
10791407 /* if we have to read 2 lines, then we haven't gotten any color data yet */
10801408 if (lines == 2)
10811409 {
1082 read_line (image, image->buffer,
1083 image->bufpos + image->buflines * linesize, data, offset);
1084 image->buflines++;
1410 curline++;
1411 read_line (image, image->buffer,
1412 image->bufpos + image->buflines * linesize, data, offset);
1413 image->buflines++;
1414 if (image->LineType[curline] & BLACKLINE)
1415 nonblank = true;
10851416 }
10861417
1087 image->buftype = bitmap;
1418 /* if no black data exists in buffer, advance blackCurLine */
1419 if (image->buftype == empty && !nonblank ) {
1420 image->buflines = 0;
1421 image->blackCurLine += lines; ;
1422 } else
1423 image->buftype = bitmap;
10881424 }
10891425
10901426 /* buffer a color line and return black data */
10921428 buffer_color_line (image_t *image, unsigned char *data[], int offset)
10931429 {
10941430 int linesize = (image->width / 2 + 7) / 8 * 3;
1431 BOOLEAN nonblank = false;
1432 int curline = image->bufferCurLine;
10951433
10961434 /* if the current line is odd, we don't need to buffer any color data */
10971435 if (image->bufferCurLine % 2 == 1)
11061444
11071445 read_line (image, data, offset, image->buffer,
11081446 image->bufpos + image->buflines * linesize);
1447 if (image->LineType[curline] & COLORLINE)
1448 nonblank = true;
11091449 image->buflines++;
11101450
1111 image->buftype = color;
1451 /* if no color data exists in buffer, advance colorCurLine */
1452 if (image->buftype == empty && !nonblank ) {
1453 image->buflines = 0;
1454 image->colorCurLine += 2;
1455 } else
1456 image->buftype = color;
11121457 }
11131458
11141459 /* Reads a single line of black image data into data which must be at least
11701515 {
11711516 for (k = 0; k < gMaxPass; k++)
11721517 memcpy (data[k] + offset,
1173 &image->buffer[k][image->bufpos], 3 * ((image->width / 2 + 7) / 8)); //mocho changes /2
1174 image->bufpos += 3 * ((image->width / 2 + 7) / 8); //mocho changes /2
1518 &image->buffer[k][image->bufpos], 3 * ((image->width / 2 + 7) / 8));
1519 image->bufpos += 3 * ((image->width / 2 + 7) / 8);
11751520 image->buflines--;
11761521 if (image->buflines == 0)
11771522 {
11981543 memcpy (image->revdata, data, (image->width + 7) / 8);
11991544 image->blackCurLine--;
12001545 }
1546
2727 version;
2828 int width, height;
2929 int blackCurLine, colorCurLine, bufferCurLine;
30 void *revdata; // used to stash a line read too early
30 unsigned char *LineType;
31 int left, right, top, bottom;
32 void *revdata; /* used to stash a line read too early */
3133 int unread;
3234
3335 /* buffer */
4951 }
5052 image_t;
5153
54 /* values for image->LineType descriptions */
55 #define READLINE 0x01 /* line has been read */
56 #define NONBLANK 0x02 /* non blank line */
57 #define BLACKLINE 0x04 /* line has black ink */
58 #define COLORLINE 0x08 /* line has color ink */
59
60
5261 int initImage (image_t *, FILE *);
5362
5463 /* reads a single line into char* */
6363
6464
6565 #ifdef __PNM2PPA_C__
66 // only defined the once
66 /* only defined the once */
6767 char *gMessages[] = {
6868
6969 #ifdef LANG_CZ
9292 };
9393
9494 #else
95 // make the messages available to other files
95 /* make the messages available to other files */
9696 extern char *gMessages[];
9797 #endif
9898
2828 You must be root to do this:
2929
3030 cp gs-pnm2ppa /etc/pdq/drivers/ghostscript
31 cp dummy /etc/pdq/intefaces
31 cp dummy /etc/pdq/interfaces
3232
3333 Then run "xpdq" to setup the printer, selecting the driver "gs-pnm2ppa",
3434 and the interface "dummy". You must specify The local parallel printer port
5151 snprintf(syslog_message,message_size,"%s",
5252 gMessages[LOG_START]);
5353 wrap_syslog (LOG_INFO,"%s",syslog_message);
54
5554
5655 ppa_init_job (&printer);
5756
155154 a user-specifed file *File_path may later be opened;
156155 should any extra validation of this be performed now ?
157156 */
158 path = File_path;
157 /* remember to free(path) after use! */
158 path = strdup(File_path);
159159 return path;
160160 }
161161 }
176176 void
177177 set_printer_specific_defaults (void)
178178 {
179 if (printer.version != HP7X0 &&
179 if (printer.version != NOPRINTER && printer.version != HP7X0 &&
180180 printer.version != HP820 && printer.version != HP1000)
181181 {
182182 snprintf(syslog_message,message_size, "set_printer_defaults(): %s",
221221 printf (" --bw forces black/white output\n");
222222 printf (" -d dumps the configuration to stdout\n");
223223 printf (" --eco Econofast mode (uses less ink)\n");
224 printf (" --dpi300 Treat input resolution as 300dpi instead of 600dpi\n");
224225 printf (" -f <cfgfile> read printer settings from configuration file <cfgfile>\n");
225226 printf (" -F <gammaFile> read color correction table from file <gammaFile>\n");
226227 printf (" --fd use fast dithering mode\n");
264265 printf
265266 (" the corresponding command-line parameters.\n");
266267 printf
267 (" Other keys that can be set in the configuration file include:\n");
268 printf
269 (" 'silent', 'verbose', 'unimode', 'blackshear', 'colorshear',\n");
270 printf
271 (" 'RedGammaIdx','BlueGammaIdx', 'GreenGammaIdx',\n");
272 printf
273 (" 'GammaR', 'GammaG', 'GammaB', 'ColOffsX', 'ColOffsY',\n");
274 printf
275 (" 'black_ink', 'color_ink', 'cyan_ink', 'magenta_ink', 'yellow_ink';\n");
268 (" Other keys that can be only set in the configuration file include:\n");
269 printf
270 (" 'silent', 'verbose', 'log_info',\n");
271 printf
272 (" 'unimode', 'blackshear', 'colorshear',\n");
273 printf
274 (" 'RedGammaIdx','BlueGammaIdx', 'GreenGammaIdx',\n");
275 printf
276 (" 'GammaR', 'GammaG', 'GammaB',\n");
277 printf
278 (" 'ColOffsX', 'ColOffsY',\n");
279 printf
280 (" 'black_ink', 'color_ink', 'cyan_ink', 'magenta_ink', 'yellow_ink',\n");
281 printf
282 (" 'compression';\n");
276283 printf
277284 (" see documentation in the sample configuration file for their usage.\n\n");
278285 printf
292299 void
293300 parm_version (char *arg)
294301 {
295
296 if (!strncasecmp (arg, "error", 5))
297 {
298 wrap_closelog ();
299 wrap_openlog ("pnm2ppa", 1);
300 snprintf(syslog_message,message_size,"parm_version(): %s",
301 gMessages[E_CONFIG]);
302 wrap_syslog (LOG_CRIT,"%s",syslog_message);
303
304 exit (1);
305 }
306302
303
304
307305 if (!strcasecmp (arg, "hp720") || !strcmp (arg, "720") ||
308306 !strcasecmp (arg, "hp722") || !strcmp (arg, "722") ||
309307 !strcasecmp (arg, "hp710") || !strcmp (arg, "710") ||
328326 parm_iversion (int arg)
329327 {
330328 switch (arg)
331 {
329 {
330 case 0:
331 printer.version = NOPRINTER;
332 break;
332333 case 720:
333334 case 722:
334335 case 710:
529530 wrap_closelog();
530531 }
531532 }
533 else if (!strncmp (key, "log_info", len))
534 {
535 if (system_config_file) {
536 if ( value )
537 gLogInfo = true ;
538 else
539 gLogInfo = false ;
540 }
541 }
532542 else if (!strncmp (key, "verbose", len))
533543 {
534544 gVerbose = true;
568578 exit (1);
569579 }
570580 }
581 else if (!strncmp (key, "compression", len))
582 {
583 if ( value )
584 gCompress = true ;
585 else
586 gCompress = false ;
587 }
571588 else
572589 {
573590 snprintf(syslog_message,message_size,"read_config_file(): %s (%s %d)\n",
611628 char c;
612629 BOOLEAN get_Gamma = true;
613630
614 char *gammaFile=NULL;
615 char *pnm_inputFile=NULL;
616 char *ppa_outputFile=NULL;
631 char gammaFile[MAXPATHLEN];
632 char pnm_inputFile[MAXPATHLEN];
633 char ppa_outputFile[MAXPATHLEN];
617634 BOOLEAN use_stdin = false;
618635 BOOLEAN use_stdout = false;
619636 BOOLEAN got_Input = false;
624641
625642 system_config_file = true;
626643
627 #ifdef __BEOS__
644 #ifdef __NO_SYSLOG__
628645 gSilent = true;
629646 #endif
630647
631 gammaFile = defaultgammafile;
648 strncpy(gammaFile,defaultgammafile,MAXPATHLEN);
632649
633650 /* activate syslog */
634651 if (!(gSilent))
662679 gColorMode = true;
663680 gFastMode = false;
664681 gUnimode = false;
682 g300 = false;
683 gCompress = true;
684 gLogInfo = false; /* no LOG_INFO syslog messages by default */
665685 gBlack = true;
666686 gCyan = true;
667687 gMagenta = true;
679699
680700 system_config_file = false;
681701
682 // read through the optional arguments before tring to find filenames
702 /* read through the optional arguments before tring to find filenames */
683703
684704 while ((c = getopt_long (argc, argv, "F:B:b:df:ghi:l:o:pr:s:t:v:x:y:",
685705 long_opts, &opt_index)) != EOF)
687707 switch (c)
688708 {
689709 case 0:
690 // long options
710 /* long options */
691711 switch (opt_index)
692712 {
693713 case 0:
694 // --bw Black & White
714 /* --bw Black & White */
695715 gColorMode = false;
696 // gEcoMode = false; //this is not needed here (?) duncan
716 #if 0
717 gEcoMode = false; /*this is not needed here (?) duncan*/
718 #endif
697719 gMaxPass = 1;
698720 break;
699721
700722 case 1:
701 // --fd Fast Dither
723 /* --fd Fast Dither*/
702724 gFastMode = true;
703725 gMaxPass = 1;
704726 break;
705727
706728 case 2:
707 // --version
708 snprintf(syslog_message,message_size, "%s %s %s %s %s\n",
729 /* --version (output to stderr, not syslog) */
730 fprintf(stderr,"%s %s %s %s %s\n",
709731 *argv, gMessages[LOG_VERSION],
710732 VERSION, __DATE__, __TIME__);
711 wrap_syslog (LOG_INFO,"%s",syslog_message);
712733 exit (0);
713734 break;
714735
715736 case 3:
716 // --help
737 /* --help */
717738 show_usage (*argv);
718739 return 0;
719740 break;
720741
721742 case 4:
722 // --verbose
743 /* --verbose */
723744 gVerbose = true;
724745 if (!(gSilent))
725746 {
729750 break;
730751
731752 case 5:
732 // --eco
753 /* --eco */
733754 gEcoMode = true;
734755 break;
735756
736757 case 6:
737 // --noGamma
758 /* --noGamma */
738759 get_Gamma = false;
739760 break;
740761
741762 case 7:
742 // --uni
763 /* --uni */
743764 gUnimode = true;
744765 break;
745766
746767 case 8:
747 // --bi
768 /* --bi */
748769 gUnimode=false;
770 break;
771
772 case 9:
773 /* --dpi300 */
774 g300=true;
749775 break;
750776
751777 default:
773799
774800 case 'f':
775801 {
776 char *configFile;
802 char *configFile=NULL;
777803 configFile = readPath (optarg);
778 if (configFile)
804 if (configFile) {
779805 read_config_file (configFile);
806 free(configFile);
807 }
780808 }
781809 break;
782810
783811 case 'F':
784812 {
785 char *path;
813 char *path=NULL;
786814 path = readPath (optarg);
787 if (path)
788 gammaFile = path;
815 if (path) {
816 strncpy(gammaFile,path,MAXPATHLEN);
817 free(path);
818 }
789819 }
790820 break;
791821
806836 }
807837 else
808838 {
809 char *path;
839 char *path=NULL;
810840 path = readPath (optarg);
811841 if (path)
812842 {
813 pnm_inputFile = path;
843 strncpy(pnm_inputFile,path,MAXPATHLEN);
844 free(path);
814845 use_stdin = false;
815846 got_Input = true;
816847 }
829860 }
830861 else
831862 {
832 char *path;
863 char *path=NULL;
833864 path = readPath(optarg);
834865 if (path)
835866 {
836 ppa_outputFile = path;
867 strncpy(ppa_outputFile,path,MAXPATHLEN);
868 free(path);
837869 use_stdout = false ;
838870 got_Output = true;
839871 }
9851017 }
9861018 }
9871019
988
989 // if the user doesn't specify an input or output file, we make like a pipe
1020 /* if no input is specified, we terminate */
1021 /* if the user doesn't specify output file, we make like a pipe*/
9901022
9911023 if (in == NULL)
992 in = stdin;
1024 exit(0);
9931025 if (out == NULL)
9941026 out = stdout;
9951027
10961128
10971129 }
10981130
1131 /* if printer version is set to NOPRINTER in pnm2ppa.conf */
1132 if (printer.version == NOPRINTER) {
1133 snprintf(syslog_message,message_size,"pnm2ppa.conf: version 0; %s",
1134 gMessages[E_PPA_UNKNOWN]);
1135 wrap_syslog (LOG_CRIT,"%s",syslog_message);
1136
1137 exit (1);
1138 }
1139
10991140 /* now do the work! */
11001141
11011142 return print_pnm (in);
11021143 }
11031144
1104
55 # uncomment entries by removing "#" to activate them.
66 #
77 #-----------set the printer model---------------------------
8 # YOU MUST CHOOSE ONE OF THE FOLLOWING, EVEN IF YOU DO NOTHING ELSE!
8 # The printer model will normally be set by a -v <model> command
9 # line argument. Otherwise, if not set in the configuration file
10 # it defaults to the 710/720 series. Remove/comment out the line
11 # "version 0" below to get the default choice.
912 #
1013 # If there is more than one "version" entry activated, the last one
1114 # will be used. The printer version can also be set with the command line
1215 # option e.g., "-v 720".
1316
14 version ERROR # PNM2PPA WIIL *NOT* WORK UNTIUL THIS ENTRY IS REMOVED!!!!
17 version 0 # REMOVE THIS ENTRY to make 720 the default printer model!!!
1518 #version 720 # 710, 712, 722 also acceptable
1619 #version 820
1720 #version 1000
2225 # For security reasons, no input from the user is ever sent to the syslog.
2326 # The setting "silent 1" suppresses messages to the syslog. The
2427 # setting "verbose 1" sends messages to the standard error stream (stderr)
25 # in addition to the syslog. (Note: on BeOS, syslog messages are
28 # in addition to the syslog. (Note: if pnm2ppa was compiled with the
29 # -D__NO_SYSLOG__ option (e.g., for BeOS), syslog messages are
2630 # diverted to stderr; use "silent 1" to suppress them.)
27 # Note: the "silent 1" keyword is only accepted from the system
28 # configuration file (/etc/pnm2ppa.conf), and not from configuration files
29 # specified with the pnm2ppa option "-f".
3031
3132 #silent 1
3233 #verbose 1
34
35 # (NEW FEATURE:)
36 # standard informational messages ( when a job starts, when each page
37 # prints, job finished, etc.) will not be recorded in the System Log,
38 # unless explicitly activated here with the "log_info 1" keyword.
39 # (i.e., "log_info 0" is the default.)
40 # (Informational messages will still always be sent to stderr in "verbose"
41 # mode, even if log_info is not set.)
42
43 log_info 1 # <= COMMENT THIS OUT TO GET THE NEW DEFAULT BEHAVIOR!
44
45 # Note: the "silent 1" and "log_info" keywords are only accepted from the
46 # system configuration file (/etc/pnm2ppa.conf), and not from configuration
47 # files specified by users with the pnm2ppa option "-f".
3348
3449 #---------set the margins of the printed page-------------------
3550 # Margins: these are distances from the edges of the paper in
86101 # color and black print heads. The third and fourth lines of the
87102 # alignment test page (see above) tests these.
88103 # The setting is correct when alignments "0" are correct.
89 # Add or subtract the + or - number shown under the best-aligned shearing
90 # alignment pattern.
104 # The (positive or negative) number shown under the best-aligned shearing
105 # alignment pattern tells you how much to change the colorshar or blackshear
106 # value by. (For, example, if you print the calibration page with
107 # "colorshear 0" (the default value) and the best pattern is labelled "-2",
108 # uncomment the "colorshear" value below and set it equal to -2.)
91109
92110 #colorshear 0
93111 #blackshear 0
149167
150168 #unimode 1
151169
170 #------------switch off (color) data compression------------------
171 # Previously, data compression of color data sent to the printer
172 # was not enabled. It is now enabled by default, but has only
173 # been tested on HP71x/72xC models. Uncomment and set "compression 0"
174 # to disable color data compression if necessary.
175
176 #compression 1
177
152178 #=====================================================================
153179 # the following are switches for debugging purposes only:
154180 # set their values to 0 to switch off the corresponding ink type:
3434 {"noGamma", 0, 0, 0},
3535 {"uni", 0, 0, 0 },
3636 {"bi", 0, 0, 0 },
37 {"dpi300", 0, 0, 0},
3738 {0, 0, 0, 0}
3839 };
3940
3838
3939 extern int Width; /* width and height in 600ths of an inch */
4040 extern int Height;
41 //extern int Pwidth; /* width in bytes */
41 #if 0
42 extern int Pwidth; /* width in bytes */
43 #endif
4244 extern char *color_bitmap;
4345 extern int BitMap_topline; /* top line of bitmap */
4446 extern int BitMap_bottomline; /* bottom line of bitmap */
4850 #ifdef __CALIBRATE_PPA_C__
4951 int Width; /* width and height in 600ths of an inch */
5052 int Height;
51 //int Pwidth; /* width in bytes */
52 //int Pheight; /* height for malloc */
53 #if 0
54 int Pwidth; /* width in bytes */
55 int Pheight; /* height for malloc */
56 #endif
5357 char *color_bitmap;
5458 int BitMap_topline; /* top line of bitmap */
5559 int BitMap_bottomline; /* bottom line of bitmap */
+217
-197
ppa.c less more
343343 {
344344 unsigned char *out = iout;
345345 int I, len = num_lines_d2;
346 unsigned compressed_len = 0;
347
348
349 /* abandon compression if datasize expands! */
346350
347351 for (I = 0; I < final_len; I += num_lines_d2, in += num_lines_d2)
348352 {
366370 {
367371 /* Max is 128 */
368372 *out++ = 0x00;
373 compressed_len++;
374 if (compressed_len > final_len)
375 return 0;
369376 i += 128;
370377 dup_len -= 128;
371378 }
372379 if (dup_len >= 1)
373380 {
374381 *out++ = dup_len;
382 compressed_len++;
383 if (compressed_len > final_len)
384 return 0;
385
375386 i += dup_len;
376387 }
377388 /* See if we have enough non-zeros to be worth compressing. */
385396 /* Max is 64 */
386397 *out++ = (char) 0x80;
387398 *out++ = (char) in[i];
399 compressed_len +=2;
400 if (compressed_len > final_len)
401 return 0;
402
388403 i += 64;
389404 dup_len -= 64;
390405 }
392407 {
393408 *out++ = dup_len + 0x80;
394409 *out++ = in[i];
410 compressed_len +=2;
411 if (compressed_len > final_len)
412 return 0;
413
395414 i += dup_len;
396415 }
397416 }
429448 int j;
430449
431450 *out++ = (char) 0xc0;
451 compressed_len ++;
432452 for (j = i; j < i + 64; j++)
433453 {
434454 *out++ = in[j];
435455 }
456 compressed_len += 64;
457 if (compressed_len > final_len)
458 return 0;
436459 i += 64;
437460 lit_len -= 64;
438461 }
441464 int j;
442465
443466 *out++ = lit_len + 0xc0;
467 compressed_len ++;
444468 for (j = i; j < i + lit_len; j++)
445469 {
446470 *out++ = in[j];
447471 }
472 compressed_len += lit_len;
473 if (compressed_len > final_len)
474 return 0;
448475 i += lit_len;
449476 }
450477 }
451478 }
452479 }
480 if (compressed_len > final_len)
481 return 0;
482
453483 return out - iout;
454484 }
455485
474504 #endif
475505 }
476506
477 //#define do_compress_data (1)
507 /*#define do_compress_data (1) */
478508
479509 void
480510 ppa_print_sweep (ppaPrinter_t * printer, ppaSweepData_t * data)
481511 {
482 unsigned char *pc, *tpc;
483 unsigned i, datasize = data->data_size;
484 unsigned char sweep_packet[144];
485 int sweep_packet_size;
486 unsigned short HP7X0constants[] = { 0x8ca0, 0x4650, 0x12c0 };
487 unsigned short HP820constants[] = { 0x4650, 0x1c20, 0x0960 };
488 unsigned short HP1000constants[] = { 0x4650, 0x2328, 0x0708 };
489 unsigned short *constants;
490 int nozzle_data_size;
491 int MF; /* Multiplicative Factor -- quick hack */
492 int k;
493
494 unsigned char do_compress_data;
495
496 DPRINTF("ppa_print_sweep: Dir: %d Color: %d Size: %d Vpos: %d Hpos: %d,%d\n",
497 data->direction, data->in_color, data->data_size, data->vertical_pos,
498 data->left_margin, data->right_margin );
499 assert( ((data->direction == left_to_right) || (data->direction == right_to_left)) );
500
501 if (gColorMode)
502 do_compress_data = 0;
503 else
504 do_compress_data = 1;
505
506 // DPRINTF("*********k up to %d\n",(data->in_color == 1 ? gMaxPass : 1));
507 for (k = 0; k < (data->in_color == 1 ? gMaxPass : 1); k++)
512 unsigned char *pc, *tpc;
513 unsigned i, datasize = data->data_size;
514 unsigned char sweep_packet[144];
515 int sweep_packet_size;
516 unsigned short HP7X0constants[] = { 0x8ca0, 0x4650, 0x12c0 };
517 unsigned short HP820constants[] = { 0x4650, 0x1c20, 0x0960 };
518 unsigned short HP1000constants[] = { 0x4650, 0x2328, 0x0708 };
519 unsigned short *constants;
520 int nozzle_data_size;
521 int MF; /* Multiplicative Factor -- quick hack */
522
523 unsigned char do_compress_data;
524
525 DPRINTF("ppa_print_sweep(): Dir: %d Color: %d Size: %d Vpos: %d Hpos: %d,%d\n",
526 data->direction, data->in_color, data->data_size, data->vertical_pos,
527 data->left_margin, data->right_margin );
528 assert( ((data->direction == left_to_right) || (data->direction == right_to_left)) );
529
530 if (data->in_color && !gCompress )
531 do_compress_data = 0;
532 else
533 do_compress_data = 1;
534
535
536
537 pc = data->image_data;
538
539 DPRINTF(" ppa_print_sweep(): datasize= %d\n", datasize);
540
541 if (do_compress_data) {
542 unsigned compressed_datasize;
543 if (!(pc = malloc ((datasize / 64 + 1) * 65)))
544 {
545 snprintf(syslog_message,message_size, "ppa_print_sweep(): %s",
546 gMessages[E_PPA_BADMALLOC]);
547 wrap_syslog (LOG_CRIT,"%s",syslog_message);
548 exit (-1);
549 }
550 compressed_datasize =
551 compress (data->image_data,
552 data->nozzle_data->pins_used_d2, datasize, pc);
553 if (!compressed_datasize) {
554 /* compression would increase datsize ! */
555 free (pc);
556 do_compress_data = 0;
557 pc = data->image_data;
558 } else {
559 datasize = compressed_datasize;
560 DPRINTF(" ppa_print_sweep():compressed datasize= %d\n", datasize);
561 }
562
563 }
564
565 /* send image data 16k at a time */
566 for (i = 0, tpc = pc; i < datasize; tpc += 16384, i += 16384)
508567 {
509 // DPRINTF("********step %d\n",k);
510 pc = data->image_data[k];
511
512 if (do_compress_data)
513 {
514 if (!(pc = malloc ((datasize / 64 + 1) * 65)))
515 {
516 snprintf(syslog_message,message_size, "ppa_print_sweep(): %s",
517 gMessages[E_PPA_BADMALLOC]);
518 wrap_syslog (LOG_CRIT,"%s",syslog_message);
519 exit (-1);
520 }
521 datasize =
522 compress (data->image_data[k],
523 data->nozzle_data->pins_used_d2, datasize, pc);
524 }
525
526 /* send image data 16k at a time */
527 for (i = 0, tpc = pc; i < datasize; tpc += 16384, i += 16384)
528 {
529 vlink_put (printer->fptr, 0, ((datasize - i) > 16384) ? 16384 : (datasize - i), tpc);
530 }
531
532 /* memory leak fix courtesy of John McKown */
533 if (do_compress_data)
534 free (pc);
535
536 /* construct sweep packet */
537 switch (printer->version)
538 {
539 case HP820:
540 constants = HP820constants;
541 MF = 1;
542 break;
543 case HP7X0:
544 constants = HP7X0constants;
568 vlink_put (printer->fptr, 0, ((datasize - i) > 16384) ? 16384 : (datasize - i), tpc);
569 }
570
571
572 /* memory leak fix courtesy of John McKown */
573 if (do_compress_data && pc){
574 free (pc);
575 pc = NULL;
576 }
577
578 /* construct sweep packet */
579 switch (printer->version) {
580 case HP820:
581 constants = HP820constants;
582 MF = 1;
583 break;
584 case HP7X0:
585 constants = HP7X0constants;
545586 MF = 2;
546587 break;
547 case HP1000:
548 constants = HP1000constants;
549 MF = 1;
550 break;
551 default:
552 snprintf(syslog_message,message_size, "ppa_print_sweep(): %s",
553 gMessages[E_PPA_UNKNOWN]);
588 case HP1000:
589 constants = HP1000constants;
590 MF = 1;
591 break;
592 default:
593 snprintf(syslog_message,message_size, "ppa_print_sweep(): %s",
594 gMessages[E_PPA_UNKNOWN]);
554595 wrap_syslog (LOG_CRIT,"%s",syslog_message);
555 return;
556 }
557
558 sweep_packet[0] = 0;
559 sweep_packet[1] = do_compress_data;
560 sweep_packet[2] = data->direction == right_to_left ? 1 : 2;
561 sweep_packet[3] = data->in_color ? 14 : 1;
562
563 packLong (datasize, sweep_packet + 4);
564
565 memset (sweep_packet + 8, 0, 8);
566
567 if (data->in_color)
568 packLong (MF * (data->vertical_pos +
569 /*96+ */ printer->y_offset) /*+ 1*/,
570 sweep_packet + 16);
571 else
572 packLong (MF *
573 (data->vertical_pos +
574 printer->y_offset), sweep_packet + 16);
575 packShort (constants[0], sweep_packet + 20);
576 packShort (MF *
577 (data->left_margin + printer->x_offset) /*+ 1*/,
578 sweep_packet + 22);
579 packShort (MF *
580 (data->right_margin + printer->x_offset) /*+ 1*/,
581 sweep_packet + 24);
582 if (data->in_color)
583 packShort (0x2ee0, sweep_packet + 26);
584 else
585 packShort (constants[1], sweep_packet + 26); /* 2ee0 in color on 820 */
586 packShort (constants[2], sweep_packet + 28);
587 packShort (0x100, sweep_packet + 30);
588
589
590 if ((data->in_color) && (k < gMaxPass - 1))
591 {
592 sweep_packet[32] = data->direction == right_to_left ? 1 : 2;
593 sweep_packet[33] = data->in_color ? 14 : 1;
594 packLong (MF *
595 (data->vertical_pos +
596 printer->y_offset), sweep_packet + 34);
597 packShort (MF *
598 (data->left_margin +
599 printer->x_offset), sweep_packet + 38);
600 packShort (MF *
601 (data->right_margin +
602 printer->x_offset), sweep_packet + 40);
603 packShort (0x2ee0, sweep_packet + 42);
604 packShort (constants[2], sweep_packet + 44);
605 }
606 else
607 {
608 if (data->next)
609 {
610 sweep_packet[32] =
611 data->next->direction == right_to_left ? 1 : 2;
612 sweep_packet[33] = data->next->in_color ? 14 : 1;
613 packLong (MF *
614 (data->next->vertical_pos +
615 printer->y_offset), sweep_packet + 34);
616 packShort (MF *
617 (data->next->left_margin +
618 printer->x_offset), sweep_packet + 38);
619 packShort (MF *
620 (data->next->right_margin +
621 printer->x_offset), sweep_packet + 40);
622 if (data->in_color)
623 packShort (0x2ee0, sweep_packet + 42);
624 else
625 packShort (constants[1], sweep_packet + 42); /* 2ee0 in color on 820 */
596 return;
597 }
598
599 sweep_packet[0] = 0;
600 sweep_packet[1] = do_compress_data;
601 sweep_packet[2] = data->direction == right_to_left ? 1 : 2;
602 sweep_packet[3] = data->in_color ? 14 : 1;
603
604 packLong (datasize, sweep_packet + 4);
605
606 memset (sweep_packet + 8, 0, 8);
607
608 if (data->in_color)
609 packLong (MF * (data->vertical_pos +
610 /*96+ */ printer->y_offset) /*+ 1*/,
611 sweep_packet + 16);
612 else
613 packLong (MF *
614 (data->vertical_pos +
615 printer->y_offset), sweep_packet + 16);
616 packShort (constants[0], sweep_packet + 20);
617 packShort (MF *
618 (data->left_margin + printer->x_offset) /*+ 1*/,
619 sweep_packet + 22);
620 packShort (MF *
621 (data->right_margin + printer->x_offset) /*+ 1*/,
622 sweep_packet + 24);
623 if (data->in_color)
624 packShort (0x2ee0, sweep_packet + 26);
625 else
626 packShort (constants[1], sweep_packet + 26); /* 2ee0 in color on 820 */
627 packShort (constants[2], sweep_packet + 28);
628 packShort (0x100, sweep_packet + 30);
629
630
631 if (data->next) {
632 sweep_packet[32] =
633 data->next->direction == right_to_left ? 1 : 2;
634 sweep_packet[33] = data->next->in_color ? 14 : 1;
635 packLong (MF *
636 (data->next->vertical_pos +
637 printer->y_offset), sweep_packet + 34);
638 packShort (MF *
639 (data->next->left_margin +
640 printer->x_offset), sweep_packet + 38);
641 packShort (MF *
642 (data->next->right_margin +
643 printer->x_offset), sweep_packet + 40);
644 if (data->in_color)
645 packShort (0x2ee0, sweep_packet + 42);
646 else
647 packShort (constants[1], sweep_packet + 42); /* 2ee0 in color on 820 */
626648 packShort (constants[2], sweep_packet + 44);
627 }
628 else
629 memset (sweep_packet + 32, 0, 14);
630 sweep_packet[46] = 8;
631 }
632 nozzle_data_size = data->nozzle_data_size;
633 if (nozzle_data_size > 6)
634 {
635 snprintf(syslog_message,message_size, "ppa_print_sweep(): %s %d\n",
636 gMessages[W_PPA_NOZZLE], nozzle_data_size);
637 wrap_syslog (LOG_WARNING,"%s",syslog_message);
638
639 nozzle_data_size = 6;
640 }
641 sweep_packet[47] = nozzle_data_size;
642
643 for (pc = sweep_packet + 48, i = 0;
644 i < nozzle_data_size; i++, pc += 16)
645 {
646 packShort (data->nozzle_data[i].DPI, pc);
647 packShort (data->nozzle_data[i].pins_used_d2, pc + 2);
648 packShort (data->nozzle_data[i].unused_pins_p1, pc + 4);
649 packShort (data->nozzle_data[i].first_pin, pc + 6);
650 packShort (data->nozzle_data[i].pins_used_d2, pc + 8);
651 packShort (MF * (data->nozzle_data[i].left_margin + printer->x_offset),
652 pc + 10);
653 packShort (MF * (data->nozzle_data[i].right_margin + printer->x_offset),
654 pc + 12);
655 pc[14] = data->nozzle_data[i].nozzle_delay;
656 pc[15] = 0;
657 }
658
659 sweep_packet_size = data->in_color ? 144 : 80;
660
661 /* send sweep packet */
662 switch (printer->version)
663 {
664 case HP820:
665 scp_put (printer->fptr, 18, 1, 7, sweep_packet_size, sweep_packet);
666 break;
667 case HP7X0:
668 scp2_put (printer->fptr, 0x0180, sweep_packet_size,
649 }
650 else
651 memset (sweep_packet + 32, 0, 14);
652 sweep_packet[46] = 8;
653
654 nozzle_data_size = data->nozzle_data_size;
655 if (nozzle_data_size > 6) {
656 snprintf(syslog_message,message_size, "ppa_print_sweep(): %s %d\n",
657 gMessages[W_PPA_NOZZLE], nozzle_data_size);
658 wrap_syslog (LOG_WARNING,"%s",syslog_message);
659
660 nozzle_data_size = 6;
661 }
662 sweep_packet[47] = nozzle_data_size;
663
664 for (pc = sweep_packet + 48, i = 0;
665 i < nozzle_data_size; i++, pc += 16) {
666 packShort (data->nozzle_data[i].DPI, pc);
667 packShort (data->nozzle_data[i].pins_used_d2, pc + 2);
668 packShort (data->nozzle_data[i].unused_pins_p1, pc + 4);
669 packShort (data->nozzle_data[i].first_pin, pc + 6);
670 packShort (data->nozzle_data[i].pins_used_d2, pc + 8);
671 packShort (MF * (data->nozzle_data[i].left_margin + printer->x_offset),
672 pc + 10);
673 packShort (MF * (data->nozzle_data[i].right_margin + printer->x_offset),
674 pc + 12);
675 pc[14] = data->nozzle_data[i].nozzle_delay;
676 pc[15] = 0;
677 }
678
679 sweep_packet_size = data->in_color ? 144 : 80;
680
681
682 /* send sweep packet */
683 switch (printer->version) {
684 case HP820:
685 scp_put (printer->fptr, 18, 1, 7, sweep_packet_size, sweep_packet);
686 break;
687 case HP7X0:
688 scp2_put (printer->fptr, 0x0180, sweep_packet_size,
669689 7, 1, datasize, sweep_packet);
670 break;
671 case HP1000:
672 scp3_put (printer->fptr, 0x0180, sweep_packet_size,
673 7, 1, datasize, sweep_packet);
674 break;
675 default:
676 snprintf(syslog_message,message_size,"ppa_print_sweep(): %s",
677 gMessages[E_PPA_UNKNOWN]);
678 wrap_syslog (LOG_CRIT,"%s",syslog_message);
679
680 return;
681 }
682 }
683 }
690 break;
691 case HP1000:
692 scp3_put (printer->fptr, 0x0180, sweep_packet_size,
693 7, 1, datasize, sweep_packet);
694 break;
695 default:
696 snprintf(syslog_message,message_size,"ppa_print_sweep(): %s",
697 gMessages[E_PPA_UNKNOWN]);
698 wrap_syslog (LOG_CRIT,"%s",syslog_message);
699
700 return;
701 }
702 }
703
684704
685705
686706 void
0
01 /***************************************************************************
12 ppa.h - PPA protocol definitions and routines
23 -------------------
5657
5758 typedef struct ppaSweepData_s
5859 {
59 unsigned char *image_data[4];
60 unsigned char *image_data;
6061 unsigned data_size;
6162 BOOLEAN in_color;
6263 enum
63 { right_to_left, left_to_right }
64 { right_to_left, left_to_right, unknown}
6465 direction;
6566 int vertical_pos;
6667 unsigned short left_margin;
6869 unsigned char nozzle_data_size;
6970 ppaNozzleData_t *nozzle_data;
7071 struct ppaSweepData_s *next; /* NULL indicates last print sweep */
72 int first_data_line;
73 int last_data_line;
74 int pre_blanklines;
75 int post_blanklines;
7176 }
7277 ppaSweepData_t;
78
79 typedef struct ppaSwathLimits_s
80 {
81 int left;
82 int right;
83 int numlines;
84 int non_blanklines;
85 int pre_blanklines;
86 int post_blanklines;
87 int first_line;
88 int last_line;
89 }
90 ppaSwathLimits_t;
91
92 typedef struct ppaPageLimits_s
93 {
94 int left;
95 int right;
96 int top;
97 int bottom;
98 }
99 ppaPageLimits_t;
73100
74101 void ppa_init_job (ppaPrinter_t *);
75102 void ppa_init_page (ppaPrinter_t *);
0 <HTML>
1
2 <HEAD><TITLE>PRINT_SWEEP specification</TITLE></HEAD>
3
4 <BODY BGCOLOR=#FFFFFF TEXT=#000000>
5
6
7
8 <H2>HP 820Cse SCP protocol</H2>
9
10 <p>Following is the probable specification for the SCP protocol on 820
11 printers. There seem to be minor differences with the 820Cxi printer,
12 and the protocol header is changed for 720 series printers.
13
14 <p><TABLE BORDER>
15 <TR><TD><B>Bytes</B></TD><TD><B>Description</B></TD></TR>
16 <TR><TD>2</TD><TD>Command specifier</TD></TR>
17 <TR><TD>2</TD><TD>Command reference number</TD></TR>
18 <TR><TD>1</TD><TD>Priority</TD></TR>
19 <TR><TD>1</TD><TD>Blank</TD></TR>
20 <TR><TD>2</TD><TD>Length of data</TD></TR>
21 <TR><TD>n</TD><TD>Data, including parameters to this command</TD></TR>
22 </TABLE>
23
24 <p>Several of the commands are described below:
25
26 <p><B><U>CS=35, CR=1 (INIT_COM ?)</U></B>
27
28 <p>This is some sort of initialization command. It probably
29 initializes the communications channel, since it is always the first
30 packet sent by the windows driver. It's data consists of 8 bytes
31 that I have only seen as:<BR>
32 <pre><tt> 00 00 01 F4 01 00 00 00</tt></pre>
33
34 <p><B><U>CS=101, CR=2 (INIT_DATA ?)</U></B>
35
36 <p>This is another initialization command. It is sent once at the
37 beginning of each file printed, after the INIT_COM packet. It is
38 preceded by a 4-byte VLink packet sent to channel 0. This suggests
39 that it somehow initializes the data channel of the printer (thus our
40 temporary name). This packet typically contains the values: <tt>DE AD
41 BE EF</tt>. The data portion of this command usually contains the
42 following 8 bytes:<BR>
43
44 <pre><tt> DE AD BE EF 02 00 00 00</tt></pre>
45
46 <p><B><U>CS=21, CR=1 (INIT_PAGE ?)</U></B>
47
48 <p>This command is sent each time before a page is loaded. It appears
49 to set some parameters for the page, possibly the minimum and maximum
50 horizontal positions for each of the four pens (?). The only data I have
51 seen it contain is the following:<BR>
52
53 <pre><tt> 28 2D 00 41 29 2E 00 42 29 2E 00 42 29 2E 00 42</tt></pre>
54
55 <p><B><U>CS=19, CR=1 (HANDLE_MEDIA)</U></B>
56
57 <p>This is the command that handles loading and ejecting of pages.
58
59 <p><table border>
60 <tr><td>1</td><td>1=load, 2=eject</td></tr>
61 <tr><td>1</td><td>?? usually 0x01</td></tr>
62 <tr><td>2</td><td>usually 0x0960 (2400 decimal), perhaps the
63 horizontal position to place the print-head while loading/ejecting the
64 page. 2400 corresponds to 4" from the left, which is about the center
65 of the page for 8.5" pages.</td></tr>
66 </table>
67
68 <p><b><u>CS=18, CR=1 (PRINT_SWEEP)</u></b>
69
70 <p>This is the print sweep command. It causes the print head to print
71 a sweep of data (which has previously been sent over channel 0).
72
73 <p>The PRINT_SWEEP command controls the print head while printing data
74 on a page. It can take on two forms, one when printing with the black
75 nozzles, and one when printing with the color nozzles. The black form
76 is described in the most detail here, since it is what I have devoted
77 the most attention to.
78
79 <p>Following is the format of the first 48 bytes of data for this
80 command:
81
82 <p><table border><tr><td><b>Bytes</b></td><td><b>Description</b></td></tr>
83 <tr><td>1</td><td>always 0x00</td></tr>
84 <tr><td>1</td><td>1 = compressed, 0 = not compressed</td></tr>
85 <tr><td>1</td><td>2 = left-to-right, 1 = right-to-left</td></tr>
86 <tr><td>1</td><td>1 = black, 0xE = CMY colors</td></tr>
87 <tr><td>4</td><td>Compressed size of data</td></tr>
88 <tr><td>8</td><td>Typically 0</td><tr>
89 <tr><td><hr></td><td><hr></td></tr>
90
91 <tr><td>4</td><td>Signed number representing vertical
92 position</td></tr>
93 <tr><td>2</td><td>Usually 0x4650 (18000 decimal)</td></tr>
94 <tr><td>2</td><td>Horizontal position for left margin in
95 dots</td></tr>
96 <tr><td>2</td><td>Horizontal position for right margin in
97 dots</td></tr>
98 <tr><td>2</td><td>0x1C20 (7200) for black data or 0x2EE0 (12000) for
99 color data</td></tr>
100 <tr><td>2</td><td>Usually 0x0960 (2400)</td></tr>
101 <tr><td>2</td><td>Usually 0x0100 - has something to do with horizontal
102 placement</td></tr>
103 <tr><td><hr></td><td><hr></td></tr>
104
105 <tr><td>1</td><td>If 0, this is the last sweep on the page; the next
106 12 bytes are ignored. Otherwise, this field predicts the print head
107 direction for the next PRINT_SWEEP command</td></tr>
108 <tr><td>1</td><td>Prediction of number of colors in next PRINT_SWEEP
109 (0x01 or 0x0E)</td></tr>
110 <tr><td>4</td><td>Vertical position of next sweep</td></tr>
111 <tr><td>2</td><td>Horizontal position for left margin in next
112 sweep</td></tr>
113 <tr><td>2</td><td>Horizontal position for right margin in next
114 sweep</td></tr>
115 <tr><td>2</td><td>Predicts the third-to-last word (2-byte value) of
116 the next sweep packet - 0x1C20 for black, 0x2EE0 for color</td></tr>
117 <tr><td>2</td><td>Usually 0x0960 - predicts the second-to-last word of
118 the next sweep packet</td></tr>
119 <tr><td>1</td><td>0x08</td></tr>
120 <tr><td>1</td><td>Number of 16-byte rows to follow this header. This
121 is 2 for black and 6 for CMY.</td></tr>
122 </table>
123
124 <p>Following this header are sets of 16-byte rows to describe how to
125 handle the nozzles. The odd nozzles are described by the first row,
126 and the even nozzles are described by the second row.
127
128 <p><table border><tr><td><b>Bytes</b></td><td><b>Description</b></td></tr>
129 <tr><td>2</td><td>DPI (dots per inch) - 300 or 600</td></tr>
130 <tr><td>2</td><td>Half of the total number of pins used</td></tr>
131 <tr><td>2</td><td>Number of unused pins + 1</td></tr>
132 <tr><td>2</td><td>First pin to start printing with, typically
133 1</td></tr>
134 <tr><td>2</td><td>Half of the total number of pins used</td></tr>
135 <tr><td>2</td><td>Left margin in dots. For black printing, this is
136 always 0x62 greater for the odd pins (first set) than the even
137 pins</td></tr>
138 <tr><td>2</td><td>Right margin in dots.</td></tr>
139 <tr><td>1</td><td>Some sort of delay before this set of nozzles starts
140 firing. See code for more details.</td></tr>
141 <tr><td>1</td><td>0</td></tr>
142 </table>
143
144
145
146 </body></html>
147
148 <!-- This document source from http://pnm2ppa.sourceforge.net/protocol/scp_820cse.html -->
121121 odd swing buffer, and the second is the even swing buffer. These
122122 correspond to which pins will be printing the data. Thus, the odd
123123 swing buffer for the first column in the above example would look like
124 this:
124 this: <b>(Note added: from inspection of the
125 pbm2ppa and pnm2mma code, this seems to be
126 the even swing buffer, not the odd one (?))</b>
125127
126128 <p><table border>
127129 <tr><td>Byte 0</td></tr>
131133 </table>
132134
133135 <P>And the even swing buffer looks like this:
136 <b>(Note added: this seems to be the odd swing buffer (?))</b>
134137
135138 <p><table border>
136139 <tr><td>Byte 8</td></tr>
0 diff -uNr pnm2ppa-1.04/Makefile pnm2ppa-1.04.redhat/Makefile
1 --- pnm2ppa-1.04/Makefile Thu Nov 2 13:33:08 2000
2 +++ pnm2ppa-1.04.redhat/Makefile Sat Nov 11 13:25:28 2000
3 @@ -10,7 +10,7 @@
0 diff -uNr pnm2ppa-1.11/Makefile pnm2ppa-1.11-redhat/Makefile
1 --- pnm2ppa-1.11/Makefile Sat Oct 5 21:27:36 2002
2 +++ pnm2ppa-1.11-redhat/Makefile Sat Nov 9 17:08:45 2002
3 @@ -11,7 +11,7 @@
4
5 #compiler and linker options:
6 CC=gcc
7 -CFLAGS=-Wall -pedantic -O2
8 +CFLAGS=$(RPM_OPT_FLAGS)
9 LDFLAGS=-lm
10
411 INSTALL=install
5
6 # production build
7 -CFLAGS=-Wall -pedantic -O2 -g -DNDEBUG
8 +CFLAGS= $(RPM_OPT_FLAGS) -DNDEBUG
9 LDFLAGS=-lm
10 OBJS = pnm2ppa.o syslog.o ppa.o image.o dither.o cutswath.o hash_ink.o gamma.o
11 SRC = pnm2ppa.c syslog.c ppa.c image.c dither.c cutswath.c hash_ink.c gamma.c
12 diff -uNr pnm2ppa-1.04/pnm2ppa.conf pnm2ppa-1.04.redhat/pnm2ppa.conf
13 --- pnm2ppa-1.04/pnm2ppa.conf Sat Oct 28 11:02:57 2000
14 +++ pnm2ppa-1.04.redhat/pnm2ppa.conf Sat Nov 11 13:26:57 2000
15 @@ -12,7 +12,7 @@
12 diff -uNr pnm2ppa-1.11/pnm2ppa.conf pnm2ppa-1.11-redhat/pnm2ppa.conf
13 --- pnm2ppa-1.11/pnm2ppa.conf Sat Nov 9 16:47:47 2002
14 +++ pnm2ppa-1.11-redhat/pnm2ppa.conf Sat Nov 9 17:11:20 2002
15 @@ -15,7 +15,7 @@
1616 # will be used. The printer version can also be set with the command line
1717 # option e.g., "-v 720".
1818
19 -version ERROR # PNM2PPA WIIL *NOT* WORK UNTIUL THIS ENTRY IS REMOVED!!!!
20 +
19 -version 0 # REMOVE THIS ENTRY to make 720 the default printer model!!!
20 +#version 0 # REMOVE THIS ENTRY to make 720 the default printer model!!!
2121 #version 720 # 710, 712, 722 also acceptable
2222 #version 820
2323 #version 1000
24 @@ -29,8 +29,9 @@
25 # configuration file (/etc/pnm2ppa.conf), and not from configuration files
26 # specified with the pnm2ppa option "-f".
24 @@ -41,7 +41,7 @@
25 # (Informational messages will still always be sent to stderr in "verbose"
26 # mode, even if log_info is not set.)
2727
28 -#silent 1
29 -#verbose 1
30 +silent 1 #SYSTEM LOG MESSAGES SILENCED
31 +#verbose 1
32 +
28 -log_info 1 # <= COMMENT THIS OUT TO GET THE NEW DEFAULT BEHAVIOR!
29 +#log_info 1 # <= UNCOMMENT THIS TO GET THE OLD (pre v1.11) BEHAVIOR!
3330
34 #---------set the margins of the printed page-------------------
35 # Margins: these are distances from the edges of the paper in
31 # Note: the "silent 1" and "log_info" keywords are only accepted from the
32 # system configuration file (/etc/pnm2ppa.conf), and not from configuration
0 %define _mandir /usr/man
0 %define _mandir /usr/share/man
11
22 Name: pnm2ppa
33 Summary: Drivers for printing to HP PPA printers
44 Serial: 1
55 Obsoletes: ppa
6 Obsoletes: pbm2ppa
7 Version: 1.04
8 Release: 1
6 Version: 1.11
7 Release: 1rh7x
98 URL: http://sourceforge.net/projects/pnm2ppa
109 Source: http://download.sourceforge.net/pnm2ppa/pnm2ppa-%{version}.tar.gz
11 Source1: http://www.httptech.com/ppa/files/ppa-0.8.6.tar.gz
12 Patch2: pbm2ppa-20000205.diff
1310 Patch3: pnm2ppa-redhat.patch
1411 Copyright: GPL
1512 Group: Applications/Publishing
2017 pnm2ppa is a color driver for HP PPA host-based printers such
2118 as the HP710C, 712C, 720C, 722C, 820Cse, 820Cxi, 1000Cse, and 1000Cxi.
2219 It accepts ghostscript output in PNM formats, and sends it to the printer
23 in PPA format. The older (black only) driver pbm2ppa is also included.
20 in PPA format.
2421
2522 Install pnm2ppa if you have a PPA printer and need to print.
2623
3229
3330 %setup -q -n %{topdir}
3431
35 #pbm2ppa source
36 %setup -T -D -a 1 -n %{topdir}
37 %patch2 -p0
3832 %patch3 -p1 -b .rh
3933
4034 %build
4135 make
42 cd pbm2ppa-0.8.6
43 make
44
4536
4637 %install
4738 install -d $RPM_BUILD_ROOT/usr/bin
4839 install -d $RPM_BUILD_ROOT/etc
4940 install -d $RPM_BUILD_ROOT%{_mandir}/man1
50 make INSTALLDIR=$RPM_BUILD_ROOT/usr/bin CONFDIR=$RPM_BUILD_ROOT/etc \
41 make BINDIR=$RPM_BUILD_ROOT/usr/bin CONFDIR=$RPM_BUILD_ROOT/etc \
5142 MANDIR=$RPM_BUILD_ROOT%{_mandir}/man1 install
5243 install -m 0755 utils/Linux/detect_ppa $RPM_BUILD_ROOT/usr/bin/
5344 install -m 0755 utils/Linux/test_ppa $RPM_BUILD_ROOT/usr/bin/
54 install -m 0755 pbm2ppa-0.8.6/pbm2ppa $RPM_BUILD_ROOT/usr/bin/
55 install -m 0755 pbm2ppa-0.8.6/pbmtpg $RPM_BUILD_ROOT/usr/bin/
56 install -m 0644 pbm2ppa-0.8.6/pbm2ppa.conf $RPM_BUILD_ROOT/etc
57 install -m 0644 pbm2ppa-0.8.6/pbm2ppa.1 $RPM_BUILD_ROOT%{_mandir}/man1
5845
5946 chmod 644 docs/en/LICENSE
60 mkdir -p pbm2ppa
61 for file in CALIBRATION CREDITS INSTALL INSTALL-MORE LICENSE README ; do
62 install -m 0644 pbm2ppa-0.8.6/$file pbm2ppa/$file
63 done
6447
6548 #---omit this section from Official RedHat/Mandrake releases!--------------
6649 install -d $RPM_BUILD_ROOT/usr/lib/rhs/rhs-printfilters
7962 %doc docs/en/RELEASE-NOTES docs/en/TODO
8063 %doc docs/en/INSTALL.REDHAT.txt docs/en/COLOR.txt docs/en/CALIBRATION.txt
8164 %doc docs/en/INSTALL.REDHAT.html docs/en/COLOR.html docs/en/CALIBRATION.html
65 %doc docs/en/PPA_networking*
8266 %doc test.ps
83 %doc pbm2ppa
8467 /usr/bin/pnm2ppa
85 /usr/bin/pbm2ppa
86 /usr/bin/pbmtpg
8768 /usr/bin/calibrate_ppa
8869 /usr/bin/test_ppa
8970 /usr/bin/detect_ppa
9071 %{_mandir}/man1/pnm2ppa.1*
91 %{_mandir}/man1/pbm2ppa.1*
9272 %config /etc/pnm2ppa.conf
93 %config /etc/pbm2ppa.conf
9473
9574
9675 #---omit from RedHat--------------------
97 %doc docs/en/INSTALL.MANDRAKE.html docs/en/INSTALL.MANDRAKE.txt
76 #%doc docs/en/INSTALL.MANDRAKE.html docs/en/INSTALL.MANDRAKE.txt
9877 #------omit from Official RedHat/Mandrake releases!
99 /usr/lib/rhs/rhs-printfilters/ppaprint-latest
100 /usr/lib/rhs/rhs-printfilters/printerdb-ppa
101 /usr/lib/rhs/rhs-printfilters/README.ppa
78 #/usr/lib/rhs/rhs-printfilters/ppaprint-latest
79 #/usr/lib/rhs/rhs-printfilters/printerdb-ppa
80 #/usr/lib/rhs/rhs-printfilters/README.ppa
10281 #-----------------------------------------
10382
10483
10584
10685 %changelog
86 * Sat Oct 9 2002 Duncan Haldane <duncan_haldane@users.sourceforge.net>
87 - 1.11 release
88
89 * Thu Jun 27 2002 Duncan Haldane <duncan_haldane@users.sourceforge.net>
90 - removed pbm2ppa for 1.10 (pre) release
91
92 * Mon Jun 11 2002 Duncan Haldane <duncan_haldane@users.sourceforge.net>
93 - updated for 1.10 (pre) release.
94
10795 * Tue Nov 24 2000 Duncan Haldane <duncan_haldane@users.sourceforge.net>
10896 - updated for 1.04 release.
10997
00 cat $1 | \
1 gs -sDEVICE=ppmraw -q -sPAPERSIZE=a4 -dNOPAUSE -r600 -sOutputFile=- - | \
2 ./pnm2ppa --bw --eco $2 $3 $4 $5 -i - -o /dev/lp0
1 gs -sDEVICE=pbmraw -q -sPAPERSIZE=a4 -dNOPAUSE -r600 -sOutputFile=- - | \
2 pnm2ppa --bw --eco $2 $3 $4 $5 -i - -o /dev/lp0
00 cat $1 | \
11 gs -sDEVICE=ppmraw -q -sPAPERSIZE=a4 -dNOPAUSE -r600 -sOutputFile=- - | \
2 ./pnm2ppa $2 $3 $4 $5 -i - -o /dev/lp0
2 pnm2ppa $2 $3 $4 $5 -i - -o /dev/lp0
00 cat $1 | \
11 gs -sDEVICE=ppmraw -q -sPAPERSIZE=a4 -dNOPAUSE -r600 -sOutputFile=- - | \
2 ./pnm2ppa --eco $2 $3 $4 $5 -i - -o /dev/lp0
2 pnm2ppa --eco $2 $3 $4 $5 -i - -o /dev/lp0
1818 BeOS syslog() wrapper
1919 syslog.c
2020 modified Duncan Haldane <duncan_haldane@users.sourceforge.net>
21 Oct 2000. all syslog messages arrive here wrapped.
21 Oct 2000. all syslog messages arrive here wrapped.
2222 */
2323
2424 #include <stdio.h>
2525 #include "syslog.h"
2626 #include "global.h"
2727
28
28 BOOLEAN verbose = false ;
2929
3030 /*
3131 For some reason, BeOS doesn't seem to implement syslog(), even though it is
3232 included with the system. Wierd. This wraps the syslog functions used
33 and writes the info to the stderr stream.
33 and writes the info to the stderr stream, if __NO_SYSLOG__ is defined.
3434 */
3535
3636
3737 void
3838 wrap_syslog(int log_pri, char *fmt, char *message )
3939 {
40 if (!(gSilent))
41 #ifdef __BEOS__
42 {
43 gSilent = true;
40 if (!(gSilent)) {
41 #ifdef __NO_SYSLOG__
4442 gVerbose = true;
45 }
4643 #else
47 {
48 syslog ( log_pri , "%s", message );
44 if (gLogInfo || log_pri != LOG_INFO)
45 syslog ( log_pri , "%s", message );
46 else if(verbose)
47 fprintf(stderr,"pnm2ppa: %s",message);
48 #endif
4949 }
50 #endif
5150
5251 if (gVerbose)
5352 {
5958
6059 void wrap_openlog( char *ident, int level )
6160 {
62 #ifndef __BEOS__
63 if ( level )
64 {
65 /* level 1 has LOG_PERROR (prints to stderr) */
61 #ifndef __NO_SYSLOG__
62 if ( level ) {
63 /* level 1 also sends messages to stderr */
64 #ifdef __NO_LOG_PERROR__
65 /* for systems (e.g. Solaris) where LOG_PERROR is not valid */
66 openlog ( ident, LOG_CONS | LOG_PID, LOG_LPR);
67 gVerbose = true;
68 #else
6669 openlog ( ident, LOG_PERROR | LOG_CONS | LOG_PID, LOG_LPR);
67 }
68 else
69 {
70 /* standard level 0 */
70 verbose = gVerbose;
71 gVerbose = false;
72 #endif
73 }
74 else {
75 /* standard level 0, messages sent to syslog only */
7176 openlog ( ident, LOG_CONS | LOG_PID, LOG_LPR);
77 verbose = gVerbose;
78 gVerbose = false;
7279 }
7380 #endif
7481 return;
7784 void
7885 wrap_closelog( void)
7986 {
80 #ifndef __BEOS__
87 #ifndef __NO_SYSLOG__
8188 closelog();
8289 #endif
8390 return;
2323 #define _PNM2PPA_SYSLOG_H_
2424
2525
26 #ifdef __BEOS__
27 /* these are not actually used for BeOS messages... */
26 #ifdef __NO_SYSLOG__
27 /* (included only for compatibility, if syslog.h is absent): */
2828 #define LOG_EMERG 0 /* system is unusable */
2929 #define LOG_ALERT 1 /* action must be taken immediately */
3030 #define LOG_CRIT 2 /* critical conditions */
2727
2828 /* 04 */ "nemohu alokovat pamì» pro ppa\n",
2929
30 /* 05 */ "chyba pøi volání", //followed by function name
30 /* 05 */ "chyba pøi volání", /*followed by function name*/
3131
3232 /* 06 */ "neznámá návratová hodnota pøepínaèe\n",
3333
34 // from ppa,c
34 /* from ppa.c */
3535
36 /* 07 */ "zkracuji data pro trysky na 6 øádek, (pùvodnì ", // followed by number
36 /* 07 */ "zkracuji data pro trysky na 6 øádek, (pùvodnì ", /* followed by number */
3737
38 // messages from image.c
38 /* messages from image.c */
3939
4040 /* 08 */ "Nemohu vytvoøit gamma.ppm soubor. Zkontrolujte práva\n",
4141
42 /* 09 */ "Pøedèasnì ukonèený vstup - narazil jsem na EOF pøi ètení obrázku:", //followed by format
42 /* 09 */ "Pøedèasnì ukonèený vstup - narazil jsem na EOF pøi ètení obrázku:", /*followed by format*/
4343
4444 /* 10 */ "Fatální chyba - nemohu èíst obrázek\n",
4545
4747
4848 /* 12 */ "Fatální chyba! Nemohu alokovat pamì» pro buffer!\n",
4949
50 /* 13 */ "Vstupní obrázek nemá podporovaný PNM formát\n",
50 /* 13 */ "Fatální chyba! Vstupní obrázek (pnm2ppa) nemá PNM formát\n",
5151
52 /* 14 */ // (removed)
52 /* 14 */ /* (removed) */
5353
54 /* 15 */ "Tiskárna nemù¾e tisknout na papír velikosti ", //followed by size
54 /* 15 */ "Tiskárna nemù¾e tisknout na papír velikosti ", /*followed by size*/
5555
56 /* 16 */ "maximální hodnota PNM pixlu musí být 255, ale je: ", //followed by value
56 /* 16 */ "maximální hodnota PNM pixlu musí být 255, ale je: ", /*followed by value */
5757
58 // messages from ppa.c and pnm2ppa.c
58 /* messages from ppa.c and pnm2ppa.c */
5959
6060 /* 17 */ "Neznámá verze tiskárny\n",
6161
6363
6464 /* 19 */ "Zaèínám zpracovávat tiskovou úlohu\n",
6565
66 /* 20 */ "Tisknu stránku ", //followed by page number
66 /* 20 */ "Tisknu stránku ", /*followed by page number*/
6767
68 /* 21 */ "Konec zpracování stránky ", //followed by page number
68 /* 21 */ "Konec zpracování stránky ", /*followed by page number*/
6969
7070 /* 22 */ "®ádné stránky nebyly vyti¹tìny!\n",
7171
7979
8080 /* 27 */ "neznámá velikost papíru\n",
8181
82 /* 28 */ "neznámý parametr", // not followed by \n
82 /* 28 */ "neznámý parametr", /* not followed by \n */
8383
84 /* 29 */ "na øádce", // followed by line number
84 /* 29 */ "na øádce", /* followed by line number */
8585
86 /* 30 */ "chyba pøi ètení konfiguraèního souboru", // not followed by \n
86 /* 30 */ "chyba pøi ètení konfiguraèního souboru", /* not followed by \n */
8787
8888 /* 31 */ "Fatální chyba: neznámý argument\n" ,
8989
9191
9292 /* 33 */ "Nemohu otevøít vstupní PPA soubor\n",
9393
94 /* 34 */ "verze a datum pøekladu:", //followed by version number and date
94 /* 34 */ "verze a datum pøekladu:", /*followed by version number and date*/
9595
9696 /* 35 */ "Color correction curve (Gamma) file exists, but is corrupt.\n",
9797
98 /* 36 */ "POSSIBLE BUFFER OVERFLOW ATTACK!!: length of a path specified as an option exceeds", //followed by maximum allowed size
98 /* 36 */ "POSSIBLE BUFFER OVERFLOW ATTACK!!: length of a path specified as an option exceeds", /*followed by maximum allowed size*/
9999
100100 "FATAL: ©patné chybové hlá¹ení\n"
101101
2626
2727 /* 04 */ "could not malloc ppa storage\n",
2828
29 /* 05 */ "error calling", //followed by function name
29 /* 05 */ "error calling", /*followed by function name*/
3030
3131 /* 06 */ "unknown return code in switch\n",
3232
33 // from ppa,c
33 /* from ppa.c */
3434
35 /* 07 */ "truncating nozzle data to 6 rows, (was ", // followed by number
35 /* 07 */ "truncating nozzle data to 6 rows, (was ", /* followed by number*/
3636
37 // messages from image.c
37 /* messages from image.c */
3838
3939 /* 08 */ "Could not create gamma.ppm file. Check permissions\n",
4040
41 /* 09 */ "Truncated input - EOF while reading image:", //followed by format
41 /* 09 */ "Truncated input - EOF while reading image:", /*followed by format*/
4242
4343 /* 10 */ "Fatal error - failed to read input image\n",
4444
4646
4747 /* 12 */ "Fatal error! Unable to allocate buffer memory!\n",
4848
49 /* 13 */ "Input image is not a supported PNM format\n",
49 /* 13 */ "Fatal error! Input image (pnm2ppa) is not a PNM image\n",
5050
51 /* 14 */ // (removed)
51 /* 14 */ /* (removed) */
5252
53 /* 15 */ "Printer cannot print on paper size ", //followed by size
53 /* 15 */ "Printer cannot print on paper size ", /*followed by size*/
5454
55 /* 16 */ "maximum PNM pixel value must be 255, but is: ", //followed by value
55 /* 16 */ "maximum PNM pixel value must be 255, but is: ", /*followed by value*/
5656
57 // messages from ppa.c and pnm2ppa.c
57 /* messages from ppa.c and pnm2ppa.c*/
5858
5959 /* 17 */ "Unknown Printer version\n",
6060
6262
6363 /* 19 */ "Starting print job\n",
6464
65 /* 20 */ "Printing page ", //followed by page number
65 /* 20 */ "Printing page ", /*followed by page number*/
6666
67 /* 21 */ "Finished rendering page ", //followed by page number
67 /* 21 */ "Finished rendering page ", /*followed by page number*/
6868
6969 /* 22 */ "No pages printed!\n",
7070
7878
7979 /* 27 */ "unknown paper size\n",
8080
81 /* 28 */ "unrecognized parameter", //not followed by \n
81 /* 28 */ "unrecognized parameter", /*not followed by \n */
8282
83 /* 29 */ "at line", // followed by line number
83 /* 29 */ "at line", /* followed by line number */
8484
85 /* 30 */ "error parsing config file", // not followed by \n
85 /* 30 */ "error parsing config file", /* not followed by \n */
8686
8787 /* 31 */ "Fatal: unknown argument\n" ,
8888
9090
9191 /* 33 */ "Could not open PNM input file\n",
9292
93 /* 34 */ "version and build date:", //followed by version number and date
93 /* 34 */ "version and build date:", /*followed by version number and date */
9494
9595 /* 35 */ "Color correction curve (Gamma) file exists, but is corrupt.\n",
9696
97 /* 36 */ "POSSIBLE BUFFER OVERFLOW ATTACK!!: length of a path specified as an option exceeds", //followed by maximum allowed size
97 /* 36 */ "POSSIBLE BUFFER OVERFLOW ATTACK!!: length of a path specified as an option exceeds", /*followed by maximum allowed size */
9898
9999
100100 "FATAL: Bad error message\n"
3636
3737 /* 04 */ "no pude reservar memoria para almacenar el ppa\n",
3838
39 /* 05 */ "error invocando", //followed by function name
39 /* 05 */ "error invocando", /*followed by function name*/
4040
4141 /* 06 */ "codigo devuelto por switch desconocido\n",
4242
43 // from ppa,c
43 /* from ppa.c */
4444
45 /* 07 */ "truncando datos de las boquillas a 6 filas, (era ", // followed by number
45 /* 07 */ "truncando datos de las boquillas a 6 filas, (era ", /* followed by number */
4646
47 // messages from image.c
47 /* messages from image.c */
4848
4949 /* 08 */ "No pude crear el archivo gamma.ppm . Comprueba los permisos\n",
5050
51 /* 09 */ "Entrada truncada - EOF mientras leia la imagen:", //followed by format
51 /* 09 */ "Entrada truncada - EOF mientras leia la imagen:", /*followed by format */
5252
5353 /* 10 */ "Error fatal - imposible leer imagen de entrada\n",
5454
5656
5757 /* 12 */ "Error fatal! Imposible reservar buffer de memoria!\n",
5858
59 /* 13 */ "La imagen de entrada no es uno de los formatos PNM soportados\n",
59 /* 13 */ "Error fatal! La imagen de entrada (pnm2ppa) no es una imagen PNM\n",
6060
61 /* 14 */ // removed
61 /* 14 */ /* removed */
6262
63 /* 15 */ "La impresora no puede imprimir en tamaño de papel ", //followed by size
63 /* 15 */ "La impresora no puede imprimir en tamaño de papel ", /*followed by size */
6464
65 /* 16 */ "el maximo calor para un pixel PNM debe ser 255, pero es: ", //followed by value
65 /* 16 */ "el maximo calor para un pixel PNM debe ser 255, pero es: ", /*followed by value */
6666
67 // messages from ppa.c and pnm2ppa.c
67 /* messages from ppa.c and pnm2ppa.c */
6868
6969 /* 17 */ "Version de impresora desconocida\n",
7070
7272
7373 /* 19 */ "Comenzando trabajo de impresion\n",
7474
75 /* 20 */ "Imprimiendo pagina ", //followed by page number
75 /* 20 */ "Imprimiendo pagina ", /*followed by page number */
7676
77 /* 21 */ "Terminado renderizado de la pagina ", //followed by page number
77 /* 21 */ "Terminado renderizado de la pagina ", /*followed by page number*/
7878
7979 /* 22 */ "No imprimi ninguna pagina!\n",
8080
8888
8989 /* 27 */ "tamaño de papel desconocido\n",
9090
91 /* 28 */ "parametro desconocido", //not followed by \n
91 /* 28 */ "parametro desconocido", /*not followed by \n*/
9292
93 /* 29 */ "en la linea", // followed by line number
93 /* 29 */ "en la linea", /* followed by line number */
9494
95 /* 30 */ "error procesando el archivo de configuracionco", // not followed by \n
95 /* 30 */ "error procesando el archivo de configuracionco", /* not followed by \n */
9696
9797 /* 31 */ "Critico: argumento desconocido\n" ,
9898
100100
101101 /* 33 */ "No pude abrir el archivo de entrada PNM\n",
102102
103 /* 34 */ "version y fecha de compilacion:", //followed by version number and date
103 /* 34 */ "version y fecha de compilacion:", /*followed by version number and date */
104104
105105 /* 35 */ "El archivo de correcion de color (gamma) existe, pero esta corrupto.\n",
106106
107 /* 36 */ "POSSIBLE BUFFER OVERFLOW ATTACK!!: length of a path specified as an option exceeds", //followed by maximum allowed size
107 /* 36 */ "POSSIBLE BUFFER OVERFLOW ATTACK!!: length of a path specified as an option exceeds", /*followed by maximum allowed size */
108108 "CRITICO: Mensaje de error incorrecto\n"
2727
2828 /* 04 */ "ne peut allouer de mémoire pour ppa\n",
2929
30 /* 05 */ "erreur lors de l'appel à", //suivi du nom de la fonction
30 /* 05 */ "erreur lors de l'appel à", /*suivi du nom de la fonction*/
3131
3232 /* 06 */ "code retour inconnu lors du switch\n",
3333
34 // from ppa,c
34 /* from ppa.c */
3535
36 /* 07 */ "troncature des données buses à 6 lignes, (initiallement ", //suivi du nombre
36 /* 07 */ "troncature des données buses à 6 lignes, (initiallement ", /*suivi du nombre */
3737
38 // messages de image.c
38 /* messages de image.c */
3939
4040 /* 08 */ "ne peut créer le fichier gamma.ppm . Vérifiez les permissions\n",
4141
42 /* 09 */ "Entrée tronquée - EOF pendant la lecture de l'image:", //suivi du format
42 /* 09 */ "Entrée tronquée - EOF pendant la lecture de l'image:", /*suivi du format */
4343
4444 /* 10 */ "Erreur fatale - impossible de lire l'image en entrée\n",
4545
4747
4848 /* 12 */ "Erreur fatale! Impossible d'allouer un buffer mémoire!\n",
4949
50 /* 13 */ "L'image en entrée n'est pas à un format PNM supporté\n",
50 /* 13 */ "Erreur fatale! L'image en entrée (pnm2ppa) n'est pas un image PNM\n",
5151
52 /* 14 */ // removed
52 /* 14 */ /* removed */
5353
54 /* 15 */ "L'imprimante ne peut imprimer sur cette taille de papier ", //suivi de la taille
54 /* 15 */ "L'imprimante ne peut imprimer sur cette taille de papier ", /*suivi de la taille */
5555
56 /* 16 */ "la valeur maximale d'un pixel PNM devrait être 255, mais est : ", //suivi de la valeur
56 /* 16 */ "la valeur maximale d'un pixel PNM devrait être 255, mais est : ", /*suivi de la valeur */
5757
58 // messages de ppa.c et pnm2ppa.c
58 /* messages de ppa.c et pnm2ppa.c */
5959
6060 /* 17 */ "Version d'imprimante inconnue\n",
6161
6363
6464 /* 19 */ "Début de la tâche d'impression\n",
6565
66 /* 20 */ "Impression de la page ", //suivi du numéro de page
66 /* 20 */ "Impression de la page ", /*suivi du numéro de page*/
6767
68 /* 21 */ "Fin du rendu de la page ", //suivi du numéro de page
68 /* 21 */ "Fin du rendu de la page ", /*suivi du numéro de page*/
6969
7070 /* 22 */ "Aucune page imprimée!\n",
7171
7979
8080 /* 27 */ "taille de papier inconnue\n",
8181
82 /* 28 */ "paramètre non reconnu", //non suivi de \n
82 /* 28 */ "paramètre non reconnu", /*non suivi de \n*/
8383
84 /* 29 */ "à la ligne", // suivi du numéro de ligne
84 /* 29 */ "à la ligne", /* suivi du numéro de ligne*/
8585
86 /* 30 */ "erreur de traitement du fichier de configuration", //non suivi de \n
86 /* 30 */ "erreur de traitement du fichier de configuration", /*non suivi de \n */
8787
8888 /* 31 */ "Fatal: argument inconnu\n" ,
8989
9191
9292 /* 33 */ "Ne peut ouvrir le fichier PNM en entrée\n",
9393
94 /* 34 */ "version et date de création:", //suivi du numéro de version et de sa date
94 /* 34 */ "version et date de création:", /*suivi du numéro de version et de sa date */
9595
9696 /* 35 */ "Color correction curve (Gamma) file exists, but is corrupt.\n",
9797
98 /* 36 */ "POSSIBLE BUFFER OVERFLOW ATTACK!!: length of a path specified as an option exceeds", //followed by maximum allowed size
98 /* 36 */ "POSSIBLE BUFFER OVERFLOW ATTACK!!: length of a path specified as an option exceeds", /*followed by maximum allowed size */
9999
100100 "FATAL: mauvais message d'erreur\n"
101101
2424
2525 /* 01 */ "impossibile leggere il margine superiore\n",
2626
27 /* 02 */ "impossibile espellere il margine inferiore\n", // FIXME: che vuol dire "clear bottom margin"?
27 /* 02 */ "impossibile espellere il margine inferiore\n", /* FIXME: che vuol dire "clear bottom margin"? */
2828
2929 /* 03 */ "impossibile leggere la riga successiva\n",
3030
3131 /* 04 */ "impossibile allocare memoria per il PPA\n",
3232
33 /* 05 */ "errore invocando la funzione", //followed by function name
33 /* 05 */ "errore invocando la funzione", /*followed by function name*/
3434
35 /* 06 */ "codice di ritorno dello scambio sconosciuto\n", // FIXME: "switch" = "scambio"??
35 /* 06 */ "codice di ritorno dello scambio sconosciuto\n", /* FIXME: "switch" = "scambio"?? */
3636
3737
38 // from ppa.c
38 /* from ppa.c */
3939
40 /* 07 */ "troncati i dati del beccuccio a 6 righe, (erano ", // followed by number // FIXME: nozzle data??
40 /* 07 */ "troncati i dati del beccuccio a 6 righe, (erano ", /* followed by number */ /* FIXME: nozzle data?? */
4141
42 // messages from image.c
42 /* messages from image.c */
4343
4444 /* 08 */ "impossibile creare il file gamma.ppm. Controllare i permessi.\n",
4545
46 /* 09 */ "Input troncato - File terminato durante la lettura dell'immagine:", //followed by format
46 /* 09 */ "Input troncato - File terminato durante la lettura dell'immagine:", /*followed by format */
4747
4848 /* 10 */ "Errore critico - impossibile leggere l'immagine in ingresso\n",
4949
5050 /* 11 */ "Errore critico - l'immagine in ingresso ha pixel con valore > 255\n",
5151
52 /* 12 */ "Errore critico! Impossibile allocare memoria per il buffer!\n", // FIXME: "memoria tampone"?
52 /* 12 */ "Errore critico! Impossibile allocare memoria per il buffer!\n", /* FIXME: "memoria tampone"? */
5353
54 /* 13 */ "L'immagine in ingresso non è in un formato PNM riconosciuto\n",
54 /* 13 */ "Errore critic! L'immagine in ingresso (pnm2ppa) non è un immagine PNM\n",
5555
56 /* 14 */ // removed
56 /* 14 */ /* removed */
5757
58 /* 15 */ "La stampante non può stampare su carta in formato ", //followed by size
58 /* 15 */ "La stampante non può stampare su carta in formato ", /*followed by size*/
5959
60 /* 16 */ "indice colore errato: il massimo è 255, il file contiene ", //followed by value
60 /* 16 */ "indice colore errato: il massimo è 255, il file contiene ", /*followed by value */
6161
62 // messages from ppa.c and pnm2ppa.c
62 /* messages from ppa.c and pnm2ppa.c */
6363
6464 /* 17 */ "Versione della stampante sconosciuta\n",
6565
6767
6868 /* 19 */ "Comincia il lavoro di stampa\n",
6969
70 /* 20 */ "Stampa in corso, pagina ", //followed by page number
70 /* 20 */ "Stampa in corso, pagina ", /*followed by page number*/
7171
72 /* 21 */ "Composta la pagina ", //followed by page number
72 /* 21 */ "Composta la pagina ", /*followed by page number*/
7373
7474 /* 22 */ "Nessuna pagina stampata!\n",
7575
8181
8282 /* 26 */ "impossibile aprire il file di configurazione\n",
8383
84 /* 27 */ "formato della carta sconosciuto\",
84 /* 27 */ "formato della carta sconosciuto\n",
8585
86 /* 28 */ "parametro non riconosciuto", //not followed by /n
86 /* 28 */ "parametro non riconosciuto", /*not followed by /n */
8787
88 /* 29 */ "alla linea", // followed by line number
88 /* 29 */ "alla linea", /* followed by line number */
8989
90 /* 30 */ "errore nel file di configurazione", // not followed by \n
90 /* 30 */ "errore nel file di configurazione", /* not followed by \n */
9191
9292 /* 31 */ "Errore critico: argomento sconosciuto\n" ,
9393
9595
9696 /* 33 */ "Impossibile aprire il file di ingresso PNM\n",
9797
98 /* 34 */ "versione e data di compilazione:", //followed by version number and date
98 /* 34 */ "versione e data di compilazione:", /*followed by version number and date */
9999
100100 /* 35 */ "Color correction curve (Gamma) file exists, but is corrupt.\n",
101101
102 /* 36 */ "POSSIBLE BUFFER OVERFLOW ATTACK!!: length of a path specified as an option exceeds", //followed by maximum allowed size
102 /* 36 */ "POSSIBLE BUFFER OVERFLOW ATTACK!!: length of a path specified as an option exceeds", /*followed by maximum allowed size */
103103 "ERRORE CRITICO: messaggio di errore impossibile (bug nel programma)\n"
104104
105
106
107
108
3232 /* 04 */ "er kon geen geheugen toewijzen worden voor de ppa opslag\n",
3333
3434 /* error calling */
35 /* 05 */ "fout tijdens het aanroepen van ", //followed by function name
35 /* 05 */ "fout tijdens het aanroepen van ", /*followed by function name*/
3636
3737 /* unknown return code in switch */
3838 /* 06 */ "onbekende return code in switch\n",
3939
40 // from ppa,c
40 /* from ppa.c */
4141
4242 /* truncating nozzle data to 6 rows, (was */
43 /* 07 */ "spuitgat gegevens worden afgekapt tot 6 rijen, (het waren ", // followed by number
43 /* 07 */ "spuitgat gegevens worden afgekapt tot 6 rijen, (het waren ", /* followed by number*/
4444
45 // messages from image.c
45 /* messages from image.c */
4646
4747 /* Could not create gamma file. Check permissions */
4848 /* 08 */ "gamma.ppm bestand kon niet worden gemaakt. Controleer de toegangsrechten\n",
4949
5050 /* Truncated input - EOF while reading image: */
51 /* 09 */ "Afgekapte invoer - EOF tijdens het lezen van de afbeelding: ", //followed by format
51 /* 09 */ "Afgekapte invoer - EOF tijdens het lezen van de afbeelding: ", /*followed by format*/
5252
5353 /* Fatal error - failed to read input image */
5454 /* 10 */ "Fatale fout - invoer afbeelding kon niet gelezen worden\n",
6060 /* 12 */ "Fatale fout! Kan geen buffer geheugen toewijzen!\n",
6161
6262 /* Input image is not a supported PNM format */
63 /* 13 */ "Invoer afbeelding is niet van een door PNM ondersteunde indeling\n",
63 /* 13 */ "Fatale fout! Invoer afbeelding (pnm2ppa) is niet een PNM indeling\n",
6464
6565 /* Unknown PNM magic */
66 /* 14 */ //removed
66 /* 14 */ /*removed*/
6767
6868
6969 /* Printer cannot print on paper size */
70 /* 15 */ "De printer kan niet afdrukken op de papiergrootte ", //followed by size
70 /* 15 */ "De printer kan niet afdrukken op de papiergrootte ", /*followed by size */
7171
7272 /* maximum PNM pixel value must be 255, but is: */
73 /* 16 */ "maximale PNM pixel waarde moet 255 zijn, maar het is: ", //followed by value
73 /* 16 */ "maximale PNM pixel waarde moet 255 zijn, maar het is: ", /*followed by value*/
7474
75 // messages from ppa.c and pnm2ppa.c
75 /* messages from ppa.c and pnm2ppa.c */
7676
7777 /* Unknown Printer version */
7878 /* 17 */ "Onbekende printer versie\n",
8484 /* 19 */ "Afdruk opdracht wordt gestart\n",
8585
8686 /* Printing page */
87 /* 20 */ "Bezig met afdrukken van pagina ", //followed by page number
87 /* 20 */ "Bezig met afdrukken van pagina ", /*followed by page number */
8888
8989 /* Finished rendering page */
90 /* 21 */ "Klaar met afbeelden van pagina ", //followed by page number
90 /* 21 */ "Klaar met afbeelden van pagina ", /*followed by page number */
9191
9292 /* No pages printed! */
9393 /* 22 */ "Geen pagina's afgedrukt!\n",
108108 /* 27 */ "onbekende papiergrootte\n",
109109
110110 /* unrecognized parameter */
111 /* 28 */ "onbekende parameter", //not followed by \n
111 /* 28 */ "onbekende parameter", /*not followed by \n */
112112
113113 /* at line */
114 /* 29 */ "in rij ", // followed by line number
114 /* 29 */ "in rij ", /* followed by line number */
115115
116116 /* error parsing config file */
117 /* 30 */ "fout bij het interpreteren van het configuratie bestand", // not followed by \n
117 /* 30 */ "fout bij het interpreteren van het configuratie bestand", /* not followed by \n */
118118
119119 /* Fatal: unknown argument */
120120 /* 31 */ "Fataal: onbekend argument\n",
126126 /* 33 */ "PNM invoer bestand kon niet geopend worden\n",
127127
128128 /* version and build date: */
129 /* 34 */ "versie en compileer datum: ", //followed by version number and date
129 /* 34 */ "versie en compileer datum: ", /*followed by version number and date*/
130130
131131 /* 35 */ "Color correction curve (Gamma) file exists, but is corrupt.\n",
132132
133133
134 /* 36 */ "POSSIBLE BUFFER OVERFLOW ATTACK!!: length of a path specified as an option exceeds", //followed by maximum allowed size
134 /* 36 */ "POSSIBLE BUFFER OVERFLOW ATTACK!!: length of a path specified as an option exceeds", /*followed by maximum allowed size*/
135135
136136 /* FATAL: Bad error message */
137137
00 #!/bin/sh
11 # script for testing installation of a PPA printer, v0.5 20000908
2 # (C) 2000 The pnm2ppa project
2 # (C) 2000,2001 The pnm2ppa project
33
44 # Requires Linux 2.2.x kernels with parport autoprobe support.
5 # assumes all parallel ports are in the range 0-7
6 # (as linux/include/parport.h sets PARPORT_MAX=8)
5 # Now updated for 2.4.x kernels too.
6 # assumes all parallel ports are in the range 0-7 (0-15 in 2.4 kernels)
7 # (as linux/include/parport.h sets PARPORT_MAX=8) (=16 in 2.4)
78
89 MODPROBE="/sbin/modprobe"
10 PROC_PARPORT="/proc/parport"
11 PARPORT=""
12 PARPORT_LIST="0 1 2 3 4 5 6 7"
913
1014 echo "*** Script for testing installation of PPA printers on Linux "
1115 echo " (requires 2.2.x kernel or later)"
1216 supported="710 720 820 1000"
1317
14 if [ "$($MODPROBE -l parport_probe.o )" = "" ] ; then
15 echo "*** kernel module parport_probe.o not found:"
16 echo "*** IEEE-1284 autodetection not supported by this Linux kernel"
17 exit 1
18 if [ -e /proc/sys/dev/parport ] ; then
19 echo "*** 2.4.x kernel: found /proc/sys/dev/parport/"
20 PROC_PARPORT="/proc/sys/dev/parport"
21 PARPORT="parport"
22 PARPORT_LIST="0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15"
23 else
24
25 if [ "$($MODPROBE -l parport_probe.o )" = "" ] ; then
26 echo "*** kernel module parport_probe.o not found:"
27 echo "*** IEEE-1284 autodetection not supported by this Linux kernel"
28 exit 1
29 fi
1830 fi
1931
2032 if ! $($MODPROBE -r ) ; then
3244 done
3345 $MODPROBE lp
3446
35 if [ -e /proc/parport ] ; then
47 if [ -e $PROC_PARPORT ] ; then
3648 found=0
3749 found_ppa=0
3850 ppa_printer=""
39 for n in 0 1 2 3 4 5 6 7 ; do
40 if [ -e /proc/parport/$n/autoprobe ] ; then
51 for n in $PARPORT_LIST ; do
52 if [ -e $PROC_PARPORT/$PARPORT$n/autoprobe ] ; then
4153 found=1
4254 echo " "
43 echo "Printer found at parallel port $n (usually /dev/lp$n )"
55 echo "Device found at parallel port $n (usually /dev/lp$n )"
4456 echo "IEEE-1284 autoprobe reports:"
45 cat /proc/parport/$n/autoprobe
46 report=$(cat /proc/parport/$n/autoprobe)
57 cat $PROC_PARPORT/$PARPORT$n/autoprobe
58 report=$(cat $PROC_PARPORT/$PARPORT$n/autoprobe)
4759 for printer in $supported ; do
4860 if $(echo $report |grep -e "DESKJET $printer" >/dev/null) ; then
4961 found_ppa=1