Utah Raster Toolkit  9999-git
URT Development version (post-3.1b)
map_scan.c
Go to the documentation of this file.
1 /*
2  * This software is copyrighted as noted below. It may be freely copied,
3  * modified, and redistributed, provided that the copyright notices are
4  * preserved on all copies.
5  *
6  * There is no warranty or other guarantee of fitness for this software,
7  * it is provided solely "as is". Bug reports or fixes may be sent
8  * to the author, who may or may not act on them as he desires.
9  *
10  * You may not include this software in a program or other software product
11  * without supplying the source, or without informing the end-user that the
12  * source is available for no extra charge.
13  *
14  * If you modify this software, you should include a notice giving the
15  * name of the person performing the modification, the date of modification,
16  * and the reason for such modification.
17  */
18 
19 /*
20  * map_scan.c - Put RLE images on X display.
21  *
22  * Author: Spencer W. Thomas (x10)
23  * Computer Science Dept.
24  * University of Utah
25  * Date: Thu Feb 20 1986
26  * Copyright (c) 1986, University of Utah
27  *
28  * Modified: Andrew F. Vesper (x 11)
29  * High Performance Workstations
30  * Digital Equipment Corp
31  * Date: Fri, Aug 7, 1987
32  * Thu, Jan 14, 1988
33  * Copyright (c) 1987,1988, Digital Equipment Corporation
34  *
35  * Modified: Martin R. Friedmann (better X11, flipbook, MAG, info)
36  * Dept of Electrical Engineering and Computer Science
37  * University of Michigan
38  * Date: Tue, Nov 14, 1989
39  * Copyright (c) 1989, University of Michigan
40  */
41 
42 #include "getx11.h"
43 
44 static void map_scanline_generic();
45 static void map_1_dither_notable_1();
46 static void map_1_dither_table_8();
47 static void map_1_nodither_table_8();
48 static void map_2or3_dither_table_8();
49 static void map_1_nodither_notable_32();
50 static void map_2or3_nodither_table_8();
51 static void map_2or3_dither_notable_32();
52 static void map_2or3_nodither_notable_32();
53 static void map_1_mono_color_8();
54 static void map_1_mono_color_32();
55 static void MAG_scanline_generic();
56 static void MAG_1_dither_notable_1();
57 static void MAG_1_dither_table_8();
58 static void MAG_1_nodither_table_8();
59 static void MAG_1_nodither_notable_32();
60 static void MAG_2or3_dither_table_8();
61 static void MAG_2or3_nodither_table_8();
62 static void MAG_2or3_dither_notable_32();
63 static void MAG_2or3_nodither_notable_32();
64 static void MAG_1_mono_color_8();
65 static void MAG_1_mono_color_32();
66 
67 static unsigned char LSBMask[9] = { 0x0, 0x1, 0x3, 0x7,
68  0xf, 0x1f, 0x3f, 0x7f, 0xff };
69 #if 0 /* Not actually used. */
70 static unsigned char MSBMask[9] = { 0x00, 0x80, 0xc0, 0xe0,
71  0xf0, 0xf8, 0xfc, 0xfe, 0xff };
72 #endif
73 
74 /*
75  * Figure out which scan line routine to use.
76  */
78 image_information *img;
79 {
80  register int i;
81  register Boolean table_present;
82  static struct {
83  Boolean one_color;
84  Boolean dither;
85  Boolean table_present;
86  int bpp;
87  void (*routine)();
88  void (*mag_routine)();
89  } map_scanline_table[] =
90  {
91 
92  /* 1 color, dithr, Table, b/p, routine ptr */
93 
94  { True, True, False, 1, map_1_dither_notable_1, MAG_1_dither_notable_1},
95  { True, True, True, 8, map_1_dither_table_8, MAG_1_dither_table_8},
96  { True, False,True, 8, map_1_nodither_table_8, MAG_1_nodither_table_8},
97  { True, False,False,32,map_1_nodither_notable_32, MAG_1_nodither_notable_32},
98  { False,True, True, 8, map_2or3_dither_table_8, MAG_2or3_dither_table_8},
99  { False,False,True, 8, map_2or3_nodither_table_8, MAG_2or3_nodither_table_8},
100  { False,True, False,32,map_2or3_dither_notable_32,MAG_2or3_dither_notable_32},
101  { False,False,False,32,map_2or3_nodither_notable_32,MAG_2or3_nodither_notable_32}};
102 
103  img->map_scanline = map_scanline_generic;
104  img->MAG_scanline = MAG_scanline_generic;
105 
106  if (img->pixel_table == NULL)
107  table_present = False;
108  else table_present = True;
109 
110  if (img->mono_color)
111  switch (img->image->bits_per_pixel) {
112  case 32:
113  img->map_scanline = map_1_mono_color_32;
114  img->MAG_scanline = MAG_1_mono_color_32;
115  break;
116  case 8:
117  img->map_scanline = map_1_mono_color_8;
118  img->MAG_scanline = MAG_1_mono_color_8;
119  break;
120  default:
121  fprintf(stderr, "%s: Warning: Bits per pixel = %d\n",
122  progname, img->image->bits_per_pixel);
123  }
124  else
125  for (i = 0; i < COUNT_OF (map_scanline_table); i++) {
126  if (map_scanline_table[i].one_color == img->mono_img &&
127  map_scanline_table[i].dither == img->dither_img &&
128  map_scanline_table[i].table_present == table_present &&
129  map_scanline_table[i].bpp == img->image->bits_per_pixel) {
130  img->map_scanline = map_scanline_table[i].routine;
131  img->MAG_scanline = map_scanline_table[i].mag_routine;
132 
133  if ( verbose_flag ) {
134  fprintf ( stderr, "Special map_scanline routine used: map_");
135 
136  if ( img->mono_img )
137  fputs ( "1_", stderr );
138  else fputs ( "2or3_", stderr );
139 
140  if ( !img->dither_img )
141  fputs ( "no", stderr );
142  fputs ( "dither_", stderr );
143 
144  if (! table_present ) fputs ( "no", stderr );
145  fprintf ( stderr, "table_%d (index %d)\n",
146  img->image->bits_per_pixel, i );
147  }
148  break;
149  }
150  }
151 }
152 
153 /*
154  * Map a scanline through the dither matrix.
155  *
156  * Inputs:
157  * rgb: Pointers to buffers containing the red, green,
158  * and blue color rows.
159  * n: Length of row.
160  * s: Skip between pixels in original image.
161  * y: Y position of row (necessary for dither)
162  * line: Pointer to output buffer for dithered color data.
163  */
164 
165 #define DMAP(v,x,y) (divN[v] + (modN[v]>dm16[x][y] ? 1 : 0) )
166 #define NDMAP(v) (divN[v])
167 
168 #define DMAP_SETUP( img )
169  register int *divN = img->divN;
170  register int *modN = img->modN;
171  register array16 *dm16 = img->dm16
172 
173 #define NDMAP_SETUP( img ) register int *divN = img->divN
174 
175 #define IN_CMAP_SETUP( img ) register rle_pixel **in_cmap = img->in_cmap
176 
177 #define LEVELS_SETUP( img )
178  register int levels = img->lvls;
179  register int levels_squared = img->lvls_squared
180 
181 /* Note! This must go at the end of the declarations section. */
182 #define X_CMAP_SETUP( img ) cmap_info cmap_i; cmap_i = img->x_cmap;
183 
184 
185 static void
186 map_scanline_generic (img, rgb, ncolors, given_width, stride, y, image)
187 image_information *img;
188 unsigned char *rgb[3];
189 int ncolors;
190 int given_width;
191 int stride;
192 int y;
193 XImage *image;
194 {
195  register Pixel *pixel_table = img->pixel_table;
196  DMAP_SETUP( img );
197  LEVELS_SETUP( img );
198  register int x;
199  register int col;
200  register int row;
201  register unsigned char *r;
202  register long pixel;
203  register int width = given_width;
204  X_CMAP_SETUP( img );
205 
206  row = y % 16;
207  col = 0;
208  r = rgb[0];
209 
210  if (ncolors == 1) {
211 
212  if ( img->dither_img ) {
213  for (x = 0;
214  --width >= 0;
215  r += stride, col = ((col + 1) & 15), x ++) {
216  pixel = DMAP(*r, col, row);
217  pixel = ((pixel_table != NULL) ? pixel_table[pixel] :
218  SHIFT_MASK_PIXEL( pixel, pixel, pixel ));
219  XPutPixel (image, x, y, pixel);
220  }
221  }
222 
223  else {
224  if (img->mono_color)
225  for (x = 0; --width >= 0;
226  r += stride, x ++) {
227  pixel = pixel_table[*r];
228  XPutPixel (image, x, y, pixel);
229  }
230  else
231  for (x = 0; --width >= 0;
232  r += stride, x ++) {
233  pixel = NDMAP(*r);
234  pixel = ((pixel_table != NULL) ? pixel_table[pixel] :
235  SHIFT_MASK_PIXEL( pixel, pixel, pixel ));
236  XPutPixel (image, x, y, pixel);
237  }
238  }
239 
240 
241  }
242 
243  else {
244  register unsigned char *g;
245  register unsigned char *b;
246 
247  g = b = rgb[1];
248  if (ncolors >= 3) b = rgb[2];
249 
250  if ( img->dither_img ) {
251  for (x = 0; --width >= 0;
252  r += stride, g += stride, b += stride,
253  col = ((col + 1) & 15), x ++ )
254  {
255  if (pixel_table != NULL)
256  pixel = pixel_table
257  [DMAP(*r, col, row) +
258  DMAP(*g, col, row) * levels +
259  DMAP(*b, col, row) * levels_squared];
260 
261  else pixel = SHIFT_MASK_PIXEL(DMAP(*r, col, row),
262  DMAP(*g, col, row),
263  DMAP(*b, col, row));
264 
265  XPutPixel (image, x, y, pixel);
266  }
267 
268  }
269 
270  else {
271 
272  for (x = 0; --width >= 0;
273  r += stride, g += stride, b += stride, x++ ) {
274  if ( pixel_table != NULL) {
275  pixel = pixel_table
276  [NDMAP(*r) +
277  NDMAP(*g) * levels +
278  NDMAP(*b) * levels_squared];
279  }
280  else {
281  pixel = SHIFT_MASK_PIXEL (NDMAP(*r), NDMAP(*g), NDMAP(*b));
282  }
283  XPutPixel (image, x, y, pixel);
284  }
285  }
286  }
287 }
288 
289 static void
290 MAG_scanline_generic( img, rle_x, rle_y, mag_size, x, y, width, height, image )
291 image_information *img;
292 int rle_x, rle_y;
293 int width, height;
294 int mag_size;
295 int x, y;
296 XImage *image;
297 
298 {
299  register Pixel *pixel_table = img->pixel_table;
300  DMAP_SETUP( img );
301  LEVELS_SETUP( img );
302  register int col;
303  register unsigned char *r;
304  int save_x = x;
305  register int mag_x;
306  int mag_y = mag_size;
307  register int w;
308  register int row = (mag_size * rle_y - 1) % 16;
309  int x_mod_16 = (mag_size * rle_x) % 16;
310  unsigned char *rgb_line = SAVED_RLE_ROW( img, rle_y ) + rle_x;
311  int rgb_line_stride = img->w * img->dpy_channels;
312  register unsigned long pixel;
313  X_CMAP_SETUP( img );
314 
315  while (--height >= 0) {
316  x = save_x;
317  w = width;
318  row = (row + 1) % 16;
319  col = x_mod_16;
320  r = rgb_line;
321  mag_x = mag_size;
322 
323  if ( img->dpy_channels == 1 ) {
324 
325  if ( img->dither_img )
326  while (--w >= 0)
327  {
328  pixel = DMAP(*r, col++, row);
329  pixel = ((pixel_table != NULL) ? pixel_table[pixel] :
330  SHIFT_MASK_PIXEL( pixel, pixel, pixel ));
331  XPutPixel (image, x, y, pixel);
332  if ( --mag_x == 0 )
333  {
334  r++;
335  mag_x = mag_size;
336  }
337  col &=15; x++;
338  }
339  else
340  if (img->mono_color)
341  while (--w >= 0)
342  {
343  pixel = pixel_table[*r];
344  XPutPixel (image, x, y, pixel);
345  if ( --mag_x == 0 )
346  {
347  r++;
348  mag_x = mag_size;
349  }
350  x++;
351  }
352  else
353  while (--w >= 0)
354  {
355  pixel = NDMAP(*r);
356  pixel = ((pixel_table != NULL) ? pixel_table[pixel] :
357  SHIFT_MASK_PIXEL( pixel, pixel, pixel ));
358  XPutPixel (image, x, y, pixel);
359  if ( --mag_x == 0 )
360  {
361  r++;
362  mag_x = mag_size;
363  }
364  x++;
365  }
366  }
367 
368  else {
369  register unsigned char *g;
370  register unsigned char *b;
371 
372  g = b = r + img->w;
373  if (img->dpy_channels >= 3) b += img->w;
374 
375  if ( img->dither_img )
376  while (--w >= 0)
377  {
378  if ( pixel_table != NULL)
379  pixel = pixel_table
380  [DMAP(*r, col, row) +
381  DMAP(*g, col, row) * levels +
382  DMAP(*b, col, row) * levels_squared];
383 
384  else pixel =
385  SHIFT_MASK_PIXEL (DMAP(*r, col, row),
386  DMAP(*g, col, row),
387  DMAP(*b, col, row));
388  XPutPixel (image, x++, y, pixel);
389  if ( --mag_x == 0 )
390  {
391  r++, g++, b++;
392  mag_x = mag_size;
393  }
394  col++;
395  col &= 15;
396  }
397  else
398  while (--w >= 0)
399  {
400  if ( pixel_table != NULL)
401  pixel = pixel_table
402  [NDMAP(*r) +
403  NDMAP(*g) * levels +
404  NDMAP(*b) * levels_squared];
405  else pixel = SHIFT_MASK_PIXEL (NDMAP(*r),
406  NDMAP(*g),
407  NDMAP(*b));
408 
409  XPutPixel (image, x++, y, pixel);
410  if ( --mag_x == 0 )
411  {
412  r++, g++, b++;
413  mag_x = mag_size;
414  }
415  }
416  }
417  if ( --mag_y == 0 )
418  {
419  rgb_line += rgb_line_stride;
420  mag_y = mag_size;
421  }
422  y++;
423  }
424 }
425 
426 /*
427  * map_1_dither_table_8
428  *
429  * Inputs:
430  * rgb: Pointers to buffers containing the red, green,
431  * and blue color rows.
432  * n: Length of row.
433  * s: Skip between pixels in original image.
434  * y: Y position of row (necessary for dither)
435  * line: Pointer to output buffer for dithered color data.
436  */
437 
438 static
439 void
440 map_1_dither_table_8(img, rgb, ncolors, given_width, stride, y, image)
441 image_information *img;
442 unsigned char *rgb[3];
443 int ncolors;
444 int given_width;
445 int stride;
446 int y;
447 XImage *image;
448 {
449  register Pixel *pixel_table = img->pixel_table;
450  DMAP_SETUP( img );
451  register int col;
452  register int row;
453  register unsigned char *r;
454  register unsigned char *pixel_ptr;
455  register int width = given_width;
456 
457  row = y % 16;
458  col = 0;
459  r = rgb[0];
460 
461  pixel_ptr = ((unsigned char *) image->data) + y * image->bytes_per_line;
462 
463  while (--width >= 0) {
464  *pixel_ptr++ = pixel_table [ DMAP(*r, col, row) ];
465 
466  r += stride;
467  col = ((col + 1) & 15);
468  }
469 }
470 
471 static
472 void
473 MAG_1_dither_table_8( img, rle_x, rle_y, mag_size, x, y, width, height, image )
474 image_information *img;
475 int rle_x, rle_y;
476 int width, height;
477 int mag_size;
478 int x, y;
479 XImage *image;
480 {
481  register Pixel *pixel_table = img->pixel_table;
482  DMAP_SETUP( img );
483  register int col;
484  register unsigned char *r;
485  register unsigned char *pixel_ptr;
486  register int mag_x;
487  int mag_y = mag_size;
488  register int w;
489  register int row = (mag_size * rle_y - 1) % 16;
490  int x_mod_16 = (mag_size * rle_x) % 16;
491  unsigned char *line_ptr;
492  unsigned char *rgb_line = SAVED_RLE_ROW( img, rle_y ) + rle_x;
493  int rgb_line_stride = img->w * img->dpy_channels;
494 
495  line_ptr = ((unsigned char *) image->data)+(y * image->bytes_per_line) + x;
496 
497  while (--height >= 0) {
498  pixel_ptr = line_ptr;
499  w = width;
500  row = (row + 1) % 16;
501  col = x_mod_16;
502  r = rgb_line;
503  mag_x = mag_size;
504 
505  while (--w >= 0) {
506  *pixel_ptr++ = pixel_table [DMAP(*r, col++, row) ];
507  col &= 15;
508  if ( --mag_x == 0 )
509  {
510  r++;
511  mag_x = mag_size;
512  }
513  }
514  line_ptr += image->bytes_per_line;
515  if ( --mag_y == 0 )
516  {
517  rgb_line += rgb_line_stride;
518  mag_y = mag_size;
519  }
520  }
521 }
522 
523 /*
524  * map_2or3_dither_table_8
525  *
526  * Dither three colors into an eight bit table... This is faster than the
527  * map_scanline_generic routine.
528  *
529  * Inputs:
530  * rgb: Pointers to buffers containing the red, green,
531  * and blue color rows.
532  * n: Length of row.
533  * s: Skip between pixels in original image.
534  * y: Y position of row (necessary for dither)
535  * line: Pointer to output buffer for dithered color data.
536  */
537 
538 static
539 void
540 map_2or3_dither_table_8 (img, rgb, ncolors, given_width, stride, y, image)
541 image_information *img;
542 unsigned char *rgb[3];
543 int ncolors;
544 int given_width;
545 int stride;
546 int y;
547 XImage *image;
548 
549 {
550  register Pixel *pixel_table = img->pixel_table;
551  DMAP_SETUP( img );
552  LEVELS_SETUP( img );
553  register int col;
554  register int row;
555  register unsigned char *r, *g, *b;
556  register unsigned char *pixel_ptr;
557  register int width = given_width;
558 
559  row = y % 16;
560  col = 0;
561  r = rgb[0];
562  g = b = rgb[1];
563  if (ncolors >= 3) b = rgb[2];
564 
565  pixel_ptr = ((unsigned char *) image->data) + y * image->bytes_per_line;
566 
567  while (--width >= 0) {
568  *pixel_ptr++ = pixel_table [DMAP(*r, col, row) +
569  DMAP(*g, col, row) * levels +
570  DMAP(*b, col, row) * levels_squared];
571  r += stride;
572  g += stride;
573  b += stride;
574  col = ((col + 1) & 15);
575  }
576 }
577 static
578 void
579 MAG_2or3_dither_table_8 ( img, rle_x, rle_y, mag_size, x, y, width, height, image)
580 image_information *img;
581 int rle_x, rle_y;
582 int width, height;
583 int mag_size;
584 int x, y;
585 XImage *image;
586 
587 {
588  register Pixel *pixel_table = img->pixel_table;
589  DMAP_SETUP( img );
590  LEVELS_SETUP( img );
591  register int col;
592  register unsigned char *r, *g, *b;
593  register unsigned char *pixel_ptr;
594  register int mag_x;
595  int mag_y = mag_size;
596  register int w;
597  register int row = (mag_size * rle_y - 1) % 16;
598  int x_mod_16 = (mag_size * rle_x) % 16;
599  unsigned char *line_ptr;
600  unsigned char *rgb_line = SAVED_RLE_ROW( img, rle_y ) + rle_x;
601  int rgb_line_stride = img->w * img->dpy_channels;
602 
603  line_ptr = ((unsigned char *) image->data)+(y * image->bytes_per_line) + x;
604 
605  while (--height >= 0) {
606  pixel_ptr = line_ptr;
607  w = width;
608  row = (row + 1) % 16;
609  col = x_mod_16;
610  mag_x = mag_size;
611 
612  r = rgb_line;
613  g = b = r + img->w;
614  if (img->dpy_channels >= 3) b += img->w;
615 
616  while (--w >= 0) {
617  *pixel_ptr++ = pixel_table [DMAP(*r, col, row) +
618  DMAP(*g, col, row) * levels +
619  DMAP(*b, col, row) * levels_squared];
620  col++;
621  col &= 15;
622  if ( --mag_x == 0 )
623  {
624  r++, g++, b++;
625  mag_x = mag_size;
626  }
627  }
628  line_ptr += image->bytes_per_line;
629  if ( --mag_y == 0 )
630  {
631  rgb_line += rgb_line_stride;
632  mag_y = mag_size;
633  }
634  }
635 }
636 
637 /*
638  * map_1_dither_notable_1
639  *
640  * Dither a 1 channel image into a 1 bit image.
641  *
642  * Inputs:
643  * rgb: Pointer to buffer containing gray scale information.
644  * n: Length of row.
645  * s: Skip between pixels in original image.
646  * y: Y position of row (necessary for dither)
647  * line: Pointer to output buffer for dithered color data.
648  */
649 static
650 void
651 map_1_dither_notable_1 (img, rgb, ncolors, given_width, stride, y, image)
652 image_information *img;
653 unsigned char *rgb[3];
654 int ncolors;
655 int given_width;
656 register int stride;
657 int y;
658 XImage *image;
659 
660 {
661  DMAP_SETUP( img );
662  register int col;
663  register int row;
664  register unsigned char *r;
665  register unsigned char *pixel_ptr;
666  register int width = given_width;
667  int bit;
668  row = y % 16;
669  col = bit = 0;
670  r = rgb[0];
671 
672  pixel_ptr = ((unsigned char *) image->data) + y * image->bytes_per_line;
673 
674  if( BitmapBitOrder(dpy) == MSBFirst ) {
675  /* we don't want to trash those good bits */
676  *pixel_ptr >>= (8 - bit) & 7;
677 
678  /* do first byte fragment */
679  while ( col & 7 )
680  {
681  *pixel_ptr <<= 1;
682  if ( DMAP(*r, col++, row) )
683  *pixel_ptr |= (unsigned char) 0x1;
684  width--;
685  r += stride;
686  }
687  if ( bit )
688 
689  pixel_ptr++, col &= 15;
690 
691  while ((width -= 8) >= 0) {
692  *pixel_ptr = 0;
693  if ( DMAP(*r, col++, row) )
694  *pixel_ptr = (unsigned char) 0x80;
695  r += stride;
696  if ( DMAP(*r, col++, row) )
697  *pixel_ptr |= (unsigned char) 0x40;
698  r += stride;
699  if ( DMAP(*r, col++, row) )
700  *pixel_ptr |= (unsigned char) 0x20;
701  r += stride;
702  if ( DMAP(*r, col++, row) )
703  *pixel_ptr |= (unsigned char) 0x10;
704  r += stride;
705  if ( DMAP(*r, col++, row) )
706  *pixel_ptr |= (unsigned char) 0x8;
707  r += stride;
708  if ( DMAP(*r, col++, row) )
709  *pixel_ptr |= (unsigned char) 0x4;
710  r += stride;
711  if ( DMAP(*r, col++, row) )
712  *pixel_ptr |= (unsigned char) 0x2;
713  r += stride;
714  if ( DMAP(*r, col++, row) )
715  *pixel_ptr |= (unsigned char) 0x1;
716  r += stride;
717  col &= 15;
718  pixel_ptr++;
719  }
720 
721  /* if w is non-zero then we have to finish up... */
722  width = 8 + width;
723  if ( width )
724  {
725  unsigned char savebits;
726 
727  savebits = *pixel_ptr & LSBMask[8-width];
728  bit = width;
729 
730  while (--width >= 0) {
731  *pixel_ptr <<= 1;
732  if ( DMAP(*r, col++, row) )
733  *pixel_ptr |= (unsigned char) 0x1;
734  r += stride;
735  }
736  *pixel_ptr <<= 8 - bit;
737  *pixel_ptr |= savebits;
738  }
739  }
740  else
741  while (--width >= 0) {
742  *pixel_ptr = (unsigned char)(*pixel_ptr >> 1) | (unsigned char)
743  ((DMAP(*r, col, row)!= 0) ? 0x80: 0);
744 
745  r += stride;
746  col = ((col + 1) & 15);
747  bit = ((bit + 1) & 7);
748  if (!bit) pixel_ptr++;
749  }
750 }
751 #define INC_RGB( stmt ) if ( --mag_x == 0 ) {stmt; mag_x = mag_size; }
752 static
753 void
754 MAG_1_dither_notable_1 ( img, rle_x, rle_y, mag_size, x, y, width, height, image )
755 image_information *img;
756 int rle_x, rle_y;
757 int width, height;
758 int mag_size;
759 int x, y;
760 XImage *image;
761 {
762  DMAP_SETUP( img );
763  register int col, bit;
764  register unsigned char *r;
765  register unsigned char *pixel_ptr;
766  register int mag_x;
767  register int w;
768  register int row = (mag_size * rle_y - 1) % 16;
769  unsigned char *line_ptr;
770  unsigned char *rgb_line = SAVED_RLE_ROW( img, rle_y ) + rle_x;
771  int rgb_line_stride = img->w * img->dpy_channels;
772  int x_mod_16 = (mag_size * rle_x) % 16;
773  int x_mod_8 = x % 8;
774  int mag_y = mag_size;
775  int byte_order = BitmapBitOrder(dpy);
776 
777  line_ptr = ((unsigned char *) image->data) +
778  (y * image->bytes_per_line) + x / 8;
779 
780  while (--height >= 0) {
781  pixel_ptr = line_ptr;
782  w = width;
783  r = rgb_line;
784  mag_x = mag_size;
785 
786  row = (row + 1) % 16;
787  col = x_mod_16;
788  bit = x_mod_8;
789 
790  if( byte_order == MSBFirst ) {
791  /* we don't want to trash those good bits */
792  *pixel_ptr >>= (8 - bit) & 7;
793 
794  /* do first byte fragment */
795  while ( bit & 7 )
796  {
797  *pixel_ptr <<= 1;
798  *pixel_ptr |= DMAP(*r, col++, row)!=0;
799  w--;
800  INC_RGB( r++ );
801  bit++;
802  col &= 15;
803  }
804  if ( x_mod_8 )
805  pixel_ptr++;
806 
807  /* do the bulk of the line fast in eight bit chunks Gee I hope all
808  * this fits into your instruction cache... Or else we are
809  * forked.. You can get rid of 7 (col &= 15)'s if you make dm16
810  * a 32x16 array with duplicates in the second half of the columns.
811  * Then we don't have to worry about col overflowing in 8 ++'s
812  */
813  while ((w -= 8) >= 0) {
814  *pixel_ptr = (unsigned char) 0;
815  if ( DMAP(*r, col++, row) )
816  *pixel_ptr = (unsigned char) 0x80;
817  INC_RGB( r++ ); col &= 15;
818  if ( DMAP(*r, col++, row) )
819  *pixel_ptr |= (unsigned char) 0x40;
820  INC_RGB( r++ ); col &= 15;
821  if ( DMAP(*r, col++, row) )
822  *pixel_ptr |= (unsigned char) 0x20;
823  INC_RGB( r++ ); col &= 15;
824  if ( DMAP(*r, col++, row) )
825  *pixel_ptr |= (unsigned char) 0x10;
826  INC_RGB( r++ ); col &= 15;
827  if ( DMAP(*r, col++, row) )
828  *pixel_ptr |= (unsigned char) 0x8;
829  INC_RGB( r++ ); col &= 15;
830  if ( DMAP(*r, col++, row) )
831  *pixel_ptr |= (unsigned char) 0x4;
832  INC_RGB( r++ ); col &= 15;
833  if ( DMAP(*r, col++, row) )
834  *pixel_ptr |= (unsigned char) 0x2;
835  INC_RGB( r++ ); col &= 15;
836  if ( DMAP(*r, col++, row) )
837  *pixel_ptr |= (unsigned char) 0x1;
838  INC_RGB( r++ ); col &= 15;
839  pixel_ptr++;
840  }
841 
842  /* if w is non-zero then we have to finish up... */
843  w = 8 + w;
844  if ( w )
845  {
846  unsigned char savebits;
847 
848  savebits = *pixel_ptr & LSBMask[8-w];
849  bit = w;
850 
851  while (--w >= 0) {
852  *pixel_ptr <<= 1;
853  *pixel_ptr |= (unsigned char)
854  (DMAP(*r, col++, row) ? 0x1 : 0);
855  INC_RGB( r++ ); col &= 15;
856  }
857  *pixel_ptr <<= 8 - bit;
858  *pixel_ptr |= savebits;
859  }
860  }
861  else {
862  /* we don't want to trash those good bits */
863  *pixel_ptr <<= (8 - bit) & 7;
864 
865  /* do first byte fragment */
866  while ( col & 7 ) {
867  *pixel_ptr >>= 1;
868  if ( DMAP(*r, col++, row) )
869  *pixel_ptr |= (unsigned char) 0x80;
870  w--;
871  INC_RGB( r++ ); col &= 15;
872  }
873  if ( x_mod_8 )
874  pixel_ptr++;
875 
876  /* do the bulk of the line fast in eight bit chunks.. */
877  while ((w -= 8) >= 0) {
878  *pixel_ptr = (unsigned char) 0x0;
879  if ( DMAP(*r, col++, row) )
880  *pixel_ptr = (unsigned char) 0x1;
881  INC_RGB( r++ ); col &= 15;
882  if ( DMAP(*r, col++, row) )
883  *pixel_ptr |= (unsigned char) 0x2;
884  INC_RGB( r++ ); col &= 15;
885  if ( DMAP(*r, col++, row) )
886  *pixel_ptr |= (unsigned char) 0x4;
887  INC_RGB( r++ ); col &= 15;
888  if ( DMAP(*r, col++, row) )
889  *pixel_ptr |= (unsigned char) 0x8;
890  INC_RGB( r++ ); col &= 15;
891  if ( DMAP(*r, col++, row) )
892  *pixel_ptr |= (unsigned char) 0x10;
893  INC_RGB( r++ ); col &= 15;
894  if ( DMAP(*r, col++, row) )
895  *pixel_ptr |= (unsigned char) 0x20;
896  INC_RGB( r++ ); col &= 15;
897  if ( DMAP(*r, col++, row) )
898  *pixel_ptr |= (unsigned char) 0x40;
899  INC_RGB( r++ ); col &= 15;
900  if ( DMAP(*r, col++, row) )
901  *pixel_ptr |= (unsigned char) 0x80;
902  INC_RGB( r++ ); col &= 15;
903  pixel_ptr++;
904  }
905 
906  /* if w is negative then we have to finish up... */
907  w = 0 - w;
908 
909  if ( w )
910  {
911  unsigned char savebits = (unsigned char )(*pixel_ptr >> 8 - w);
912  savebits <<= (unsigned char)8 - w;
913  bit = w;
914 
915  while (--w >= 0) {
916  *pixel_ptr >>= 1;
917  if (DMAP(*r, col++, row))
918  *pixel_ptr |= (unsigned char) 0x80;
919  INC_RGB( r++ ); col &= 15;
920  }
921  *pixel_ptr >>= 8 - bit;
922  *pixel_ptr |= savebits;
923  }
924  }
925  line_ptr += image->bytes_per_line;
926  if ( --mag_y == 0 )
927  {
928  rgb_line += rgb_line_stride;
929  mag_y = mag_size;
930  }
931  }
932 }
933 
934 /*
935  * map_2or3_nodither_table_8
936  *
937  * Dither three colors into an eight bit table... This is faster than the
938  * map_scanline_generic routine.
939  *
940  * Inputs:
941  * rgb: Pointers to buffers containing the red, green,
942  * and blue color rows.
943  * n: Length of row.
944  * s: Skip between pixels in original image.
945  * y: Y position of row (necessary for dither)
946  * line: Pointer to output buffer for dithered color data.
947  */
948 
949 static
950 void
951 map_2or3_nodither_table_8 (img, rgb, ncolors, given_width, stride, y, image)
952 image_information *img;
953 unsigned char *rgb[3];
954 int ncolors;
955 int given_width;
956 int stride;
957 int y;
958 XImage *image;
959 
960 {
961  register Pixel *pixel_table = img->pixel_table;
962  NDMAP_SETUP( img );
963  LEVELS_SETUP( img );
964  register unsigned char *r, *g, *b;
965  register unsigned char *pixel_ptr;
966  register int width = given_width;
967 
968  r = rgb[0];
969  g = b = rgb[1];
970  if (ncolors >= 3) b = rgb[2];
971 
972  pixel_ptr = ((unsigned char *) image->data) + y * image->bytes_per_line;
973 
974  while (--width >= 0) {
975  *pixel_ptr++ = pixel_table [ NDMAP(*r)
976  + NDMAP(*g) * levels
977  + NDMAP(*b) * levels_squared];
978  r += stride;
979  g += stride;
980  b += stride;
981  }
982 }
983 static
984 void
985 MAG_2or3_nodither_table_8( img, rle_x, rle_y, mag_size, x, y, width, height, image )
986 image_information *img;
987 int rle_x, rle_y;
988 int width, height;
989 int mag_size;
990 int x, y;
991 XImage *image;
992 
993 {
994  register Pixel *pixel_table = img->pixel_table;
995  NDMAP_SETUP( img );
996  LEVELS_SETUP( img );
997  register unsigned char *r, *g, *b;
998  register unsigned char *pixel_ptr;
999  register unsigned char table_value;
1000  register int mag_x;
1001  int mag_y = mag_size;
1002  register int w;
1003  unsigned char *line_ptr, *last_line;
1004  unsigned char *rgb_line, *last_rgb;
1005  int rgb_line_stride = img->w * img->dpy_channels;
1006 
1007  rgb_line = last_rgb = SAVED_RLE_ROW( img, rle_y ) + rle_x;
1008 
1009  last_line = line_ptr =
1010  ((unsigned char *) image->data)+(y * image->bytes_per_line) + x;
1011 
1012  while (--height >= 0) {
1013  if ( rgb_line == last_rgb && last_line != line_ptr )
1014  memcpy( line_ptr, last_line, width );
1015  else
1016  {
1017  pixel_ptr = line_ptr;
1018  w = width;
1019  r = rgb_line;
1020  mag_x = mag_size;
1021 
1022  g = b = r + img->w;
1023  if (img->dpy_channels >= 3) b += img->w;
1024 
1025  table_value = pixel_table [ NDMAP(*r)
1026  + NDMAP(*g) * levels
1027  + NDMAP(*b) * levels_squared];
1028  while ( --w >= 0 ) {
1029  *pixel_ptr++ = table_value;
1030  if ( --mag_x == 0 )
1031  {
1032  r++, g++, b++;
1033  mag_x = mag_size;
1034  table_value =
1035  pixel_table [ NDMAP(*r)
1036  + NDMAP(*g) * levels
1037  + NDMAP(*b) * levels_squared];
1038  }
1039  }
1040  }
1041  last_line = line_ptr;
1042  last_rgb = rgb_line;
1043 
1044  line_ptr += image->bytes_per_line;
1045  if ( --mag_y == 0 )
1046  {
1047  rgb_line += rgb_line_stride;
1048  mag_y = mag_size;
1049  }
1050  }
1051 }
1052 
1053 /*
1054  * map_1_nodither_table_8
1055  *
1056  * Inputs:
1057  * rgb: Pointers to buffers containing the red, green,
1058  * and blue color rows.
1059  * n: Length of row.
1060  * s: Skip between pixels in original image.
1061  * y: Y position of row (necessary for dither)
1062  * line: Pointer to output buffer for dithered color data.
1063  */
1064 
1065 static void
1066 map_1_nodither_table_8 (img, rgb, ncolors, given_width, stride, y, image)
1067 image_information *img;
1068 unsigned char *rgb[3];
1069 int ncolors;
1070 int given_width;
1071 int stride;
1072 int y;
1073 XImage *image;
1074 
1075 {
1076  register Pixel *pixel_table = img->pixel_table;
1077  NDMAP_SETUP( img );
1078  register unsigned char * r;
1079  register unsigned char * pixel_ptr;
1080  register int width = given_width;
1081 
1082  r = rgb[0];
1083 
1084  pixel_ptr = ((unsigned char *) image->data) + y * image->bytes_per_line;
1085 
1086  while (--width >= 0) {
1087  *pixel_ptr++ = pixel_table [ NDMAP(*r) ];
1088  r += stride;
1089  }
1090 
1091 }
1092 static void
1093 MAG_1_nodither_table_8(img, rle_x, rle_y, mag_size, x, y, width, height, image)
1094 image_information *img;
1095 int rle_x, rle_y;
1096 int width, height;
1097 int mag_size;
1098 int x, y;
1099 XImage *image;
1100 {
1101  register Pixel *pixel_table = img->pixel_table;
1102  NDMAP_SETUP( img );
1103  register unsigned char * r;
1104  register unsigned char * pixel_ptr;
1105  register unsigned char table_value;
1106  register int mag_x;
1107  int mag_y = mag_size;
1108  register int w;
1109  unsigned char *line_ptr, *last_line;
1110  unsigned char *rgb_line, *last_rgb;
1111  int rgb_line_stride = img->w * img->dpy_channels;
1112 
1113  rgb_line = last_rgb = SAVED_RLE_ROW( img, rle_y ) + rle_x;
1114 
1115  last_line = line_ptr =
1116  ((unsigned char *) image->data)+(y * image->bytes_per_line) + x;
1117 
1118  while (--height >= 0) {
1119  if ( rgb_line == last_rgb && last_line != line_ptr )
1120  memcpy( line_ptr, last_line, width );
1121  else
1122  {
1123  pixel_ptr = line_ptr;
1124  w = width;
1125  r = rgb_line;
1126  mag_x = mag_size;
1127 
1128  table_value = pixel_table [ NDMAP(*r) ];
1129  while (--w >= 0) {
1130  *pixel_ptr++ = table_value;
1131  if ( --mag_x == 0 ){
1132  r++;
1133  mag_x = mag_size;
1134  table_value = pixel_table [ NDMAP(*r) ];
1135  }
1136  }
1137  }
1138 
1139  last_line = line_ptr;
1140  last_rgb = rgb_line;
1141 
1142  line_ptr += image->bytes_per_line;
1143  if ( --mag_y == 0 )
1144  {
1145  rgb_line += rgb_line_stride;
1146  mag_y = mag_size;
1147  }
1148  }
1149 }
1150 /*
1151  * map_1_mono_color_8
1152  *
1153  * Inputs:
1154  * rgb: Pointers to buffers containing the red, green,
1155  * and blue color rows.
1156  * n: Length of row.
1157  * s: Skip between pixels in original image.
1158  * y: Y position of row (necessary for dither)
1159  * line: Pointer to output buffer for dithered color data.
1160  */
1161 
1162 static void
1163 map_1_mono_color_8 (img, rgb, ncolors, given_width, stride, y, image)
1164 image_information *img;
1165 unsigned char *rgb[3];
1166 int ncolors;
1167 int given_width;
1168 int stride;
1169 int y;
1170 XImage *image;
1171 
1172 {
1173  register Pixel *pixel_table = img->pixel_table;
1174  register unsigned char * r;
1175  register unsigned char * pixel_ptr;
1176  register int width = given_width;
1177 
1178  r = rgb[0];
1179 
1180  pixel_ptr = ((unsigned char *) image->data) + y * image->bytes_per_line;
1181 
1182  while (--width >= 0) {
1183  *pixel_ptr++ = pixel_table [ *r ];
1184  r += stride;
1185  }
1186 
1187 }
1188 static void
1189 MAG_1_mono_color_8 (img, rle_x, rle_y, mag_size, x, y, width, height, image )
1190 image_information *img;
1191 int rle_x, rle_y;
1192 int width, height;
1193 int mag_size;
1194 int x, y;
1195 XImage *image;
1196 {
1197  register Pixel *pixel_table = img->pixel_table;
1198  register unsigned char * r;
1199  register unsigned char * pixel_ptr;
1200  register unsigned char table_value;
1201  register int mag_x;
1202  int mag_y = mag_size;
1203  register int w;
1204  unsigned char *line_ptr, *last_line;
1205  unsigned char *rgb_line, *last_rgb;
1206  int rgb_line_stride = img->w * img->dpy_channels;
1207 
1208  rgb_line = last_rgb = SAVED_RLE_ROW( img, rle_y ) + rle_x;
1209 
1210  last_line = line_ptr =
1211  ((unsigned char *) image->data)+(y * image->bytes_per_line) + x;
1212 
1213  while (--height >= 0) {
1214  if ( rgb_line == last_rgb && last_line != line_ptr )
1215  memcpy( line_ptr, last_line, width );
1216  else {
1217  pixel_ptr = line_ptr;
1218  w = width;
1219  r = rgb_line;
1220  mag_x = mag_size;
1221 
1222  table_value = pixel_table [ *r ];
1223  while (--w >= 0) {
1224  *pixel_ptr++ = table_value;
1225  if ( --mag_x == 0 ){
1226  r++;
1227  mag_x = mag_size;
1228  table_value = pixel_table [ *r ];
1229  }
1230  }
1231  }
1232 
1233  last_line = line_ptr;
1234  last_rgb = rgb_line;
1235 
1236  line_ptr += image->bytes_per_line;
1237  if ( --mag_y == 0 )
1238  {
1239  rgb_line += rgb_line_stride;
1240  mag_y = mag_size;
1241  }
1242  }
1243 }
1244 
1245 /*
1246  * map_2or3_dither_table_32
1247  *
1248  * Inputs:
1249  * rgb: Pointers to buffers containing the red, green,
1250  * and blue color rows.
1251  * n: Length of row.
1252  * s: Skip between pixels in original image.
1253  * y: Y position of row (necessary for dither)
1254  * line: Pointer to output buffer for dithered color data.
1255  */
1256 
1257 #if 0 /* Never called. */
1258 static
1259 void
1260 map_2or3_dither_table_32 ( img, rgb, ncolors, given_width, stride, y, image)
1261 image_information *img;
1262 unsigned char *rgb[3];
1263 int ncolors;
1264 int given_width;
1265 int stride;
1266 int y;
1267 XImage *image;
1268 
1269 {
1270  register Pixel *pixel_table = img->pixel_table;
1271  DMAP_SETUP( img );
1272  LEVELS_SETUP( img );
1273  register int col;
1274  register int row;
1275  register unsigned char * r;
1276  register unsigned char *g;
1277  register unsigned char *b;
1278  register unsigned long pixval;
1279  register unsigned char * pixel_ptr;
1280  register int width = given_width;
1281  int byte_order = ImageByteOrder( dpy );
1282 
1283  row = y % 16;
1284  col = 0;
1285  r = rgb[0];
1286 
1287  g = b = rgb[1];
1288  if (ncolors >= 3) b = rgb[2];
1289 
1290  pixel_ptr = (unsigned char *)image->data + y * image->bytes_per_line;
1291 
1292  while (--width >= 0) {
1293 
1294  pixval = pixel_table [DMAP(*r, col, row) +
1295  DMAP(*g, col, row) * levels +
1296  DMAP(*b, col, row) * levels_squared];
1297  if ( byte_order == MSBFirst )
1298  {
1299  pixel_ptr += 3;
1300  *pixel_ptr-- = pixval & 0xff;
1301  pixval >>= 8;
1302  *pixel_ptr-- = pixval & 0xff;
1303  pixval >>= 8;
1304  *pixel_ptr-- = pixval & 0xff;
1305  pixval >>= 8;
1306  *pixel_ptr = pixval & 0xff;
1307  pixel_ptr += 4;
1308  }
1309  else
1310  {
1311  *pixel_ptr++ = pixval & 0xff;
1312  pixval >>= 8;
1313  *pixel_ptr++ = pixval & 0xff;
1314  pixval >>= 8;
1315  *pixel_ptr++ = pixval & 0xff;
1316  pixval >>= 8;
1317  *pixel_ptr++ = pixval & 0xff;
1318  }
1319  r += stride;
1320  g += stride;
1321  b += stride;
1322  col = ((col + 1) & 15);
1323 
1324  }
1325 
1326 }
1327 #endif
1328 
1329 #if 0 /* Never called. */
1330 static
1331 void
1332 MAG_2or3_dither_table_32 ( img, rle_x, rle_y, mag_size, x, y, width, height, image )
1333 image_information *img;
1334 int rle_x, rle_y;
1335 int width, height;
1336 int mag_size;
1337 int x, y;
1338 XImage *image;
1339 {
1340  register Pixel *pixel_table = img->pixel_table;
1341  DMAP_SETUP( img );
1342  LEVELS_SETUP( img );
1343  register int col;
1344  register unsigned long pixval;
1345  register unsigned char * pixel_ptr;
1346  register unsigned char *r;
1347  register unsigned char *g;
1348  register unsigned char *b;
1349  register int w;
1350  register int row = (mag_size * rle_y - 1) % 16;
1351  register int mag_x;
1352  int mag_y = mag_size;
1353  int x_mod_16 = (mag_size * rle_x) % 16;
1354  unsigned char *line_ptr;
1355  unsigned char *rgb_line = SAVED_RLE_ROW( img, rle_y ) + rle_x;
1356  int rgb_line_stride = img->w * img->dpy_channels;
1357  int byte_order = ImageByteOrder( dpy );
1358 
1359  line_ptr = (unsigned char *)
1360  ((image->data) + (y * image->bytes_per_line)) + 4 * x;
1361 
1362  while (--height >= 0) {
1363  pixel_ptr = line_ptr;
1364  w = width;
1365  row = (row + 1) % 16;
1366  col = x_mod_16;
1367  r = rgb_line;
1368  mag_x = mag_size;
1369 
1370  g = b = r + img->w;
1371  if (img->dpy_channels >= 3) b += img->w;
1372 
1373  while (--w >= 0) {
1374  pixval = pixel_table [DMAP(*r, col, row) +
1375  DMAP(*g, col, row) * levels +
1376  DMAP(*b, col, row) * levels_squared];
1377  if ( byte_order == MSBFirst )
1378  {
1379  pixel_ptr += 3;
1380  *pixel_ptr-- = pixval & 0xff;
1381  pixval >>= 8;
1382  *pixel_ptr-- = pixval & 0xff;
1383  pixval >>= 8;
1384  *pixel_ptr-- = pixval & 0xff;
1385  pixval >>= 8;
1386  *pixel_ptr = pixval & 0xff;
1387  pixel_ptr += 4;
1388  }
1389  else
1390  {
1391  *pixel_ptr++ = pixval & 0xff;
1392  pixval >>= 8;
1393  *pixel_ptr++ = pixval & 0xff;
1394  pixval >>= 8;
1395  *pixel_ptr++ = pixval & 0xff;
1396  pixval >>= 8;
1397  *pixel_ptr++ = pixval & 0xff;
1398  }
1399  if ( --mag_x == 0 )
1400  {
1401  r++, g++, b++;
1402  mag_x = mag_size;
1403  }
1404  col++;
1405  col &= 15;
1406  }
1407  line_ptr += image->bytes_per_line;
1408  if ( --mag_y == 0 )
1409  {
1410  rgb_line += rgb_line_stride;
1411  mag_y = mag_size;
1412  }
1413  }
1414 }
1415 #endif
1416 
1417 /*
1418  * map_2or3_dither_notable_32
1419  *
1420  * Inputs:
1421  * rgb: Pointers to buffers containing the red, green,
1422  * and blue color rows.
1423  * n: Length of row.
1424  * s: Skip between pixels in original image.
1425  * y: Y position of row (necessary for dither)
1426  * line: Pointer to output buffer for dithered color data.
1427  */
1428 static void
1429 map_2or3_dither_notable_32 (img, rgb, ncolors, given_width, stride, y, image)
1430 image_information *img;
1431 unsigned char *rgb[3];
1432 int ncolors;
1433 int given_width;
1434 int stride;
1435 int y;
1436 XImage *image;
1437 
1438 {
1439  DMAP_SETUP( img );
1440  register int col;
1441  register int row;
1442  register unsigned char *r;
1443  register unsigned char *g;
1444  register unsigned char *b;
1445  register unsigned long pixval;
1446  register unsigned char *pixel_ptr;
1447  register int width = given_width;
1448  int byte_order = ImageByteOrder( dpy );
1449  X_CMAP_SETUP( img );
1450 
1451  row = y % 16;
1452  col = 0;
1453  r = rgb[0];
1454  g = rgb[1];
1455  if (ncolors >= 3) b = rgb[2];
1456  else b = rgb[1];
1457 
1458  pixel_ptr = (unsigned char *) ( image->data + y * image->bytes_per_line );
1459 
1460  while (--width >= 0) {
1461 
1462  pixval = SHIFT_MASK_PIXEL (DMAP(*r, col, row),
1463  DMAP(*g, col, row),
1464  DMAP(*b, col, row));
1465  if ( byte_order == MSBFirst )
1466  {
1467  pixel_ptr += 3;
1468  *pixel_ptr-- = pixval & 0xff;
1469  pixval >>= 8;
1470  *pixel_ptr-- = pixval & 0xff;
1471  pixval >>= 8;
1472  *pixel_ptr-- = pixval & 0xff;
1473  pixval >>= 8;
1474  *pixel_ptr = pixval & 0xff;
1475  pixel_ptr += 4;
1476  }
1477  else
1478  {
1479  *pixel_ptr++ = pixval & 0xff;
1480  pixval >>= 8;
1481  *pixel_ptr++ = pixval & 0xff;
1482  pixval >>= 8;
1483  *pixel_ptr++ = pixval & 0xff;
1484  pixval >>= 8;
1485  *pixel_ptr++ = pixval & 0xff;
1486  }
1487  r += stride;
1488  g += stride;
1489  b += stride;
1490  col = ((col + 1) & 15);
1491  }
1492 }
1493 static void
1494 MAG_2or3_dither_notable_32 ( img, rle_x, rle_y, mag_size, x, y, width, height, image )
1495 image_information *img;
1496 int rle_x, rle_y;
1497 int width, height;
1498 int mag_size;
1499 int x, y;
1500 XImage *image;
1501 {
1502  DMAP_SETUP( img );
1503  register unsigned char *r, *g, *b;
1504  register unsigned long pixval;
1505  register unsigned char *pixel_ptr;
1506  register int row = (mag_size * rle_y - 1) % 16;
1507  register int col;
1508  register int mag_x;
1509  int mag_y = mag_size;
1510  register int w;
1511  int x_mod_16 = (mag_size * rle_x) % 16;
1512  unsigned char *line_ptr;
1513  unsigned char *rgb_line = SAVED_RLE_ROW( img, rle_y ) + rle_x;
1514  int rgb_line_stride = img->w * img->dpy_channels;
1515  int byte_order = ImageByteOrder( dpy );
1516  X_CMAP_SETUP( img );
1517 
1518  line_ptr = (unsigned char *)
1519  (image->data + (y * image->bytes_per_line)) + 4 * x;
1520 
1521  while (--height >= 0) {
1522  pixel_ptr = line_ptr;
1523  w = width;
1524  row = (row + 1) % 16;
1525  col = x_mod_16;
1526  r = rgb_line;
1527  mag_x = mag_size;
1528 
1529  g = b = r + img->w;
1530  if (img->dpy_channels >= 3) b += img->w;
1531 
1532  while (--w >= 0) {
1533  pixval = SHIFT_MASK_PIXEL(DMAP(*r, col, row),
1534  DMAP(*g, col, row),
1535  DMAP(*b, col, row));
1536  if ( byte_order == MSBFirst )
1537  {
1538  pixel_ptr += 3;
1539  *pixel_ptr-- = pixval & 0xff;
1540  pixval >>= 8;
1541  *pixel_ptr-- = pixval & 0xff;
1542  pixval >>= 8;
1543  *pixel_ptr-- = pixval & 0xff;
1544  pixval >>= 8;
1545  *pixel_ptr = pixval & 0xff;
1546  pixel_ptr += 4;
1547  }
1548  else
1549  {
1550  *pixel_ptr++ = pixval & 0xff;
1551  pixval >>= 8;
1552  *pixel_ptr++ = pixval & 0xff;
1553  pixval >>= 8;
1554  *pixel_ptr++ = pixval & 0xff;
1555  pixval >>= 8;
1556  *pixel_ptr++ = pixval & 0xff;
1557  }
1558  if ( --mag_x == 0 )
1559  {
1560  r++, g++, b++;
1561  mag_x = mag_size;
1562  }
1563  col++;
1564  col &= 15;
1565  }
1566  line_ptr += image->bytes_per_line;
1567  if ( --mag_y == 0 )
1568  {
1569  rgb_line += rgb_line_stride;
1570  mag_y = mag_size;
1571  }
1572  }
1573 }
1574 
1575 
1576 /*
1577  * map_2or3_nodither_notable_32
1578  *
1579  * Inputs:
1580  * rgb: Pointers to buffers containing the red, green,
1581  * and blue color rows.
1582  * n: Length of row.
1583  * s: Skip between pixels in original image.
1584  * y: Y position of row (necessary for dither)
1585  * line: Pointer to output buffer for dithered color data.
1586  */
1587 
1588 static
1589 void
1590 map_2or3_nodither_notable_32 (img, rgb, ncolors, given_width, stride, y, image)
1591 image_information *img;
1592 unsigned char *rgb[3];
1593 int ncolors;
1594 int given_width;
1595 int stride;
1596 int y;
1597 XImage *image;
1598 
1599 {
1600  NDMAP_SETUP( img );
1601  register unsigned char *r;
1602  register unsigned char *g;
1603  register unsigned char *b;
1604  register unsigned long pixval;
1605  register unsigned char *pixel_ptr;
1606  register int width = given_width;
1607  int byte_order = ImageByteOrder( dpy );
1608  X_CMAP_SETUP( img );
1609 
1610  r = rgb[0];
1611  g = rgb[1];
1612  if (ncolors >= 3) b = rgb[2];
1613  else b = rgb[1];
1614 
1615  pixel_ptr = (unsigned char *) ( image->data + y * image->bytes_per_line );
1616 
1617  while (--width >= 0) {
1618 
1619  pixval = SHIFT_MASK_PIXEL_32(NDMAP(*r), NDMAP(*g), NDMAP(*b));
1620  if ( byte_order == MSBFirst )
1621  {
1622  pixel_ptr += 3;
1623  *pixel_ptr-- = pixval & 0xff;
1624  pixval >>= 8;
1625  *pixel_ptr-- = pixval & 0xff;
1626  pixval >>= 8;
1627  *pixel_ptr-- = pixval & 0xff;
1628  pixval >>= 8;
1629  *pixel_ptr = pixval & 0xff;
1630  pixel_ptr += 4;
1631  }
1632  else
1633  {
1634  *pixel_ptr++ = pixval & 0xff;
1635  pixval >>= 8;
1636  *pixel_ptr++ = pixval & 0xff;
1637  pixval >>= 8;
1638  *pixel_ptr++ = pixval & 0xff;
1639  pixval >>= 8;
1640  *pixel_ptr++ = pixval & 0xff;
1641  }
1642 
1643  r += stride;
1644  g += stride;
1645  b += stride;
1646 
1647  }
1648 
1649 }
1650 static
1651 void
1652 MAG_2or3_nodither_notable_32 ( img, rle_x, rle_y, mag_size, x, y, width, height, image )
1653 image_information *img;
1654 int rle_x, rle_y;
1655 int width, height;
1656 int mag_size;
1657 int x, y;
1658 XImage *image;
1659 
1660 {
1661  NDMAP_SETUP( img );
1662  register unsigned char *r, *g, *b;
1663  register unsigned long pixval;
1664  register unsigned char *pixel_ptr;
1665  unsigned long pixel_value;
1666  register int mag_x;
1667  int mag_y = mag_size;
1668  register int w;
1669  unsigned char *line_ptr, *last_line;
1670  unsigned char *rgb_line, *last_rgb;
1671  int rgb_line_stride = img->w * img->dpy_channels;
1672  int byte_order = ImageByteOrder( dpy );
1673  X_CMAP_SETUP( img );
1674 
1675  rgb_line = last_rgb = SAVED_RLE_ROW( img, rle_y ) + rle_x;
1676 
1677  last_line = line_ptr = (unsigned char *)
1678  (image->data + (y * image->bytes_per_line)) + 4 * x;
1679 
1680  while (--height >= 0) {
1681  if ( rgb_line == last_rgb && last_line != line_ptr )
1682  memcpy( line_ptr, last_line, width * sizeof(long) );
1683  else
1684  {
1685  pixel_ptr = line_ptr;
1686  w = width;
1687  r = rgb_line;
1688  mag_x = mag_size;
1689 
1690  g = b = r + img->w;
1691  if (img->dpy_channels >= 3) b += img->w;
1692 
1693  pixel_value = SHIFT_MASK_PIXEL_32(NDMAP(*r), NDMAP(*g), NDMAP(*b));
1694 
1695  while (--w >= 0) {
1696  pixval = pixel_value;
1697  if ( byte_order == MSBFirst )
1698  {
1699  pixel_ptr += 3;
1700  *pixel_ptr-- = pixval & 0xff;
1701  pixval >>= 8;
1702  *pixel_ptr-- = pixval & 0xff;
1703  pixval >>= 8;
1704  *pixel_ptr-- = pixval & 0xff;
1705  pixval >>= 8;
1706  *pixel_ptr = pixval & 0xff;
1707  pixel_ptr += 4;
1708  }
1709  else
1710  {
1711  *pixel_ptr++ = pixval & 0xff;
1712  pixval >>= 8;
1713  *pixel_ptr++ = pixval & 0xff;
1714  pixval >>= 8;
1715  *pixel_ptr++ = pixval & 0xff;
1716  pixval >>= 8;
1717  *pixel_ptr++ = pixval & 0xff;
1718  }
1719  if ( --mag_x == 0 )
1720  {
1721  r++, g++, b++;
1722  mag_x = mag_size;
1723  pixel_value = SHIFT_MASK_PIXEL_32(NDMAP(*r),
1724  NDMAP(*g), NDMAP(*b));
1725  }
1726  }
1727  }
1728  last_line = line_ptr;
1729  last_rgb = rgb_line;
1730 
1731  line_ptr += image->bytes_per_line;
1732  if ( --mag_y == 0 )
1733  {
1734  rgb_line += rgb_line_stride;
1735  mag_y = mag_size;
1736  }
1737  }
1738 }
1739 
1740 /*
1741  * map_1_nodither_notable_32
1742  *
1743  * Inputs:
1744  * rgb: Pointers to buffers containing the red, green,
1745  * and blue color rows.
1746  * n: Length of row.
1747  * s: Skip between pixels in original image.
1748  * y: Y position of row (necessary for dither)
1749  * line: Pointer to output buffer for dithered color data.
1750  */
1751 
1752 static
1753 void
1754 map_1_nodither_notable_32 (img, rgb, ncolors, given_width, stride, y, image)
1755 image_information *img;
1756 unsigned char *rgb[3];
1757 int ncolors;
1758 int given_width;
1759 register int stride;
1760 int y;
1761 XImage *image;
1762 
1763 {
1764  NDMAP_SETUP( img );
1765  register unsigned char *r;
1766  register unsigned long pixval;
1767  register unsigned char *pixel_ptr;
1768  register int width = given_width;
1769  int byte_order = ImageByteOrder( dpy );
1770  X_CMAP_SETUP( img );
1771 
1772  r = rgb[0];
1773 
1774  pixel_ptr = (unsigned char *) ( image->data + y * image->bytes_per_line );
1775 
1776  while (--width >= 0) {
1777  register int bw_value = NDMAP(*r);
1778 
1779  pixval = SHIFT_MASK_PIXEL_32( bw_value, bw_value, bw_value );
1780  if ( byte_order == MSBFirst )
1781  {
1782  pixel_ptr += 3;
1783  *pixel_ptr-- = pixval & 0xff;
1784  pixval >>= 8;
1785  *pixel_ptr-- = pixval & 0xff;
1786  pixval >>= 8;
1787  *pixel_ptr-- = pixval & 0xff;
1788  pixval >>= 8;
1789  *pixel_ptr = pixval & 0xff;
1790  pixel_ptr += 4;
1791  }
1792  else
1793  {
1794  *pixel_ptr++ = pixval & 0xff;
1795  pixval >>= 8;
1796  *pixel_ptr++ = pixval & 0xff;
1797  pixval >>= 8;
1798  *pixel_ptr++ = pixval & 0xff;
1799  pixval >>= 8;
1800  *pixel_ptr++ = pixval & 0xff;
1801  }
1802 
1803  r += stride;
1804  }
1805 
1806 }
1807 static
1808 void
1809 MAG_1_nodither_notable_32 ( img, rle_x, rle_y, mag_size, x, y, width, height, image )
1810 image_information *img;
1811 int rle_x, rle_y;
1812 int width, height;
1813 int mag_size;
1814 int x, y;
1815 XImage *image;
1816 
1817 {
1818  NDMAP_SETUP( img );
1819  register unsigned char *r;
1820  register unsigned long pixval;
1821  register unsigned char *pixel_ptr;
1822  unsigned long pixel_value;
1823  register int bw_value;
1824  register int mag_x;
1825  register int w;
1826  register int mag_y = mag_size;
1827  unsigned char *line_ptr, *last_line;
1828  unsigned char *rgb_line, *last_rgb;
1829  int rgb_line_stride = img->w * img->dpy_channels;
1830  int byte_order = ImageByteOrder( dpy );
1831  X_CMAP_SETUP( img );
1832 
1833  rgb_line = last_rgb = SAVED_RLE_ROW( img, rle_y ) + rle_x;
1834 
1835  last_line = line_ptr = (unsigned char *)
1836  (image->data + (y * image->bytes_per_line)) + 4 * x;
1837 
1838  while (--height >= 0) {
1839  if ( rgb_line == last_rgb && last_line != line_ptr )
1840  memcpy( line_ptr, last_line, width * sizeof( long ) );
1841  else
1842  {
1843  pixel_ptr = line_ptr;
1844  w = width;
1845  r = rgb_line;
1846  mag_x = mag_size;
1847 
1848  bw_value = NDMAP(*r);
1849  pixel_value = SHIFT_MASK_PIXEL_32(bw_value, bw_value, bw_value );
1850 
1851  while (--w >= 0) {
1852  pixval = pixel_value;
1853  if ( byte_order == MSBFirst )
1854  {
1855  pixel_ptr += 3;
1856  *pixel_ptr-- = pixval & 0xff;
1857  pixval >>= 8;
1858  *pixel_ptr-- = pixval & 0xff;
1859  pixval >>= 8;
1860  *pixel_ptr-- = pixval & 0xff;
1861  pixval >>= 8;
1862  *pixel_ptr = pixval & 0xff;
1863  pixel_ptr += 4;
1864  }
1865  else
1866  {
1867  *pixel_ptr++ = pixval & 0xff;
1868  pixval >>= 8;
1869  *pixel_ptr++ = pixval & 0xff;
1870  pixval >>= 8;
1871  *pixel_ptr++ = pixval & 0xff;
1872  pixval >>= 8;
1873  *pixel_ptr++ = pixval & 0xff;
1874  }
1875  if ( --mag_x == 0 )
1876  {
1877  r++;
1878  mag_x = mag_size;
1879 
1880  bw_value = NDMAP(*r);
1881  pixel_value =
1882  SHIFT_MASK_PIXEL_32(bw_value, bw_value, bw_value );
1883  }
1884  }
1885  }
1886  last_line = line_ptr;
1887  last_rgb = rgb_line;
1888 
1889  line_ptr += image->bytes_per_line;
1890  if ( --mag_y == 0 )
1891  {
1892  rgb_line += rgb_line_stride;
1893  mag_y = mag_size;
1894  }
1895  }
1896 }
1897 /*
1898  * map_1_mono_color_32
1899  *
1900  * Inputs:
1901  * rgb: Pointers to buffers containing the red, green,
1902  * and blue color rows.
1903  * n: Length of row.
1904  * s: Skip between pixels in original image.
1905  * y: Y position of row (necessary for dither)
1906  * line: Pointer to output buffer for dithered color data.
1907  */
1908 
1909 static
1910 void
1911 map_1_mono_color_32 (img, rgb, ncolors, given_width, stride, y, image)
1912 image_information *img;
1913 unsigned char *rgb[3];
1914 int ncolors;
1915 int given_width;
1916 register int stride;
1917 int y;
1918 XImage *image;
1919 {
1920  register unsigned char *r;
1921  register unsigned long pixval;
1922  register unsigned char *pixel_ptr;
1923  register int width = given_width;
1924  int byte_order = ImageByteOrder( dpy );
1925 
1926  r = rgb[0];
1927 
1928  pixel_ptr = (unsigned char *) ( image->data + y * image->bytes_per_line );
1929 
1930  while (--width >= 0) {
1931  pixval = img->pixel_table[ *r ];
1932  if ( byte_order == MSBFirst )
1933  {
1934  pixel_ptr += 3;
1935  *pixel_ptr-- = pixval & 0xff;
1936  pixval >>= 8;
1937  *pixel_ptr-- = pixval & 0xff;
1938  pixval >>= 8;
1939  *pixel_ptr-- = pixval & 0xff;
1940  pixval >>= 8;
1941  *pixel_ptr = pixval & 0xff;
1942  pixel_ptr += 4;
1943  }
1944  else
1945  {
1946  *pixel_ptr++ = pixval & 0xff;
1947  pixval >>= 8;
1948  *pixel_ptr++ = pixval & 0xff;
1949  pixval >>= 8;
1950  *pixel_ptr++ = pixval & 0xff;
1951  pixval >>= 8;
1952  *pixel_ptr++ = pixval & 0xff;
1953  }
1954  r += stride;
1955  }
1956 
1957 }
1958 static
1959 void
1960 MAG_1_mono_color_32 ( img, rle_x, rle_y, mag_size, x, y, width, height, image )
1961 image_information *img;
1962 int rle_x, rle_y;
1963 int width, height;
1964 int mag_size;
1965 int x, y;
1966 XImage *image;
1967 
1968 {
1969  register unsigned char *r;
1970  register unsigned char *pixel_ptr;
1971  register unsigned long pixval;
1972  unsigned long pixel_value;
1973  register int mag_x;
1974  register int w;
1975  register int mag_y = mag_size;
1976  unsigned char *line_ptr, *last_line;
1977  unsigned char *rgb_line, *last_rgb;
1978  int rgb_line_stride = img->w * img->dpy_channels;
1979  int byte_order = ImageByteOrder( dpy );
1980 
1981  rgb_line = last_rgb = SAVED_RLE_ROW( img, rle_y ) + rle_x;
1982 
1983  last_line = line_ptr = (unsigned char *)
1984  (image->data + (y * image->bytes_per_line)) + 4 * x;
1985 
1986  while (--height >= 0) {
1987  if ( rgb_line == last_rgb && last_line != line_ptr )
1988  memcpy( line_ptr, last_line, width * sizeof( long ) );
1989  else
1990  {
1991  pixel_ptr = line_ptr;
1992  w = width;
1993  r = rgb_line;
1994  mag_x = mag_size;
1995 
1996  pixel_value = img->pixel_table[ *r ];
1997 
1998  while (--w >= 0) {
1999  pixval = pixel_value;
2000  if ( byte_order == MSBFirst )
2001  {
2002  pixel_ptr += 3;
2003  *pixel_ptr-- = pixval & 0xff;
2004  pixval >>= 8;
2005  *pixel_ptr-- = pixval & 0xff;
2006  pixval >>= 8;
2007  *pixel_ptr-- = pixval & 0xff;
2008  pixval >>= 8;
2009  *pixel_ptr = pixval & 0xff;
2010  pixel_ptr += 4;
2011  }
2012  else
2013  {
2014  *pixel_ptr++ = pixval & 0xff;
2015  pixval >>= 8;
2016  *pixel_ptr++ = pixval & 0xff;
2017  pixval >>= 8;
2018  *pixel_ptr++ = pixval & 0xff;
2019  pixval >>= 8;
2020  *pixel_ptr++ = pixval & 0xff;
2021  }
2022  if ( --mag_x == 0 )
2023  {
2024  r++;
2025  mag_x = mag_size;
2026 
2027  pixel_value = img->pixel_table[ *r ];
2028  }
2029  }
2030  }
2031  last_line = line_ptr;
2032  last_rgb = rgb_line;
2033 
2034  line_ptr += image->bytes_per_line;
2035  if ( --mag_y == 0 )
2036  {
2037  rgb_line += rgb_line_stride;
2038  mag_y = mag_size;
2039  }
2040  }
2041 }
2042 
2043 /*****************************************************************
2044  * TAG( map_rgb_to_bw )
2045  *
2046  * Convert RGB to black and white through NTSC transform, but map
2047  * RGB through a color map first.
2048  * Inputs:
2049  * red_row, green_row, blue_row: Given RGB pixel data.
2050  * map: Array[3] of pointers to pixel arrays,
2051  * representing color map.
2052  * rowlen: Number of pixels in the rows.
2053  * Outputs:
2054  * bw_row: Output B&W data. May coincide with one of the
2055  * inputs.
2056  * Algorithm:
2057  * BW = .35*map[0][R] + .55*map[1][G] + .10*map[2][B]
2058  */
2059 void
2061 image_information *img;
2062 rle_pixel **rows;
2063 register rle_pixel *bw_row;
2064 
2065 {
2066  register rle_pixel *red;
2067  register rle_pixel *green;
2068  register rle_pixel *blue;
2069 
2070  rle_pixel **map;
2071  int ncolors;
2072  int rowlen;
2073 
2074  map = img->in_cmap;
2075  ncolors = img->img_channels;
2076  rowlen = img->w;
2077 
2078  if (ncolors < 1) {
2079  fprintf (stderr, "%s: map_rgb_to_bw given %d colors\n",
2080  progname, ncolors);
2081  exit (1);
2082  }
2083 
2084  switch (ncolors) {
2085 
2086  case 1:
2087  red = rows[0];
2088  if ( !map || img->mono_color )
2089  duff8( rowlen, *bw_row++ = *red++)
2090  else {
2091  register rle_pixel *cmap = map[0];
2092  duff8( rowlen, *bw_row++ = cmap[*red++])
2093  }
2094  break;
2095 
2096  case 2:
2097  red = rows[0];
2098  green = rows[1];
2099  if ( !map )
2100  duff8( rowlen, *bw_row++ = ( 50 * *red++ + 50 * *green++ ) / 100)
2101  else {
2102  register rle_pixel **cmap = map;
2103  duff8( rowlen, *bw_row++ = (50 * cmap[0][*red++] +
2104  50 * cmap[1][*green++]) /100)
2105  }
2106  break;
2107 
2108  default:
2109  case 3:
2110  red = rows[0];
2111  green = rows[1];
2112  blue = rows[2];
2113  if ( !map )
2114  duff8( rowlen, *bw_row++ = ( 35 * *red++ + 55 * *green++ +
2115  10 * *blue++ ) / 100)
2116  else {
2117  register rle_pixel **cmap = map;
2118  duff8( rowlen, *bw_row++ = ( 35 * cmap[0][*red++] +
2119  55 * cmap[1][*green++] +
2120  10 * cmap[2][*blue++] ) / 100)
2121  }
2122  break;
2123  }
2124 }
2125 
2126 /*****************************************************************
2127  * TAG( map_rgb_to_rgb )
2128  *
2129  * Convert RGB to RGB through a colormap
2130  * Inputs:
2131  * in_rows: Given RGB pixel data.
2132  * map: Array[3] of pointers to pixel arrays,
2133  * representing color map.
2134  * rowlen: Number of pixels in the rows.
2135  * Outputs:
2136  * out_rows: Output data. May coincide with one of the inputs.
2137  */
2138 void
2140 image_information *img;
2141 rle_pixel **in_rows, **out_rows;
2142 {
2143  register rle_pixel *in, *out, *cmap;
2144  register int w;
2145  rle_pixel **map;
2146  int ncolors;
2147  int rowlen;
2148 
2149  map = img->in_cmap;
2150  ncolors = img->img_channels;
2151  rowlen = img->w;
2152 
2153  if ( ncolors < 1 )
2154  {
2155  fprintf (stderr, "%s: map_rgb_to_rgb given %d colors\n",
2156  progname, ncolors);
2157  exit (1);
2158  }
2159 
2160  if ( map )
2161  while ( --ncolors >= 0 )
2162  {
2163  in = in_rows[0];
2164  out = out_rows[0];
2165  cmap = map[0];
2166  w = rowlen;
2167 
2168  duff8( w, *out++ = cmap[*in++] );
2169 
2170  in_rows++;
2171  out_rows++;
2172  map++;
2173  }
2174  else
2175  while ( --ncolors >= 0 )
2176  {
2177  if ( in_rows[0] != out_rows[0] )
2178  memcpy( out_rows[0], in_rows[0], rowlen );
2179 
2180  in_rows++;
2181  out_rows++;
2182  }
2183 }
2184 
2185 
2187 register image_information *img;
2188 {
2189  if (!img->divN)
2190  img->divN = (int *) malloc ( 256 * sizeof(int) );
2191  if (!img->modN)
2192  img->modN = (int *) malloc ( 256 * sizeof(int) );
2193  if (!img->dm16)
2194  img->dm16 = (array16 *) malloc ( 16 * 16 * sizeof(int) );
2195 
2196  if (!img->divN || !img->modN || !img->dm16 )
2197  {
2198  fprintf( stderr, "malloc error getting dither arrays\n");
2199  exit (1);
2200  }
2201 }
2202 
2203 
2204 int
2206 
2207 Pixel mask;
2208 int high_bit_index;
2209 
2210 {
2211  register int shift;
2212  register Pixel high_bit;
2213 
2214  if (mask == 0) return (0);
2215 
2216  high_bit = 0x80000000;
2217 
2218  for (shift = (32 - high_bit_index); (high_bit & mask) == 0; shift--) {
2219  high_bit >>= 1;
2220  }
2221  return (shift);
2222 }
2223 
2224 
2225 
2226 int
2228 Pixel mask;
2229 {
2230  register int shift;
2231  register Pixel low_bit;
2232 
2233  if (mask == 0) return (0);
2234 
2235  low_bit = 1;
2236 
2237  for (shift = 0; (low_bit & mask) == 0; shift++) {
2238  low_bit <<= 1;
2239  }
2240  return (shift);
2241 }
int Boolean
Definition: getx11.h:53
void get_dither_arrays(register image_information *img)
static unsigned char LSBMask[9]
Definition: map_scan.c:67
#define NDMAP(v)
Definition: map_scan.c:166
void choose_scanline_converter(image_information *img)
Definition: map_scan.c:77
int array16[16]
Definition: getx11.h:79
Display * dpy
Definition: getx10.c:94
#define LEVELS_SETUP(img)
Definition: map_scan.c:177
char * progname
Definition: unslice.c:51
short verbose_flag
Definition: qcr.c:17
Boolean mono_color
Definition: getx11.h:168
void map_rgb_to_rgb(image_information *img, rle_pixel **in_rows, rle_pixel **out_rows)
Definition: map_scan.c:2139
Pixel * pixel_table
Definition: getx11.h:179
#define INC_RGB(stmt)
Definition: map_scan.c:751
int shift_match_right(Pixel mask)
Definition: map_scan.c:2227
#define X_CMAP_SETUP(img)
Definition: map_scan.c:182
#define duff8(counter, block)
Definition: getx11.h:196
#define DMAP_SETUP(img)
Definition: map_scan.c:168
#define NDMAP_SETUP(img)
Definition: map_scan.c:173
#define SHIFT_MASK_PIXEL_32(r, g, b)
Definition: getx11.h:70
int shift_match_left(Pixel mask, int high_bit_index)
Definition: map_scan.c:2205
#define SAVED_RLE_ROW(img, y)
Definition: getx11.h:192
XImage * image
Definition: getx11.h:129
unsigned char rle_pixel
Definition: rle.h:56
Boolean mono_img
Definition: getx11.h:164
rle_pixel ** in_cmap
Definition: getx11.h:171
void map_rgb_to_bw(image_information *img, rle_pixel **rows, register rle_pixel *bw_row)
#define SHIFT_MASK_PIXEL(r, g, b)
Definition: getx11.h:64
VOID_FUNCTION * MAG_scanline
Definition: getx11.h:144
#define DMAP(v, x, y)
Definition: get_orion.c:310
#define COUNT_OF(_array_)
Definition: getx11.h:50
Boolean dither_img
Definition: getx11.h:165
VOID_FUNCTION * map_scanline
Definition: getx11.h:143
array16 * dm16
Definition: getx11.h:177
unsigned long Pixel
Definition: getx11.h:54