-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrastertozjs.c
More file actions
722 lines (624 loc) · 19.7 KB
/
rastertozjs.c
File metadata and controls
722 lines (624 loc) · 19.7 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
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
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
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
198
199
200
201
202
203
204
205
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
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
/*
* rastertozjs.c — CUPS raster filter for ZjStream printers
*
* Converts CUPS raster input to Zenographics ZjStream format with JBIG
* compression. Supports multiple printer models:
*
* Model 0 (2300DL): Minolta/QMS 2300DL, 2200DL, 2430DL, HP LJ 1000/1005
* Model 1 (HP1020): HP LaserJet 1018, 1020, 1022, M1319, P2035
* Model 2 (HP Pro): HP LaserJet Pro P1102, P1102w, P1566, P1606dn
* Model 3 (HP Pro CP): HP LaserJet Pro CP1025nw (color)
*
* Pipeline: PDF → cgpdftoraster (macOS built-in) → rastertozjs → printer
*
* Based on foo2zjs from the foo2zjs project by Rick Richardson.
* Rewritten as a native CUPS raster filter.
*
* License: GPL v2 or later (same as foo2zjs)
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <fcntl.h>
#include <signal.h>
#include <time.h>
#include <cups/cups.h>
#include <cups/raster.h>
#include "jbig.h"
#include "zjs.h"
/* Model variants */
#define MODEL_2300DL 0
#define MODEL_HP1020 1
#define MODEL_HP_PRO 2
#define MODEL_HP_PRO_CP 3
/* ---------- ZJS output helpers ---------- */
static void
chunk_write_rsvd(unsigned long type, unsigned int rsvd,
unsigned long items, unsigned long size, FILE *fp)
{
ZJ_HEADER chunk;
chunk.type = be32(type);
chunk.items = be32(items);
chunk.size = be32(sizeof(ZJ_HEADER) + size);
chunk.reserved = be16(rsvd);
chunk.signature = 0x5a5a;
if (fwrite(&chunk, 1, sizeof(ZJ_HEADER), fp) == 0)
{
fprintf(stderr, "ERROR: rastertozjs: chunk_write failed\n");
exit(1);
}
}
static void
chunk_write(unsigned long type, unsigned long items, unsigned long size,
FILE *fp)
{
chunk_write_rsvd(type, 0, items, size, fp);
}
static void
item_uint32_write(unsigned short item, unsigned long value, FILE *fp)
{
ZJ_ITEM_UINT32 rec;
rec.header.size = be32(sizeof(ZJ_ITEM_UINT32));
rec.header.item = be16(item);
rec.header.type = ZJIT_UINT32;
rec.header.param = 0;
rec.value = be32(value);
if (fwrite(&rec, 1, sizeof(ZJ_ITEM_UINT32), fp) == 0)
{
fprintf(stderr, "ERROR: rastertozjs: item_uint32_write failed\n");
exit(1);
}
}
/* ---------- JBIG compressed data chain ---------- */
typedef struct _BIE_CHAIN {
unsigned char *data;
size_t len;
struct _BIE_CHAIN *next;
} BIE_CHAIN;
static void
free_chain(BIE_CHAIN *chain)
{
BIE_CHAIN *next;
next = chain;
while ((chain = next))
{
next = chain->next;
if (chain->data)
free(chain->data);
free(chain);
}
}
static long JbgOptions[5] = {
JBG_ILEAVE | JBG_SMID,
JBG_DELAY_AT | JBG_LRLTWO | JBG_TPDON | JBG_TPBON | JBG_DPON,
128,
16,
0
};
static void
output_jbig(unsigned char *start, size_t len, void *cbarg)
{
BIE_CHAIN *current, **root = (BIE_CHAIN **)cbarg;
int size = 65536;
if (*root == NULL)
{
*root = malloc(sizeof(BIE_CHAIN));
if (!*root)
{
fprintf(stderr, "ERROR: rastertozjs: malloc failed\n");
exit(1);
}
(*root)->data = NULL;
(*root)->next = NULL;
(*root)->len = 0;
size = 20;
}
current = *root;
while (current->next)
current = current->next;
while (len > 0)
{
int amt, left;
if (!current->data)
{
current->data = malloc(size);
if (!current->data)
{
fprintf(stderr, "ERROR: rastertozjs: malloc failed\n");
exit(1);
}
}
left = size - current->len;
amt = (len > (size_t)left) ? left : (int)len;
memcpy(current->data + current->len, start, amt);
current->len += amt;
len -= amt;
start += amt;
if (current->len == (size_t)size)
{
current->next = malloc(sizeof(BIE_CHAIN));
if (!current->next)
{
fprintf(stderr, "ERROR: rastertozjs: malloc failed\n");
exit(1);
}
current = current->next;
current->data = NULL;
current->next = NULL;
current->len = 0;
}
}
}
/* ---------- ZJS page/plane output ---------- */
#define PADTO 4
#define EXTRA_PAD 16
static int
write_plane(int planeNum, BIE_CHAIN **root, FILE *fp, int model)
{
BIE_CHAIN *current = *root;
BIE_CHAIN *next;
int i, len, pad_len;
if (!current || !current->next || current->len != 20)
{
fprintf(stderr, "ERROR: rastertozjs: invalid JBIG data\n");
return 1;
}
if (planeNum)
{
if (model == MODEL_HP_PRO_CP)
chunk_write_rsvd(ZJT_START_PLANE, 1 * 12,
1, 1 * sizeof(ZJ_ITEM_UINT32), fp);
else
chunk_write(ZJT_START_PLANE, 1, 1 * sizeof(ZJ_ITEM_UINT32), fp);
item_uint32_write(ZJI_PLANE, planeNum, fp);
}
for (current = *root; current && current->len; current = current->next)
{
if (current == *root)
{
chunk_write(ZJT_JBIG_BIH, 0, current->len, fp);
fwrite(current->data, 1, current->len, fp);
}
else
{
len = current->len;
next = current->next;
if (!next || !next->len)
pad_len = EXTRA_PAD + PADTO * ((len + PADTO - 1) / PADTO) - len;
else
pad_len = 0;
chunk_write(ZJT_JBIG_BID, 0, len + pad_len, fp);
fwrite(current->data, 1, len, fp);
for (i = 0; i < pad_len; i++)
putc(0, fp);
}
}
free_chain(*root);
/* END_JBIG */
switch (model)
{
case MODEL_2300DL:
case MODEL_HP1020:
chunk_write(ZJT_END_JBIG, 0, 0, fp);
break;
case MODEL_HP_PRO:
case MODEL_HP_PRO_CP:
chunk_write(ZJT_END_JBIG, 0, 0, fp);
break;
}
/* END_PLANE */
if (planeNum)
{
if (model == MODEL_HP_PRO_CP)
{
int nitems = 1;
chunk_write_rsvd(ZJT_END_PLANE, nitems * 12,
nitems, nitems * sizeof(ZJ_ITEM_UINT32), fp);
item_uint32_write(ZJI_PLANE, planeNum, fp);
}
else
{
chunk_write(ZJT_END_PLANE, 0, 0, fp);
}
}
return 0;
}
static void
start_doc(FILE *fp, int model, int density, int economode)
{
char header[4] = "JZJZ";
int nitems;
int size;
time_t now;
struct tm *tmp;
char datetime[14 + 1];
/* PJL preamble for HP models */
if (model == MODEL_HP1020 || model == MODEL_HP_PRO ||
model == MODEL_HP_PRO_CP)
{
now = time(NULL);
tmp = localtime(&now);
strftime(datetime, sizeof(datetime), "%Y%m%d%H%M%S", tmp);
fprintf(fp, "\033%%-12345X@PJL JOB\n");
fprintf(fp, "@PJL SET JAMRECOVERY=OFF\n");
fprintf(fp, "@PJL SET DENSITY=%d\n", density);
fprintf(fp, "@PJL SET ECONOMODE=%s\n", economode ? "ON" : "OFF");
fprintf(fp, "@PJL SET RET=MEDIUM\n");
fprintf(fp, "@PJL INFO STATUS\n");
fprintf(fp, "@PJL USTATUS DEVICE = ON\n");
fprintf(fp, "@PJL USTATUS JOB = ON\n");
fprintf(fp, "@PJL USTATUS PAGE = ON\n");
fprintf(fp, "@PJL USTATUS TIMED = 30\n");
fprintf(fp, "@PJL SET JOBATTR=\"JobAttr4=%s\"", datetime);
fputc(0, fp);
fprintf(fp, "\033%%-12345X");
}
fwrite(header, 1, sizeof(header), fp);
/* START_DOC */
nitems = 1; /* ZJI_DMCOLLATE always */
switch (model)
{
case MODEL_2300DL:
nitems += 3; /* DMDUPLEX, PAGECOUNT, QUANTITY */
break;
case MODEL_HP1020:
case MODEL_HP_PRO_CP:
nitems += 2; /* DMDUPLEX, PAGECOUNT */
break;
case MODEL_HP_PRO:
nitems += 1; /* DMDUPLEX (simplex only) */
break;
}
size = nitems * sizeof(ZJ_ITEM_UINT32);
switch (model)
{
case MODEL_2300DL:
chunk_write(ZJT_START_DOC, nitems, size, fp);
break;
case MODEL_HP1020:
chunk_write_rsvd(ZJT_START_DOC, 0x24, nitems, size, fp);
break;
case MODEL_HP_PRO:
case MODEL_HP_PRO_CP:
chunk_write_rsvd(ZJT_START_DOC, nitems * 0x0c, nitems, size, fp);
break;
}
item_uint32_write(ZJI_DMCOLLATE, 0, fp);
switch (model)
{
case MODEL_2300DL:
case MODEL_HP1020:
case MODEL_HP_PRO_CP:
item_uint32_write(ZJI_DMDUPLEX, 1, fp); /* off */
item_uint32_write(ZJI_PAGECOUNT, 0, fp);
break;
case MODEL_HP_PRO:
item_uint32_write(ZJI_DMDUPLEX, 1, fp); /* off */
break;
}
if (model == MODEL_2300DL)
item_uint32_write(ZJI_QUANTITY, 1, fp);
}
static void
end_doc(FILE *fp, int model)
{
chunk_write(ZJT_END_DOC, 0, 0, fp);
if (model == MODEL_HP1020 || model == MODEL_HP_PRO ||
model == MODEL_HP_PRO_CP)
{
fprintf(fp, "\033%%-12345X@PJL EOJ\n");
fprintf(fp, "\033%%-12345X");
}
}
static void
start_page(FILE *fp, int model, int resX, int resY, int bpp,
unsigned long rasterW, unsigned long rasterH,
int realWidth,
int paperCode, int mediaCode, int sourceCode,
int copies, int economode)
{
int nitems = 12;
switch (model)
{
case MODEL_2300DL:
nitems += 4 + 1; /* custom x/y, minolta page#, economode */
chunk_write(ZJT_START_PAGE, nitems,
nitems * sizeof(ZJ_ITEM_UINT32), fp);
break;
case MODEL_HP1020:
nitems += 1; /* economode */
chunk_write_rsvd(ZJT_START_PAGE, 0x9c, nitems,
nitems * sizeof(ZJ_ITEM_UINT32), fp);
break;
case MODEL_HP_PRO:
nitems += 1 + 1; /* RET + economode (if set) */
if (!economode) nitems -= 1;
chunk_write_rsvd(ZJT_START_PAGE, nitems * 12, nitems,
nitems * sizeof(ZJ_ITEM_UINT32), fp);
break;
case MODEL_HP_PRO_CP:
nitems += 1; /* PLANE */
if (economode) nitems += 1;
chunk_write_rsvd(ZJT_START_PAGE, nitems * 12, nitems,
nitems * sizeof(ZJ_ITEM_UINT32), fp);
break;
}
if (model == MODEL_HP_PRO_CP)
item_uint32_write(ZJI_PLANE, 1, fp); /* nbie=1 for mono */
if (model == MODEL_2300DL || model == MODEL_HP1020 || economode)
item_uint32_write(ZJI_ECONOMODE, economode, fp);
item_uint32_write(ZJI_VIDEO_X, realWidth / bpp, fp);
item_uint32_write(ZJI_VIDEO_Y, rasterH, fp);
item_uint32_write(ZJI_VIDEO_BPP, bpp, fp);
if (model == MODEL_HP_PRO_CP)
item_uint32_write(ZJI_RASTER_X, rasterW, fp);
else
item_uint32_write(ZJI_RASTER_X, realWidth, fp);
item_uint32_write(ZJI_RASTER_Y, rasterH, fp);
item_uint32_write(ZJI_NBIE, 1, fp); /* mono */
item_uint32_write(ZJI_RESOLUTION_X, resX, fp);
item_uint32_write(ZJI_RESOLUTION_Y, resY, fp);
if (model == MODEL_HP_PRO)
item_uint32_write(ZJI_RET, 1, fp);
item_uint32_write(ZJI_DMDEFAULTSOURCE, sourceCode, fp);
item_uint32_write(ZJI_DMCOPIES, copies, fp);
item_uint32_write(ZJI_DMPAPER, paperCode, fp);
item_uint32_write(ZJI_DMMEDIATYPE, mediaCode, fp);
if (model == MODEL_2300DL)
{
item_uint32_write(ZJI_MINOLTA_CUSTOM_X, 0, fp);
item_uint32_write(ZJI_MINOLTA_CUSTOM_Y, 0, fp);
static int pageno = 0;
item_uint32_write(ZJI_MINOLTA_PAGE_NUMBER, ++pageno, fp);
}
}
static void
end_page(FILE *fp, int model)
{
switch (model)
{
case MODEL_2300DL:
case MODEL_HP1020:
case MODEL_HP_PRO:
chunk_write(ZJT_END_PAGE, 0, 0, fp);
break;
case MODEL_HP_PRO_CP:
chunk_write(ZJT_END_PAGE, 0, 0, fp);
break;
}
}
/* ---------- Mapping functions ---------- */
static int
map_paper_code(const char *name)
{
if (!name || !name[0])
return DMPAPER_LETTER;
if (strcmp(name, "Letter") == 0) return DMPAPER_LETTER;
if (strcmp(name, "Legal") == 0) return DMPAPER_LEGAL;
if (strcmp(name, "Executive") == 0) return DMPAPER_EXECUTIVE;
if (strcmp(name, "A4") == 0) return DMPAPER_A4;
if (strcmp(name, "A5") == 0) return DMPAPER_A5;
if (strcmp(name, "A6") == 0) return 70;
if (strcmp(name, "B5") == 0) return DMPAPER_B5;
if (strcmp(name, "Env10") == 0) return DMPAPER_ENV_10;
if (strcmp(name, "EnvDL") == 0) return DMPAPER_ENV_DL;
if (strcmp(name, "EnvC5") == 0) return DMPAPER_ENV_C5;
if (strcmp(name, "EnvB5") == 0) return DMPAPER_ENV_B5;
if (strcmp(name, "EnvMonarch") == 0) return DMPAPER_ENV_MONARCH;
if (strcmp(name, "Postcard") == 0) return DMPAPER_JAPANESE_POSTCARD;
if (strcmp(name, "FanFoldGermanLegal") == 0) return DMPAPER_FANFOLD_LGL_GERMAN;
return DMPAPER_LETTER;
}
static int
map_media_code(const char *media, int model)
{
if (!media || !media[0])
return DMMEDIA_STANDARD;
if (strcmp(media, "Plain") == 0) return DMMEDIA_STANDARD;
if (strcmp(media, "Transparency") == 0) return DMMEDIA_TRANSPARENCY;
if (strcmp(media, "Glossy") == 0) return DMMEDIA_GLOSSY;
/* Extended codes for HP models (z1/z2/z3) */
if (model >= MODEL_HP1020)
{
if (strcmp(media, "Envelope") == 0) return 267;
if (strcmp(media, "Letterhead") == 0) return 513;
if (strcmp(media, "ThickStock") == 0) return 261;
if (strcmp(media, "Cardstock") == 0) return 261;
if (strcmp(media, "Labels") == 0) return 265;
if (strcmp(media, "Rough") == 0) return 263;
if (strcmp(media, "Heavy") == 0) return 261;
if (strcmp(media, "Light") == 0) return 258;
if (strcmp(media, "Vellum") == 0) return 273;
if (strcmp(media, "Color") == 0) return 512;
if (strcmp(media, "Preprinted") == 0) return 514;
if (strcmp(media, "Prepunched") == 0) return 515;
if (strcmp(media, "Recycled") == 0) return 516;
}
else
{
/* Model 0 (2300DL/Minolta) codes */
if (strcmp(media, "Envelope") == 0) return 0x101;
if (strcmp(media, "Letterhead") == 0) return 0x103;
if (strcmp(media, "ThickStock") == 0) return 0x105;
if (strcmp(media, "Labels") == 0) return 0x107;
if (strcmp(media, "Postcard") == 0) return 0x106;
}
return DMMEDIA_STANDARD;
}
static int
map_source_code(unsigned media_position)
{
switch (media_position)
{
case 1: return DMBIN_UPPER;
case 2: return DMBIN_LOWER;
case 4: return DMBIN_MANUAL;
default: return DMBIN_AUTO;
}
}
/* ---------- CUPS options parsing ---------- */
static void
parse_options(const char *options, int *density, int *economode, int *model)
{
cups_option_t *opts = NULL;
int num_opts;
const char *val;
if (!options || !options[0])
return;
num_opts = cupsParseOptions(options, 0, &opts);
val = cupsGetOption("Density", num_opts, opts);
if (val)
{
int d = atoi(val);
if (d >= 1 && d <= 5)
*density = d;
}
val = cupsGetOption("Quality", num_opts, opts);
if (val && strcmp(val, "draft") == 0)
*economode = 1;
val = cupsGetOption("EconoMode", num_opts, opts);
if (val && strcmp(val, "on") == 0)
*economode = 1;
val = cupsGetOption("Model", num_opts, opts);
if (val)
{
int m = atoi(val);
if (m >= 0 && m <= 3)
*model = m;
}
cupsFreeOptions(num_opts, opts);
}
/* ---------- Signal handling ---------- */
static volatile int Canceled = 0;
static void
cancel_handler(int sig)
{
(void)sig;
Canceled = 1;
}
/* ---------- Main ---------- */
int
main(int argc, char *argv[])
{
cups_raster_t *ras;
cups_page_header2_t header;
int fd;
int page = 0;
int density = 3;
int economode = 0;
int model = MODEL_HP1020;
if (argc < 6 || argc > 7)
{
fprintf(stderr, "Usage: %s job user title copies options [file]\n",
argv[0]);
return 1;
}
signal(SIGTERM, cancel_handler);
signal(SIGPIPE, SIG_IGN);
parse_options(argv[5], &density, &economode, &model);
if (argc == 7)
{
fd = open(argv[6], O_RDONLY);
if (fd < 0)
{
fprintf(stderr, "ERROR: rastertozjs: cannot open %s\n", argv[6]);
return 1;
}
}
else
{
fd = 0;
}
ras = cupsRasterOpen(fd, CUPS_RASTER_READ);
if (!ras)
{
fprintf(stderr, "ERROR: rastertozjs: cannot open raster stream\n");
if (fd != 0) close(fd);
return 1;
}
start_doc(stdout, model, density, economode);
while (!Canceled && cupsRasterReadHeader2(ras, &header))
{
unsigned int cupsW, cupsH, cupsBpl;
int resX, resY, bpp;
int jbigW, realWidth;
int bpl, bpl16;
unsigned char *buf;
unsigned char *bitmaps[1];
struct jbg_enc_state se;
BIE_CHAIN *chain = NULL;
int paperCode, mediaCode, sourceCode;
unsigned int y;
int invert;
int copies;
page++;
cupsW = header.cupsWidth;
cupsH = header.cupsHeight;
cupsBpl = header.cupsBytesPerLine;
resX = header.HWResolution[0];
resY = header.HWResolution[1];
copies = header.NumCopies > 0 ? header.NumCopies : 1;
fprintf(stderr, "DEBUG: rastertozjs: page %d, %ux%u pixels, %dx%d dpi, model %d\n",
page, cupsW, cupsH, resX, resY, model);
if (header.cupsBitsPerPixel != 1)
{
fprintf(stderr, "ERROR: rastertozjs: expected 1bpp, got %d\n",
header.cupsBitsPerPixel);
break;
}
invert = (header.cupsColorSpace == CUPS_CSPACE_W);
bpp = resX / 600;
if (bpp < 1) bpp = 1;
paperCode = map_paper_code(header.cupsPageSizeName);
mediaCode = map_media_code(header.MediaType, model);
sourceCode = map_source_code(header.MediaPosition);
realWidth = cupsW;
jbigW = (cupsW + 127) & ~127;
bpl = (jbigW + 7) / 8;
bpl16 = (bpl + 15) & ~15;
buf = calloc(bpl16, cupsH);
if (!buf)
{
fprintf(stderr, "ERROR: rastertozjs: cannot allocate page buffer\n");
break;
}
for (y = 0; y < cupsH && !Canceled; y++)
{
unsigned int n = cupsRasterReadPixels(ras,
buf + (size_t)y * bpl16,
cupsBpl);
if (n == 0) break;
if (invert)
{
unsigned int i;
unsigned char *row = buf + (size_t)y * bpl16;
for (i = 0; i < cupsBpl; i++)
row[i] ^= 0xFF;
}
}
if (Canceled)
{
free(buf);
break;
}
*bitmaps = buf;
jbg_enc_init(&se, jbigW, cupsH, 1, bitmaps, output_jbig, &chain);
jbg_enc_options(&se, JbgOptions[0], JbgOptions[1],
JbgOptions[2], JbgOptions[3], JbgOptions[4]);
jbg_enc_out(&se);
jbg_enc_free(&se);
start_page(stdout, model, 600, resY, bpp,
jbigW, cupsH, realWidth,
paperCode, mediaCode, sourceCode,
copies, economode);
write_plane(4, &chain, stdout, model); /* plane 4 = K for mono */
end_page(stdout, model);
free(buf);
fprintf(stderr, "PAGE: %d %d\n", page, copies);
}
end_doc(stdout, model);
cupsRasterClose(ras);
if (fd != 0) close(fd);
return Canceled ? 1 : 0;
}