| 1 | /* |
| 2 | * Convert BJC-printjobs to xbm files, one for each color channel |
| 3 | * |
| 4 | * Copyright 2001 Andy Thaller <[email protected]> |
| 5 | * |
| 6 | * This program is free software; you can redistribute it and/or modify it |
| 7 | * under the terms of the GNU General Public License as published by the Free |
| 8 | * Software Foundation; either version 2 of the License, or (at your option) |
| 9 | * any later version. |
| 10 | * |
| 11 | * This program is distributed in the hope that it will be useful, but |
| 12 | * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY |
| 13 | * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
| 14 | * for more details. |
| 15 | * |
| 16 | * You should have received a copy of the GNU General Public License |
| 17 | * along with this program. If not, see <https://www.gnu.org/licenses/>. |
| 18 | */ |
| 19 | |
| 20 | |
| 21 | #ifdef HAVE_CONFIG_H |
| 22 | #include <config.h> |
| 23 | #endif |
| 24 | #include <gutenprint/util.h> |
| 25 | #include <stdio.h> |
| 26 | #include <string.h> |
| 27 | #include <unistd.h> |
| 28 | |
| 29 | char *efnlc= 0,*efnlm= 0,*efnc= 0,*efnm= 0,*efny= 0,*efnk= 0; |
| 30 | |
| 31 | int lc_cnt= 0,lm_cnt= 0,ly_cnt= 0,c_cnt= 0,m_cnt= 0,y_cnt= 0,k_cnt= 0; |
| 32 | |
| 33 | FILE *outfilelc= 0; |
| 34 | FILE *outfilelm= 0; |
| 35 | FILE *outfilely= 0; |
| 36 | FILE *outfilec= 0; |
| 37 | FILE *outfilem= 0; |
| 38 | FILE *outfiley= 0; |
| 39 | FILE *outfilek= 0; |
| 40 | |
| 41 | int xsize,ysize,pixcnt; |
| 42 | |
| 43 | typedef struct scanline_t_ { |
| 44 | int size; |
| 45 | int osize; |
| 46 | unsigned char *buf; |
| 47 | int xmin; |
| 48 | int xmax; |
| 49 | int width; |
| 50 | int y; |
| 51 | struct scanline_t_ *next; |
| 52 | } scanline_t; |
| 53 | |
| 54 | typedef struct bitimage_t_ { |
| 55 | unsigned char *buf; |
| 56 | int y0; |
| 57 | int width; |
| 58 | int height; |
| 59 | int xmin; |
| 60 | int xmax; |
| 61 | } bitimage_t; |
| 62 | |
| 63 | typedef struct level_t_ { |
| 64 | /* Max number of bits per ink so far known is 8 |
| 65 | Thus max number of levels is 256 (including value 0) |
| 66 | */ |
| 67 | int levelvals[256]; /* number of occurrences of each level */ |
| 68 | int numlevels; /* number of actual levels used */ |
| 69 | int maxlevel; /* maximum value */ |
| 70 | int numbits; /* deduced number bits used for numlevels */ |
| 71 | } level_t; |
| 72 | |
| 73 | bitimage_t *bitimage_new (void); |
| 74 | int last_bit (unsigned char i); |
| 75 | int first_bit (unsigned char i); |
| 76 | void rle_info (const unsigned char *inbuf, int n, int *first, int *last, |
| 77 | int *width, int *length); |
| 78 | int rle_decode (unsigned char *inbuf, int n, unsigned char *outbuf, int max, level_t *levels); |
| 79 | scanline_t* scanline_new (void); |
| 80 | level_t* level_new (void); |
| 81 | int calc_bits(int numlevels); |
| 82 | scanline_t *scanline_store (scanline_t *line, int y, unsigned char *buf, |
| 83 | int size); |
| 84 | bitimage_t *scanlines2bitimage (scanline_t *slimg, level_t *levels); |
| 85 | char conv (char i); |
| 86 | void save2xbm (const char *filename,char col, bitimage_t *img, |
| 87 | int xmin, int ymin, int xmax, int ymax); |
| 88 | int nextcmd (FILE *infile, unsigned char *inbuff, unsigned int *cnt); |
| 89 | int process(FILE *infile, scanline_t *sf[7], int *xmin_, int *xmax_, |
| 90 | int *ymin_, int *ymax_, level_t *lv[7]); |
| 91 | |
| 92 | |
| 93 | bitimage_t *bitimage_new(void) |
| 94 | { |
| 95 | bitimage_t *tmp= (bitimage_t*) stp_malloc (sizeof(bitimage_t)); |
| 96 | tmp->buf= 0; |
| 97 | tmp->y0= 0; |
| 98 | tmp->width= 0; |
| 99 | tmp->height= 0; |
| 100 | tmp->xmin= 0; |
| 101 | tmp->xmax= 0; |
| 102 | return tmp; |
| 103 | } |
| 104 | |
| 105 | int last_bit(unsigned char i) { |
| 106 | if (i & 0x1) return 0; |
| 107 | if (i & 0x2) return 1; |
| 108 | if (i & 0x4) return 2; |
| 109 | if (i & 0x8) return 3; |
| 110 | if (i & 0x10) return 4; |
| 111 | if (i & 0x20) return 5; |
| 112 | if (i & 0x40) return 6; |
| 113 | if (i & 0x80) return 7; |
| 114 | return 0; |
| 115 | } |
| 116 | |
| 117 | int first_bit(unsigned char i) { |
| 118 | if (i & 0x80) return 7; |
| 119 | if (i & 0x40) return 6; |
| 120 | if (i & 0x20) return 5; |
| 121 | if (i & 0x10) return 4; |
| 122 | if (i & 0x8) return 3; |
| 123 | if (i & 0x4) return 2; |
| 124 | if (i & 0x2) return 1; |
| 125 | if (i & 0x1) return 0; |
| 126 | return 0; |
| 127 | } |
| 128 | |
| 129 | void rle_info(const unsigned char *inbuf, int n, int *first, int *last, int *width, int *length) |
| 130 | { |
| 131 | const char *ib= (const char *)inbuf; |
| 132 | char cnt; |
| 133 | int o= 0; |
| 134 | int i=0,j,num,f=-1,l=0; |
| 135 | |
| 136 | *first= 0; |
| 137 | *last= 0; |
| 138 | *width= 0; |
| 139 | |
| 140 | if (n<=0) return; |
| 141 | while (i<n) { |
| 142 | cnt= ib[i]; |
| 143 | if (cnt<0) { |
| 144 | num= 1-cnt; |
| 145 | if (inbuf[i+1]) { |
| 146 | if (f<0) f=o*8 + first_bit(inbuf[i+1]); |
| 147 | l= o*8 + last_bit(inbuf[i+1]); |
| 148 | } |
| 149 | o+= num; |
| 150 | i+= 2; |
| 151 | } else { |
| 152 | num= cnt+1; |
| 153 | for (j=0; j<num; j++) { |
| 154 | if (inbuf[i+j+1]) { |
| 155 | if (f<0) f=(o+j)*8 + first_bit(inbuf[i+j+1]); |
| 156 | l= o*8 + last_bit(inbuf[i+j+1]); |
| 157 | } |
| 158 | } |
| 159 | o+= num; |
| 160 | i+= num+1; |
| 161 | } |
| 162 | } |
| 163 | |
| 164 | if (first) *first= f; |
| 165 | if (last) *last= l; |
| 166 | if (length) *length= o; |
| 167 | if (width) *width= (f<0) ? 0 : l-f+1; |
| 168 | } |
| 169 | |
| 170 | /* n is the size of the scanline */ |
| 171 | int rle_decode(unsigned char *inbuf, int n, unsigned char *outbuf,int max, level_t *levels) |
| 172 | { |
| 173 | const char *ib= (const char *)inbuf; /* input scanline */ |
| 174 | char cnt; |
| 175 | int o= 0; |
| 176 | int i=0,j,num; |
| 177 | |
| 178 | (void)max; |
| 179 | |
| 180 | /* Results of the decoding are in the output buffer already. |
| 181 | We want to organize the decoded numbers to see |
| 182 | the total number of levels, and their values. |
| 183 | */ |
| 184 | /*fprintf(stderr,"rle_decode: decoding scanline\n");*/ |
| 185 | if (n<=0) return 0; |
| 186 | while (i<n) { |
| 187 | cnt= ib[i]; |
| 188 | if (cnt<0) { |
| 189 | num= 1-cnt; |
| 190 | /*for (j=0; j<num; j++) outbuf[o+j]=inbuf[i+1];*/ |
| 191 | for (j=0; j<num; j++) { |
| 192 | outbuf[o+j]=inbuf[i+1]; |
| 193 | /*fprintf(stderr," %d ",outbuf[o+j]);*/ |
| 194 | levels->levelvals[outbuf[o+j]] += 1; |
| 195 | if ( outbuf[o+j] > levels->maxlevel ) levels->maxlevel = outbuf[o+j]; |
| 196 | } |
| 197 | o+= num; |
| 198 | i+= 2; |
| 199 | } else { |
| 200 | num= cnt+1; |
| 201 | /* for (j=0; j<num; j++) outbuf[o+j]=inbuf[i+j+1]; */ |
| 202 | for (j=0; j<num; j++) { |
| 203 | outbuf[o+j]=inbuf[i+j+1]; |
| 204 | /*fprintf(stderr," %d ",outbuf[o+j]);*/ |
| 205 | levels->levelvals[outbuf[o+j]] += 1; |
| 206 | if ( outbuf[o+j] > levels->maxlevel ) levels->maxlevel = outbuf[o+j]; |
| 207 | } |
| 208 | o+= num; |
| 209 | i+= num+1; |
| 210 | } |
| 211 | } |
| 212 | /*fprintf(stderr,"\n");*/ |
| 213 | return o; |
| 214 | } |
| 215 | |
| 216 | scanline_t* scanline_new(void) |
| 217 | { |
| 218 | scanline_t* tmp= (scanline_t*) stp_malloc (sizeof(scanline_t)); |
| 219 | tmp->size= 0; |
| 220 | tmp->osize= 0; |
| 221 | tmp->buf= 0; |
| 222 | tmp->xmin= 0; |
| 223 | tmp->xmax= 0; |
| 224 | tmp->width= 0; |
| 225 | tmp->y= 0; |
| 226 | tmp->next= 0; |
| 227 | return tmp; |
| 228 | } |
| 229 | |
| 230 | level_t *level_new(void) |
| 231 | { |
| 232 | int i; |
| 233 | level_t* tmp = (level_t*) stp_malloc (sizeof(level_t)); |
| 234 | tmp->numlevels=0; |
| 235 | tmp->maxlevel=0; |
| 236 | tmp->numbits=0; |
| 237 | for (i=0; i<256; i++) tmp->levelvals[i]=0; |
| 238 | return tmp; |
| 239 | } |
| 240 | |
| 241 | int calc_bits(int numlevels) { |
| 242 | if (numlevels > 128) return 8; |
| 243 | else if (numlevels > 64) return 7; |
| 244 | else if (numlevels > 32) return 6; |
| 245 | else if (numlevels > 16) return 5; |
| 246 | else if (numlevels > 8) return 4; |
| 247 | else if (numlevels > 4) return 3; |
| 248 | else if (numlevels > 2) return 2; |
| 249 | else if (numlevels > 1) return 1; |
| 250 | else return 0; |
| 251 | } |
| 252 | |
| 253 | scanline_t *scanline_store(scanline_t *line, int y, unsigned char *buf, int size) { |
| 254 | if (!line && !(line= scanline_new())) |
| 255 | return 0; |
| 256 | line->size= size; /* from cnt in nextcmd function */ |
| 257 | line->buf= (unsigned char *) stp_malloc (size); |
| 258 | memcpy(line->buf,buf,size); |
| 259 | rle_info(buf,size,&line->xmin,&line->xmax,&line->width,&line->osize); |
| 260 | /*fprintf(stderr,"Scanline size %d, xmin %d, xmax %d, width %d\n",size,line->xmin,line->xmax,line->width);*/ |
| 261 | line->y= y; |
| 262 | return line; |
| 263 | } |
| 264 | |
| 265 | bitimage_t *scanlines2bitimage(scanline_t *slimg, level_t *level) |
| 266 | { |
| 267 | bitimage_t *img= 0; |
| 268 | scanline_t *sl; |
| 269 | int w= 0; |
| 270 | int y0= -1; |
| 271 | int y= 0; |
| 272 | int h,i; |
| 273 | |
| 274 | for (sl=slimg; sl!=0; sl=sl->next) { |
| 275 | if (sl->width) { |
| 276 | if (w<sl->osize) w= sl->osize; |
| 277 | if (y0<0) y0= sl->y; |
| 278 | y= sl->y; |
| 279 | } |
| 280 | } |
| 281 | h= y-y0+1; |
| 282 | |
| 283 | if ((!w) || (!h)) |
| 284 | return 0; |
| 285 | |
| 286 | img= bitimage_new(); |
| 287 | |
| 288 | img->buf= (unsigned char*) stp_malloc(h*w); |
| 289 | memset(img->buf,0,h*w); |
| 290 | img->width= w; |
| 291 | img->height= h; |
| 292 | img->y0= y0; |
| 293 | |
| 294 | for (sl=slimg; sl!=0; sl=sl->next) { |
| 295 | y= sl->y- y0; |
| 296 | if ((y>=0) && (y<h)) { |
| 297 | rle_decode(sl->buf,sl->size,img->buf+y*w,w,level); |
| 298 | } |
| 299 | } |
| 300 | |
| 301 | /* print out stats of levels */ |
| 302 | for (i=0;i<256;i++) { |
| 303 | fprintf(stderr,"level %d: %d\n",i,level->levelvals[i]); |
| 304 | if (level->levelvals[i] > 0) level->numlevels += 1; |
| 305 | } |
| 306 | fprintf(stderr,"numlevels: %d\n",level->numlevels); |
| 307 | fprintf(stderr,"maxlevel: %d\n",level->maxlevel); |
| 308 | level->numbits = calc_bits(level->maxlevel); |
| 309 | fprintf(stderr,"numbits: %d\n",level->numbits); |
| 310 | |
| 311 | return img; |
| 312 | } |
| 313 | |
| 314 | char conv(char i) { |
| 315 | char o= 0; |
| 316 | if (i & 0x80) o|=0x01; |
| 317 | if (i & 0x40) o|=0x02; |
| 318 | if (i & 0x20) o|=0x04; |
| 319 | if (i & 0x10) o|=0x08; |
| 320 | if (i & 0x08) o|=0x10; |
| 321 | if (i & 0x04) o|=0x20; |
| 322 | if (i & 0x02) o|=0x40; |
| 323 | if (i & 0x01) o|=0x80; |
| 324 | return o; |
| 325 | } |
| 326 | |
| 327 | void save2xbm(const char *filename,char col, bitimage_t *img, |
| 328 | int xmin, int ymin, int xmax, int ymax) |
| 329 | { |
| 330 | char *outfilename= (char*) stp_malloc(strlen(filename)+16); |
| 331 | FILE *o; |
| 332 | int i,j,k,i0,i1,j0,j1,w,h; |
| 333 | |
| 334 | if (!img) return; |
| 335 | |
| 336 | if (col) |
| 337 | sprintf(outfilename,"%s_%c.xbm",filename,col); |
| 338 | else |
| 339 | sprintf(outfilename,"%s.xbm",filename); |
| 340 | |
| 341 | if (!(o= fopen(outfilename,"w"))) { |
| 342 | stp_free(outfilename); |
| 343 | return; |
| 344 | } |
| 345 | |
| 346 | i0= (ymin>0) ? ymin-img->y0 : 0; |
| 347 | i1= (ymax>0) ? ymax-img->y0 : img->height; |
| 348 | j0= (xmin>0 && xmin<img->width*8) ? xmin/8 : 0; |
| 349 | j1= (xmax>0 && xmax<img->width*8) ? xmax/8 : img->width-1; |
| 350 | |
| 351 | w= j1-j0+1; |
| 352 | h= i1-i0; |
| 353 | |
| 354 | if (col) |
| 355 | fprintf(o,"#define %s_%c_width %d\n#define %s_%c_height %d\nstatic char %s_%c_bits[] = {", |
| 356 | outfilename,col,w*8, |
| 357 | outfilename,col,h, |
| 358 | outfilename,col); |
| 359 | else |
| 360 | fprintf(o,"#define %s_width %d\n#define %s_height %d\nstatic char %s_bits[] = {", |
| 361 | outfilename,w*8, |
| 362 | outfilename,h, |
| 363 | outfilename); |
| 364 | |
| 365 | fprintf(stderr,"%d %d %d %d\n",i0,h,j0,w); |
| 366 | for (i=i0,k=0; i<i1; i++) { |
| 367 | for (j=j0; j<=j1; j++) { |
| 368 | if (k%16 == 0) fprintf(o,"\n"); |
| 369 | fprintf(o,"0x%02x, ",(i>=0 && i<img->height)? conv(img->buf[i*img->width+j])&0xff : 0); |
| 370 | k++; |
| 371 | } |
| 372 | } |
| 373 | |
| 374 | fprintf(o," 0x00 };\n"); |
| 375 | |
| 376 | fclose(o); |
| 377 | } |
| 378 | |
| 379 | int nextcmd(FILE *infile,unsigned char *inbuff,unsigned int *cnt) |
| 380 | { |
| 381 | unsigned char c1=0,c2=0; |
| 382 | int c; |
| 383 | int cmd; |
| 384 | |
| 385 | while (!feof(infile) && c1!=0x1b && (c2!=0x28 && c2!=0x5b)) { |
| 386 | c1=c2; c2=fgetc(infile); |
| 387 | } |
| 388 | if (feof(infile)) return 0; |
| 389 | |
| 390 | cmd=fgetc(infile); |
| 391 | if (feof(infile)) return 0; |
| 392 | |
| 393 | c1= fgetc(infile); |
| 394 | if (feof(infile)) return 0; |
| 395 | c2= fgetc(infile); |
| 396 | if (feof(infile)) return 0; |
| 397 | |
| 398 | /* 2 bytes: seems to be the size+1 of one scanline in cases where command is a scanline */ |
| 399 | *cnt= c1+256*c2; |
| 400 | |
| 401 | if ((c=fread(inbuff,1,*cnt,infile) != *cnt)) { |
| 402 | fprintf(stderr,"read error for 0x%02x - not enough data (%d/%d)!\n",cmd, |
| 403 | c,*cnt); |
| 404 | return 0; |
| 405 | } |
| 406 | |
| 407 | return cmd; |
| 408 | } |
| 409 | |
| 410 | int process(FILE *infile,scanline_t *sf[7],int *xmin_,int *xmax_,int *ymin_,int *ymax_,level_t *lv[7]) |
| 411 | { |
| 412 | unsigned char inbuff[65540]; |
| 413 | scanline_t *sl[7], *nsl; |
| 414 | |
| 415 | int xres,yres; |
| 416 | int xmin=1000000,xmax=0,ymin=-1,ymax=0,width=0; |
| 417 | int col=0; |
| 418 | int line=0; |
| 419 | int i; |
| 420 | unsigned int cnt; |
| 421 | int cmd; |
| 422 | |
| 423 | for (i=0; i<7; i++) sf[i]= sl[i]= 0; |
| 424 | |
| 425 | for (i=0; i<7; i++) lv[i] = level_new(); |
| 426 | |
| 427 | if (!infile) return 0; |
| 428 | fseek(infile,0,SEEK_SET); |
| 429 | |
| 430 | while ((cmd= nextcmd(infile,inbuff,&cnt))) { |
| 431 | switch(cmd) { |
| 432 | case 0x64: |
| 433 | yres=inbuff[0]*256+inbuff[1]; |
| 434 | xres=inbuff[2]*256+inbuff[3]; |
| 435 | fprintf(stderr,"res=%dx%ddpi\n",xres,yres); |
| 436 | break; |
| 437 | case 0x65: |
| 438 | line+=(inbuff[0]*256+inbuff[1]); |
| 439 | break; |
| 440 | case 0x41: |
| 441 | switch(inbuff[0]) { |
| 442 | case 0x4b: col= 0; break; /* black */ |
| 443 | case 0x59: col= 1; break; /* yellow */ |
| 444 | case 0x4d: col= 2; break; /* magenta */ |
| 445 | case 0x43: col= 3; break; /* cyan */ |
| 446 | case 0x79: col= 4; break; /* lightyellow */ |
| 447 | case 0x6d: col= 5; break; /* lightmagenta */ |
| 448 | case 0x63: col= 6; break; /* lightcyan */ |
| 449 | default: |
| 450 | fprintf(stderr,"unknown color component 0x%02x\n",inbuff[0]); |
| 451 | exit(-1); |
| 452 | } |
| 453 | |
| 454 | nsl= scanline_store(0,line,inbuff+1,cnt-1); |
| 455 | |
| 456 | if (nsl) { |
| 457 | if (nsl->width) { |
| 458 | if (ymin<0) ymin=line; |
| 459 | ymax=line; |
| 460 | if (nsl->xmin<xmin) xmin=nsl->xmin; |
| 461 | if (nsl->xmax>xmax) xmax=nsl->xmax; |
| 462 | if (nsl->width>width) width=nsl->width; |
| 463 | if (!sf[col]) |
| 464 | sf[col]=nsl; |
| 465 | else |
| 466 | sl[col]->next= nsl; |
| 467 | sl[col]= nsl; |
| 468 | } else { |
| 469 | stp_free (nsl); |
| 470 | nsl= 0; |
| 471 | } |
| 472 | |
| 473 | if (fgetc(infile)!=0x0d) { |
| 474 | fprintf(stderr,"COLOR LINE NOT TERMINATED BY 0x0d @ %lx!!\n", |
| 475 | ftell(infile)); |
| 476 | } |
| 477 | } |
| 478 | break; |
| 479 | case 0x62: |
| 480 | break; |
| 481 | default: |
| 482 | ; |
| 483 | } |
| 484 | } |
| 485 | |
| 486 | fprintf(stderr,"size=%d..%d:%d..%d = %dx%d\n",xmin,xmax,ymin,ymax,width,ymax-ymin+1); |
| 487 | |
| 488 | *xmin_= xmin; |
| 489 | *xmax_= xmax; |
| 490 | *ymin_= ymin; |
| 491 | *ymax_= ymax; |
| 492 | |
| 493 | return 1; |
| 494 | } |
| 495 | |
| 496 | /* |
| 497 | const char *fbin(char b) { |
| 498 | static char bf[9]; |
| 499 | |
| 500 | bf[0]= (b & 0x80) ? '1' : '0'; |
| 501 | bf[1]= (b & 0x40) ? '1' : '0'; |
| 502 | bf[2]= (b & 0x20) ? '1' : '0'; |
| 503 | bf[3]= (b & 0x10) ? '1' : '0'; |
| 504 | bf[4]= (b & 0x08) ? '1' : '0'; |
| 505 | bf[5]= (b & 0x04) ? '1' : '0'; |
| 506 | bf[6]= (b & 0x02) ? '1' : '0'; |
| 507 | bf[7]= (b & 0x01) ? '1' : '0'; |
| 508 | bf[8]=0; |
| 509 | return bf; |
| 510 | } |
| 511 | */ |
| 512 | |
| 513 | int main(int argc, char **argv) |
| 514 | { |
| 515 | char *infilename= 0, *outfilename=0; |
| 516 | FILE *infile= 0; |
| 517 | scanline_t *scanlines[7]; |
| 518 | char colname[7] = { 'K', 'Y', 'M', 'C', 'y', 'm', 'c' }; |
| 519 | level_t *levels[7]; |
| 520 | int xmin,xmax; |
| 521 | int ymin,ymax; |
| 522 | |
| 523 | if (argc>1) { |
| 524 | if (argc>2) |
| 525 | outfilename= argv[2]; |
| 526 | else |
| 527 | outfilename= argv[1]; |
| 528 | |
| 529 | infilename= argv[1]; |
| 530 | infile= fopen(infilename,"r"); |
| 531 | |
| 532 | xsize=ysize=0; |
| 533 | |
| 534 | process(infile,scanlines,&xmin,&xmax,&ymin,&ymax,levels); |
| 535 | |
| 536 | fprintf(stderr,"Color %c\n",colname[0]); |
| 537 | save2xbm(outfilename,colname[0],scanlines2bitimage(scanlines[0],levels[0]),xmin,ymin,xmax,ymax); |
| 538 | fprintf(stderr,"Color %c\n",colname[1]); |
| 539 | save2xbm(outfilename,colname[1],scanlines2bitimage(scanlines[1],levels[1]),xmin,ymin,xmax,ymax); |
| 540 | fprintf(stderr,"Color %c\n",colname[2]); |
| 541 | save2xbm(outfilename,colname[2],scanlines2bitimage(scanlines[2],levels[2]),xmin,ymin,xmax,ymax); |
| 542 | fprintf(stderr,"Color %c\n",colname[3]); |
| 543 | save2xbm(outfilename,colname[3],scanlines2bitimage(scanlines[3],levels[3]),xmin,ymin,xmax,ymax); |
| 544 | fprintf(stderr,"Color %c\n",colname[4]); |
| 545 | save2xbm(outfilename,colname[4],scanlines2bitimage(scanlines[4],levels[4]),xmin,ymin,xmax,ymax); |
| 546 | fprintf(stderr,"Color %c\n",colname[5]); |
| 547 | save2xbm(outfilename,colname[5],scanlines2bitimage(scanlines[5],levels[5]),xmin,ymin,xmax,ymax); |
| 548 | fprintf(stderr,"Color %c\n",colname[6]); |
| 549 | save2xbm(outfilename,colname[6],scanlines2bitimage(scanlines[6],levels[6]),xmin,ymin,xmax,ymax); |
| 550 | |
| 551 | } else { |
| 552 | fprintf(stderr,"\nusage: bjc-unprint INFILE [OUTFILE]\n\n"); |
| 553 | } |
| 554 | |
| 555 | return 0; |
| 556 | } |